Skip to content

Commit 9151b39

Browse files
Dan Carpentertorvalds
authored andcommitted
i2o: check copy_from_user() size parameter
Limit the size of the copy so we don't corrupt memory. Hopefully this can only be called by root, but fixing this makes the static checkers happier. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Cc: Jiri Kosina <jkosina@suse.cz> Cc: Masanari Iida <standby24x7@gmail.com> Cc: Alan Cox <alan@linux.intel.com> Cc: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 79bae42 commit 9151b39

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/message/i2o/i2o_config.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,11 @@ static int i2o_cfg_passthru32(struct file *file, unsigned cmnd,
687687
}
688688
size = size >> 16;
689689
size *= 4;
690+
if (size > sizeof(rmsg)) {
691+
rcode = -EINVAL;
692+
goto sg_list_cleanup;
693+
}
694+
690695
/* Copy in the user's I2O command */
691696
if (copy_from_user(rmsg, user_msg, size)) {
692697
rcode = -EFAULT;
@@ -922,6 +927,11 @@ static int i2o_cfg_passthru(unsigned long arg)
922927
}
923928
size = size >> 16;
924929
size *= 4;
930+
if (size > sizeof(rmsg)) {
931+
rcode = -EFAULT;
932+
goto sg_list_cleanup;
933+
}
934+
925935
/* Copy in the user's I2O command */
926936
if (copy_from_user(rmsg, user_msg, size)) {
927937
rcode = -EFAULT;

0 commit comments

Comments
 (0)