accel/qaic: Fix integer overflow in qaic_validate_req()
Subsystems (4)
PATCH v2 1/1 accel/qaic: Fix integer overflow in qaic_validate_req()
These are u64 variables that come from the user via qaic_attach_slice_bo_ioctl(). Use check_add_overflow() to ensure that the math doesn't have an integer wrapping bug.
Fixes ff13be830333 ("accel/qaic: Add datapath")
Signed-off-by Dan Carpenter <[email protected]>
---
v2: use check_add_overflow() instead of open coding a check
drivers/accel/qaic/qaic_data.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/accel/qaic/qaic_data.c +3 -1
@@ -554,6 +554,7 @@ static bool invalid_sem(struct qaic_sem *sem)static int qaic_validate_req (struct qaic_device *qdev,struct qaic_attach_slice_entry *slice_ent,u32 count,u64 total_size) { +u64 total;int i;for (i =0 ; i < count; i++) {
@@ -563,7 +564,8 @@ static int qaic_validate_req(struct qaic_device *qdev, struct qaic_attach_slice_ invalid_sem(&slice_ent[i].sem2) || invalid_sem(&slice_ent[i].sem3)) return -EINVAL; -if (slice_ent[i].offset + slice_ent[i].size > total_size) +if (check_add_overflow (slice_ent[i].offset, slice_ent[i].size, &total) || + total > total_size)return -EINVAL ; }
Signature · 1 line
2.47.2
Quoted 7 lines · Dan Carpenter
These are u64 variables that come from the user via
qaic_attach_slice_bo_ioctl(). Usecheck_add_overflow()to ensure that the math doesn't have an integer wrapping bug.Fixes ff13be830333 ("accel/qaic: Add datapath")Signed-off-by Dan Carpenter <[email protected]>
Thanks!
Reviewed-by Jeff Hugo <[email protected]>
Quoted 7 lines · Dan Carpenter
These are u64 variables that come from the user via
qaic_attach_slice_bo_ioctl(). Usecheck_add_overflow()to ensure that the math doesn't have an integer wrapping bug.Fixes ff13be830333 ("accel/qaic: Add datapath")Signed-off-by Dan Carpenter <[email protected]>
Pushed to drm-misc-fixes
-Jeff