diff mbox

drivers/net/hamradio: Integer overflow in hdlcdrv_ioctl()

Message ID 1387250728-10795-1-git-send-email-fanwlexca@gmail.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Wenliang Fan Dec. 17, 2013, 3:25 a.m. UTC
The local variable 'bi' comes from userspace. If userspace passed a
large number to 'bi.data.calibrate', there would be an integer overflow
in the following line:
	s->hdlctx.calibrate = bi.data.calibrate * s->par.bitrate / 16;

Signed-off-by: Wenliang Fan <fanwlexca@gmail.com>
---
 drivers/net/hamradio/hdlcdrv.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

David Miller Dec. 19, 2013, 8:03 p.m. UTC | #1
From: Wenliang Fan <fanwlexca@gmail.com>
Date: Tue, 17 Dec 2013 11:25:28 +0800

> The local variable 'bi' comes from userspace. If userspace passed a
> large number to 'bi.data.calibrate', there would be an integer overflow
> in the following line:
> 	s->hdlctx.calibrate = bi.data.calibrate * s->par.bitrate / 16;
> 
> Signed-off-by: Wenliang Fan <fanwlexca@gmail.com>

Applied and queued up for -stable, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c
index 3169252..5d78c1d 100644
--- a/drivers/net/hamradio/hdlcdrv.c
+++ b/drivers/net/hamradio/hdlcdrv.c
@@ -571,6 +571,8 @@  static int hdlcdrv_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 	case HDLCDRVCTL_CALIBRATE:
 		if(!capable(CAP_SYS_RAWIO))
 			return -EPERM;
+		if (bi.data.calibrate > INT_MAX / s->par.bitrate)
+			return -EINVAL;
 		s->hdlctx.calibrate = bi.data.calibrate * s->par.bitrate / 16;
 		return 0;