Skip to content

Commit 67d15c7

Browse files
Dan CarpenterJeff Hugo
authored andcommitted
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. Cc: stable@vger.kernel.org Fixes: ff13be8 ("accel/qaic: Add datapath") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Jeff Hugo <jeff.hugo@oss.qualcomm.com> Signed-off-by: Jeff Hugo <jeff.hugo@oss.qualcomm.com> Link: https://patchwork.freedesktop.org/patch/msgid/176388fa-40fe-4cb4-9aeb-2c91c22130bd@stanley.mountain
1 parent 84a833d commit 67d15c7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/accel/qaic/qaic_data.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ static bool invalid_sem(struct qaic_sem *sem)
557557
static int qaic_validate_req(struct qaic_device *qdev, struct qaic_attach_slice_entry *slice_ent,
558558
u32 count, u64 total_size)
559559
{
560+
u64 total;
560561
int i;
561562

562563
for (i = 0; i < count; i++) {
@@ -566,7 +567,8 @@ static int qaic_validate_req(struct qaic_device *qdev, struct qaic_attach_slice_
566567
invalid_sem(&slice_ent[i].sem2) || invalid_sem(&slice_ent[i].sem3))
567568
return -EINVAL;
568569

569-
if (slice_ent[i].offset + slice_ent[i].size > total_size)
570+
if (check_add_overflow(slice_ent[i].offset, slice_ent[i].size, &total) ||
571+
total > total_size)
570572
return -EINVAL;
571573
}
572574

0 commit comments

Comments
 (0)