Skip to contentSkip to conversation

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

PATCH In review Wenliang Fan 2 participants 2 messages Dec 17, 2013 – Dec 19, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

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;
---
 drivers/net/hamradio/hdlcdrv.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/hamradio/hdlcdrv.c +2 -0
index 3169252..5d78c1d 100644
@@ -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;
 
Signature · 1 line
1.8.5.rc1.28.g7061504
maintainer
#1 lore raw

From: Wenliang Fan <[email protected]>
Date: Tue, 17 Dec 2013 11:25:28 +0800

Quoted 6 lines

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;

Applied and queued up for -stable, thanks.