mirror of
https://github.com/torvalds/linux.git
synced 2025-11-01 00:58:39 +02:00
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 <airlied@redhat.com> Signed-off-by: Philipp Stanner <pstanner@redhat.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
This commit is contained in:
parent
e8183fa10c
commit
cc9c54232f
1 changed files with 2 additions and 2 deletions
|
|
@ -450,8 +450,8 @@ static long i2cdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||||
if (rdwr_arg.nmsgs > I2C_RDWR_IOCTL_MAX_MSGS)
|
if (rdwr_arg.nmsgs > I2C_RDWR_IOCTL_MAX_MSGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
rdwr_pa = memdup_user(rdwr_arg.msgs,
|
rdwr_pa = memdup_array_user(rdwr_arg.msgs,
|
||||||
rdwr_arg.nmsgs * sizeof(struct i2c_msg));
|
rdwr_arg.nmsgs, sizeof(struct i2c_msg));
|
||||||
if (IS_ERR(rdwr_pa))
|
if (IS_ERR(rdwr_pa))
|
||||||
return PTR_ERR(rdwr_pa);
|
return PTR_ERR(rdwr_pa);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue