lkml.org 
[lkml]   [2013]   [Dec]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] scsi: integer overflow in megadev_ioctl()
Date
From: "Chen.Yu" <chyyuu@gmail.com>

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,..)

Reported-by: Wenliang Fan <fanwlexca@gmail.com>
Suggested-by: Qixue Xiao <xiaoqixue_1@163.com>
Signed-off-by: Yu Chen <chyyuu@gmail.com>
Reviewed-by: Levente Kurusa <levex@linux.com>
---
drivers/scsi/megaraid.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 816db12..0b90c54 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -3099,7 +3099,10 @@ megadev_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
/*
* Which adapter
*/
- if( (adapno = GETADAP(uioc.adapno)) >= hba_count )
+ adapno = GETADAP(uioc.adapno);
+ if( adapno < 0 )
+ return (-EINVAL);
+ if( adapno >= hba_count )
return (-ENODEV);

if( copy_to_user(uioc.uioc_uaddr, mcontroller+adapno,
@@ -3113,7 +3116,10 @@ megadev_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
/*
* Which adapter
*/
- if( (adapno = GETADAP(uioc.adapno)) >= hba_count )
+ adapno = GETADAP(uioc.adapno);
+ if( adapno < 0 )
+ return (-EINVAL);
+ if( adapno >= hba_count )
return (-ENODEV);

adapter = hba_soft_state[adapno];
@@ -3160,7 +3166,10 @@ megadev_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
/*
* Which adapter
*/
- if( (adapno = GETADAP(uioc.adapno)) >= hba_count )
+ adapno = GETADAP(uioc.adapno);
+ if( adapno < 0 )
+ return (-EINVAL);
+ if( adapno >= hba_count )
return (-ENODEV);

adapter = hba_soft_state[adapno];
--
1.8.3.2


\
 
 \ /
  Last update: 2013-12-13 20:21    [W:0.065 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site