* [PATCH] drivers/i2c: copy userspace array safely
@ 2023-11-02 19:26 Philipp Stanner
2023-11-08 9:26 ` Wolfram Sang
0 siblings, 1 reply; 2+ messages in thread
From: Philipp Stanner @ 2023-11-02 19:26 UTC (permalink / raw)
To: Wolfram Sang; +Cc: linux-i2c, linux-kernel, Philipp Stanner, Dave Airlie
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>
---
drivers/i2c/i2c-dev.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index a01b59e3599b..7d337380a05d 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -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)
return -EINVAL;
- rdwr_pa = memdup_user(rdwr_arg.msgs,
- rdwr_arg.nmsgs * sizeof(struct i2c_msg));
+ rdwr_pa = memdup_array_user(rdwr_arg.msgs,
+ rdwr_arg.nmsgs, sizeof(struct i2c_msg));
if (IS_ERR(rdwr_pa))
return PTR_ERR(rdwr_pa);
--
2.41.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drivers/i2c: copy userspace array safely
2023-11-02 19:26 [PATCH] drivers/i2c: copy userspace array safely Philipp Stanner
@ 2023-11-08 9:26 ` Wolfram Sang
0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Sang @ 2023-11-08 9:26 UTC (permalink / raw)
To: Philipp Stanner; +Cc: linux-i2c, linux-kernel, Dave Airlie
[-- Attachment #1: Type: text/plain, Size: 397 bytes --]
On Thu, Nov 02, 2023 at 08:26:13PM +0100, Philipp Stanner wrote:
> 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>
Applied to for-current, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-11-08 9:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-02 19:26 [PATCH] drivers/i2c: copy userspace array safely Philipp Stanner
2023-11-08 9:26 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox