Skip to content

Commit cc9c542

Browse files
Philipp Stannerwsakernel
authored andcommitted
i2c: dev: copy userspace array safely
i2c-dev.c utilizes memdup_user() to copy a userspace array. This is done without an overflow check. Use the new wrapper memdup_array_user() to copy the array more safely. Suggested-by: Dave Airlie <[email protected]> Signed-off-by: Philipp Stanner <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent e8183fa commit cc9c542

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/i2c/i2c-dev.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,8 @@ static long i2cdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
450450
if (rdwr_arg.nmsgs > I2C_RDWR_IOCTL_MAX_MSGS)
451451
return -EINVAL;
452452

453-
rdwr_pa = memdup_user(rdwr_arg.msgs,
454-
rdwr_arg.nmsgs * sizeof(struct i2c_msg));
453+
rdwr_pa = memdup_array_user(rdwr_arg.msgs,
454+
rdwr_arg.nmsgs, sizeof(struct i2c_msg));
455455
if (IS_ERR(rdwr_pa))
456456
return PTR_ERR(rdwr_pa);
457457

0 commit comments

Comments
 (0)