Skip to contentSkip to conversation

scsi: integer overflow in megadev_ioctl()

PATCH New Chen.Yu 1 participant 1 message Dec 14, 2013

Subsystems (2)
lore
Share & tools
lore

Chen.Yu

author
#0 lore raw

PATCH 1/1 scsi: integer overflow in megadev_ioctl()

From: "Chen.Yu" <[email protected]>

There is a potential integer overflow in megadev_ioctl() if userspace passes in a large u32 variable uioc.adapno. The int variable adapno would < 0, leading to an error array access for hdb_soft_state[adapno], or an error copy_to_user(uioc.uioc_uaddr, mcontroller+adapno,..). The simple fix is to the simpler fix is to change the type of 'adapno' to u32, which is the type of uioc.adapno to u32.

---
 drivers/scsi/megaraid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/megaraid.c +1 -1
index 816db12..724c5a5 100644
@@ -3038,7 +3038,7 @@ megadev_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
 {
 	adapter_t	*adapter;
 	nitioctl_t	uioc;
-	int		adapno;
+	u32		adapno;
 	int		rval;
 	mega_passthru	__user *upthru;	/* user address for passthru */
 	mega_passthru	*pthru;		/* copy user passthru here */
Signature · 1 line
1.8.3.2