drivers/fpga: copy userspace array safely
Subsystems (2)
PATCH 1/1 drivers/fpga: copy userspace array safely
dfl.c utilizes memdup_user() and array_size() to copy a userspace array. Currently, this does not check for an overflow.
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]>
---
Linus recently merged this new wrapper for Kernel v6.7
--- drivers/fpga/dfl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/fpga/dfl.c +2 -2
@@ -2008,8 +2008,8 @@ long dfl_feature_ioctl_set_irq(struct platform_device *pdev, (hdr.start + hdr.count < hdr.start))return -EINVAL ; - fds =memdup_user ((void __user *)(arg +sizeof (hdr)), -array_size (hdr.count,sizeof (s32))); + fds =memdup_array_user ((void __user *)(arg +sizeof (hdr)), + hdr.count,sizeof (s32));if (IS_ERR (fds))return PTR_ERR (fds);
Signature · 1 line
2.41.0
Quoted 2 lines · Philipp Stanner
dfl.cutilizesmemdup_user()andarray_size()to copy a userspace array. Currently, this does not check for an overflow.
array_size() actually checks for overflow, so please re-write the changelog.
Thanks,
Yilun
Quoted 29 lines
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]>---
Linus recently merged this new wrapper for Kernel v6.7--- drivers/fpga/dfl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/fpga/dfl.c +2
-2@@ -2008,8 +2008,8 @@ long dfl_feature_ioctl_set_irq(struct platform_device *pdev, (hdr.start + hdr.count < hdr.start))return -EINVAL ; - fds =memdup_user ((void __user *)(arg +sizeof (hdr)), -array_size (hdr.count,sizeof (s32))); + fds =memdup_array_user ((void __user *)(arg +sizeof (hdr)), + hdr.count,sizeof (s32));if (IS_ERR (fds))return PTR_ERR (fds);Signature · 1 line
2.41.0