* [PATCH v2] accel/qaic: Fix integer overflow in qaic_validate_req()
@ 2025-03-07 8:41 Dan Carpenter
2025-03-14 16:46 ` Jeff Hugo
2025-03-14 16:48 ` Jeff Hugo
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2025-03-07 8:41 UTC (permalink / raw)
To: Jeff Hugo
Cc: Carl Vanderlip, Oded Gabbay, Jacek Lawrynowicz,
Pranjal Ramajor Asha Kanojiya, Stanislaw Gruszka, linux-arm-msm,
dri-devel, linux-kernel, kernel-janitors
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: ff13be830333 ("accel/qaic: Add datapath")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
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(-)
diff --git a/drivers/accel/qaic/qaic_data.c b/drivers/accel/qaic/qaic_data.c
index c20eb63750f5..631e401fbe4a 100644
--- a/drivers/accel/qaic/qaic_data.c
+++ b/drivers/accel/qaic/qaic_data.c
@@ -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;
}
--
2.47.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] accel/qaic: Fix integer overflow in qaic_validate_req()
2025-03-07 8:41 [PATCH v2] accel/qaic: Fix integer overflow in qaic_validate_req() Dan Carpenter
@ 2025-03-14 16:46 ` Jeff Hugo
2025-03-14 16:48 ` Jeff Hugo
1 sibling, 0 replies; 3+ messages in thread
From: Jeff Hugo @ 2025-03-14 16:46 UTC (permalink / raw)
To: Dan Carpenter
Cc: Carl Vanderlip, Oded Gabbay, Jacek Lawrynowicz,
Pranjal Ramajor Asha Kanojiya, Stanislaw Gruszka, linux-arm-msm,
dri-devel, linux-kernel, kernel-janitors
On 3/7/2025 1:41 AM, Dan Carpenter wrote:
> 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: ff13be830333 ("accel/qaic: Add datapath")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Thanks!
Reviewed-by: Jeff Hugo <jeff.hugo@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] accel/qaic: Fix integer overflow in qaic_validate_req()
2025-03-07 8:41 [PATCH v2] accel/qaic: Fix integer overflow in qaic_validate_req() Dan Carpenter
2025-03-14 16:46 ` Jeff Hugo
@ 2025-03-14 16:48 ` Jeff Hugo
1 sibling, 0 replies; 3+ messages in thread
From: Jeff Hugo @ 2025-03-14 16:48 UTC (permalink / raw)
To: Dan Carpenter
Cc: Carl Vanderlip, Oded Gabbay, Jacek Lawrynowicz,
Pranjal Ramajor Asha Kanojiya, Stanislaw Gruszka, linux-arm-msm,
dri-devel, linux-kernel, kernel-janitors
On 3/7/2025 1:41 AM, Dan Carpenter wrote:
> 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: ff13be830333 ("accel/qaic: Add datapath")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Pushed to drm-misc-fixes
-Jeff
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-14 16:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-07 8:41 [PATCH v2] accel/qaic: Fix integer overflow in qaic_validate_req() Dan Carpenter
2025-03-14 16:46 ` Jeff Hugo
2025-03-14 16:48 ` Jeff Hugo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox