[SCSI] megaraid: missing bounds check in mimd_to_kioc()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 30 Oct 2013 17:13:51 +0000 (20:13 +0300)
committerJames Bottomley <JBottomley@Parallels.com>
Sat, 15 Mar 2014 17:19:00 +0000 (10:19 -0700)
pthru32->dataxferlen comes from the user so we need to check that it's
not too large so we don't overflow the buffer.

Reported-by: Nico Golde <nico@ngolde.de>
Reported-by: Fabian Yamaguchi <fabs@goesec.de>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Sumit Saxena <sumit.saxena@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
drivers/scsi/megaraid/megaraid_mm.c

index dfffd0f37916f18097eaafe21eb2589b033d9193..a70692779a16c770300b410eda56a9f1823e9239 100644 (file)
@@ -486,6 +486,8 @@ mimd_to_kioc(mimd_t __user *umimd, mraid_mmadp_t *adp, uioc_t *kioc)
 
        pthru32->dataxferaddr   = kioc->buf_paddr;
        if (kioc->data_dir & UIOC_WR) {
+               if (pthru32->dataxferlen > kioc->xferlen)
+                       return -EINVAL;
                if (copy_from_user(kioc->buf_vaddr, kioc->user_data,
                                                pthru32->dataxferlen)) {
                        return (-EFAULT);