Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
* [PATCH] accel/qaic: Replace user defined overflow check
@ 2025-10-15 15:22 Youssef Samir
  2025-10-15 16:01 ` Carl Vanderlip
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Youssef Samir @ 2025-10-15 15:22 UTC (permalink / raw)
  To: jeff.hugo, carl.vanderlip, troy.hanson, zachary.mckevitt
  Cc: ogabbay, lizhi.hou, karol.wachowski, linux-arm-msm, dri-devel

From: Sourab Bera <quic_sourbera@quicinc.com>

Replace the current logic to check overflow, with the kernel-provided
macro `check_mul_overflow` in the function __qaic_execute_bo_ioctl().

Signed-off-by: Sourab Bera <quic_sourbera@quicinc.com>
Signed-off-by: Youssef Samir <youssef.abdulrahman@oss.qualcomm.com>
---
 drivers/accel/qaic/qaic_data.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/accel/qaic/qaic_data.c b/drivers/accel/qaic/qaic_data.c
index 797289e9d780..e6f96dbb3382 100644
--- a/drivers/accel/qaic/qaic_data.c
+++ b/drivers/accel/qaic/qaic_data.c
@@ -15,6 +15,7 @@
 #include <linux/math64.h>
 #include <linux/mm.h>
 #include <linux/moduleparam.h>
+#include <linux/overflow.h>
 #include <linux/scatterlist.h>
 #include <linux/spinlock.h>
 #include <linux/srcu.h>
@@ -1305,17 +1306,17 @@ static int __qaic_execute_bo_ioctl(struct drm_device *dev, void *data, struct dr
 	u64 received_ts;
 	u32 queue_level;
 	u64 submit_ts;
+	size_t size;
 	int rcu_id;
 	u32 head;
 	u32 tail;
-	u64 size;
 	int ret;
 
 	received_ts = ktime_get_ns();
 
 	size = is_partial ? sizeof(struct qaic_partial_execute_entry) : sizeof(*exec);
-	n = (unsigned long)size * args->hdr.count;
-	if (args->hdr.count == 0 || n / args->hdr.count != size)
+	if (args->hdr.count == 0 ||
+	    check_mul_overflow((unsigned long)size, (unsigned long)args->hdr.count, &n))
 		return -EINVAL;
 
 	user_data = u64_to_user_ptr(args->data);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] accel/qaic: Replace user defined overflow check
  2025-10-15 15:22 [PATCH] accel/qaic: Replace user defined overflow check Youssef Samir
@ 2025-10-15 16:01 ` Carl Vanderlip
  2025-10-15 16:42 ` Jeff Hugo
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Carl Vanderlip @ 2025-10-15 16:01 UTC (permalink / raw)
  To: Youssef Samir, jeff.hugo, troy.hanson, zachary.mckevitt
  Cc: ogabbay, lizhi.hou, karol.wachowski, linux-arm-msm, dri-devel

On 10/15/2025 8:22 AM, Youssef Samir wrote:
> From: Sourab Bera <quic_sourbera@quicinc.com>
> 
> Replace the current logic to check overflow, with the kernel-provided
> macro `check_mul_overflow` in the function __qaic_execute_bo_ioctl().
> 
> Signed-off-by: Sourab Bera <quic_sourbera@quicinc.com>
> Signed-off-by: Youssef Samir <youssef.abdulrahman@oss.qualcomm.com>
> ---

Reviewed-by: Carl Vanderlip <carl.vanderlip@oss.qualcomm.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] accel/qaic: Replace user defined overflow check
  2025-10-15 15:22 [PATCH] accel/qaic: Replace user defined overflow check Youssef Samir
  2025-10-15 16:01 ` Carl Vanderlip
@ 2025-10-15 16:42 ` Jeff Hugo
  2025-10-17 15:13 ` Falkowski, Maciej
  2025-10-20 15:05 ` Jeff Hugo
  3 siblings, 0 replies; 6+ messages in thread
From: Jeff Hugo @ 2025-10-15 16:42 UTC (permalink / raw)
  To: Youssef Samir, carl.vanderlip, troy.hanson, zachary.mckevitt
  Cc: ogabbay, lizhi.hou, karol.wachowski, linux-arm-msm, dri-devel

On 10/15/2025 9:22 AM, Youssef Samir wrote:
> From: Sourab Bera <quic_sourbera@quicinc.com>
> 
> Replace the current logic to check overflow, with the kernel-provided
> macro `check_mul_overflow` in the function __qaic_execute_bo_ioctl().
> 
> Signed-off-by: Sourab Bera <quic_sourbera@quicinc.com>
> Signed-off-by: Youssef Samir <youssef.abdulrahman@oss.qualcomm.com>

Reviewed-by: Jeff Hugo <jeff.hugo@oss.qualcomm.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] accel/qaic: Replace user defined overflow check
  2025-10-15 15:22 [PATCH] accel/qaic: Replace user defined overflow check Youssef Samir
  2025-10-15 16:01 ` Carl Vanderlip
  2025-10-15 16:42 ` Jeff Hugo
@ 2025-10-17 15:13 ` Falkowski, Maciej
  2025-10-20 15:05 ` Jeff Hugo
  3 siblings, 0 replies; 6+ messages in thread
From: Falkowski, Maciej @ 2025-10-17 15:13 UTC (permalink / raw)
  To: Youssef Samir, jeff.hugo, carl.vanderlip, troy.hanson,
	zachary.mckevitt
  Cc: ogabbay, lizhi.hou, karol.wachowski, linux-arm-msm, dri-devel

Reviewed-by: Maciej Falkowski <maciej.falkowski@linux.intel.com>

On 10/15/2025 5:22 PM, Youssef Samir wrote:
> From: Sourab Bera <quic_sourbera@quicinc.com>
>
> Replace the current logic to check overflow, with the kernel-provided
> macro `check_mul_overflow` in the function __qaic_execute_bo_ioctl().
>
> Signed-off-by: Sourab Bera <quic_sourbera@quicinc.com>
> Signed-off-by: Youssef Samir <youssef.abdulrahman@oss.qualcomm.com>
> ---
>   drivers/accel/qaic/qaic_data.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/accel/qaic/qaic_data.c b/drivers/accel/qaic/qaic_data.c
> index 797289e9d780..e6f96dbb3382 100644
> --- a/drivers/accel/qaic/qaic_data.c
> +++ b/drivers/accel/qaic/qaic_data.c
> @@ -15,6 +15,7 @@
>   #include <linux/math64.h>
>   #include <linux/mm.h>
>   #include <linux/moduleparam.h>
> +#include <linux/overflow.h>
>   #include <linux/scatterlist.h>
>   #include <linux/spinlock.h>
>   #include <linux/srcu.h>
> @@ -1305,17 +1306,17 @@ static int __qaic_execute_bo_ioctl(struct drm_device *dev, void *data, struct dr
>   	u64 received_ts;
>   	u32 queue_level;
>   	u64 submit_ts;
> +	size_t size;
>   	int rcu_id;
>   	u32 head;
>   	u32 tail;
> -	u64 size;
>   	int ret;
>   
>   	received_ts = ktime_get_ns();
>   
>   	size = is_partial ? sizeof(struct qaic_partial_execute_entry) : sizeof(*exec);
> -	n = (unsigned long)size * args->hdr.count;
> -	if (args->hdr.count == 0 || n / args->hdr.count != size)
> +	if (args->hdr.count == 0 ||
> +	    check_mul_overflow((unsigned long)size, (unsigned long)args->hdr.count, &n))
>   		return -EINVAL;
>   
>   	user_data = u64_to_user_ptr(args->data);

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] accel/qaic: Replace user defined overflow check
  2025-10-15 15:22 [PATCH] accel/qaic: Replace user defined overflow check Youssef Samir
                   ` (2 preceding siblings ...)
  2025-10-17 15:13 ` Falkowski, Maciej
@ 2025-10-20 15:05 ` Jeff Hugo
  2025-10-21 16:03   ` Youssef Abdulrahman
  3 siblings, 1 reply; 6+ messages in thread
From: Jeff Hugo @ 2025-10-20 15:05 UTC (permalink / raw)
  To: Youssef Samir, carl.vanderlip, troy.hanson, zachary.mckevitt
  Cc: ogabbay, lizhi.hou, karol.wachowski, linux-arm-msm, dri-devel

On 10/15/2025 9:22 AM, Youssef Samir wrote:
> From: Sourab Bera <quic_sourbera@quicinc.com>
> 
> Replace the current logic to check overflow, with the kernel-provided
> macro `check_mul_overflow` in the function __qaic_execute_bo_ioctl().
> 
> Signed-off-by: Sourab Bera <quic_sourbera@quicinc.com>
> Signed-off-by: Youssef Samir <youssef.abdulrahman@oss.qualcomm.com>

Youssef,

It looks like this conflicts with "accel/qaic: Replace kcalloc + 
copy_from_user with memdup_array_user".  It looks like we don't need to 
bring back the overflow check, which would make this change no longer 
needed.

Can you have a look and see if you agree?

-Jeff

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] accel/qaic: Replace user defined overflow check
  2025-10-20 15:05 ` Jeff Hugo
@ 2025-10-21 16:03   ` Youssef Abdulrahman
  0 siblings, 0 replies; 6+ messages in thread
From: Youssef Abdulrahman @ 2025-10-21 16:03 UTC (permalink / raw)
  To: Jeff Hugo
  Cc: carl.vanderlip, troy.hanson, zachary.mckevitt, ogabbay, lizhi.hou,
	karol.wachowski, linux-arm-msm, dri-devel

On Mon, Oct 20, 2025 at 4:05 PM Jeff Hugo <jeff.hugo@oss.qualcomm.com> wrote:
>
> On 10/15/2025 9:22 AM, Youssef Samir wrote:
> > From: Sourab Bera <quic_sourbera@quicinc.com>
> >
> > Replace the current logic to check overflow, with the kernel-provided
> > macro `check_mul_overflow` in the function __qaic_execute_bo_ioctl().
> >
> > Signed-off-by: Sourab Bera <quic_sourbera@quicinc.com>
> > Signed-off-by: Youssef Samir <youssef.abdulrahman@oss.qualcomm.com>
>
> Youssef,
>
> It looks like this conflicts with "accel/qaic: Replace kcalloc +
> copy_from_user with memdup_array_user".  It looks like we don't need to
> bring back the overflow check, which would make this change no longer
> needed.
>
> Can you have a look and see if you agree?
Hi Jeff,

I checked it out and you're right. It doesn't apply anymore.

-Youssef

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-10-21 16:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-15 15:22 [PATCH] accel/qaic: Replace user defined overflow check Youssef Samir
2025-10-15 16:01 ` Carl Vanderlip
2025-10-15 16:42 ` Jeff Hugo
2025-10-17 15:13 ` Falkowski, Maciej
2025-10-20 15:05 ` Jeff Hugo
2025-10-21 16:03   ` Youssef Abdulrahman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox