aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2015-07-03 04:53:03 -0400
committerJames Bottomley <JBottomley@Odin.com>2015-08-26 10:11:45 -0400
commite819cdb198319cccf4af4fc12ac4d796109d8c23 (patch)
tree5ebde58eb5e51eb6dc52149192e00ff9a13275e4 /drivers/message
parent8d6a9f5676f0e734967ac3739f5c6a28a0b047d9 (diff)
mptfusion: prevent some memory corruption
These are signed values the come from the user, we put a cap on the upper bounds but not on the lower bounds. We use "karg.dataSgeOffset" to calculate "sz". We verify "sz" and proceed as if that means that "karg.dataSgeOffset" is correct but this fails to consider that the "sz" calculations can have integer overflows. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: James Bottomley <JBottomley@Odin.com>
Diffstat (limited to 'drivers/message')
-rw-r--r--drivers/message/fusion/mptctl.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
index 70bb7530b22c..fc7393729081 100644
--- a/drivers/message/fusion/mptctl.c
+++ b/drivers/message/fusion/mptctl.c
@@ -1859,6 +1859,15 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr)
1859 } 1859 }
1860 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); 1860 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags);
1861 1861
1862 /* Basic sanity checks to prevent underflows or integer overflows */
1863 if (karg.maxReplyBytes < 0 ||
1864 karg.dataInSize < 0 ||
1865 karg.dataOutSize < 0 ||
1866 karg.dataSgeOffset < 0 ||
1867 karg.maxSenseBytes < 0 ||
1868 karg.dataSgeOffset > ioc->req_sz / 4)
1869 return -EINVAL;
1870
1862 /* Verify that the final request frame will not be too large. 1871 /* Verify that the final request frame will not be too large.
1863 */ 1872 */
1864 sz = karg.dataSgeOffset * 4; 1873 sz = karg.dataSgeOffset * 4;