All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rob Clark" <robin.clark@oss.qualcomm.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v4 6/6] drm/msm: Remove invalid overflow check
Date: Wed, 08 Jul 2026 17:40:25 +0000	[thread overview]
Message-ID: <20260708174026.5A8B61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260708173356.578713-7-robin.clark@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] Integer Truncation leading to Heap Buffer Overflow on 32-bit architectures.
--

--- Patch [6]: [PATCH v4 6/6] drm/msm: Remove invalid overflow check ---
commit b6fd344e5aae554bc6124eb5aa28a19da1bb53c5
Author: Rob Clark <robin.clark@oss.qualcomm.com>

drm/msm: Remove invalid overflow check

This commit changes the size variable for the msm_gem_submit allocation
from uint64_t to size_t and removes the explicit check against SIZE_MAX,
relying on kzalloc to handle struct_size overflows natively.

> diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
> index 0dc983d155cd2..744af6389ac62 100644
> --- a/drivers/gpu/drm/msm/msm_gem_submit.c
> +++ b/drivers/gpu/drm/msm/msm_gem_submit.c
> @@ -36,15 +36,11 @@ static struct msm_gem_submit *submit_create(struct drm_device *dev,
>  {
>  	static atomic_t ident = ATOMIC_INIT(0);
>  	struct msm_gem_submit *submit;
> -	uint64_t sz;
> +	size_t sz;
>  	int ret;
>  
>  	sz = struct_size(submit, bos, nr_bos) +
>  			((u64)nr_cmds * sizeof(submit->cmd[0]));
> -
> -	if (sz > SIZE_MAX)
> -		return ERR_PTR(-ENOMEM);
> -

[Severity: Critical]
Does changing sz to size_t introduce an integer truncation vulnerability on
32-bit architectures?

The right side of this assignment evaluates to a 64-bit value because
nr_cmds is cast to u64. If struct_size() overflows and returns SIZE_MAX, or if
nr_cmds is extremely large, the addition results in a value exceeding 4GB.

When this 64-bit value is assigned to a 32-bit size_t variable on 32-bit
architectures, it will implicitly truncate and wrap around to a small value.
Since kzalloc() is now passed this truncated size, it will successfully
allocate a small buffer instead of failing.

Could this allow user-controlled nr_cmds and nr_bos values to trigger a heap
buffer overflow when subsequent loops write past the allocated bounds?

>  	submit = kzalloc(sz, GFP_KERNEL | __GFP_NOWARN);
>  	if (!submit)
>  		return ERR_PTR(-ENOMEM);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260708173356.578713-1-robin.clark@oss.qualcomm.com?part=6

      reply	other threads:[~2026-07-08 17:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-08 17:33 [PATCH v4 0/6] drm/msm: A couple lazy-vm fixes Rob Clark
2026-07-08 17:33 ` [PATCH v4 1/6] drm/msm: Fix barriers accessing ctx vm Rob Clark
2026-07-08 17:52   ` sashiko-bot
2026-07-08 17:33 ` [PATCH v4 2/6] drm/msm: Block VM_BIND for shared VMs Rob Clark
2026-07-08 17:50   ` sashiko-bot
2026-07-08 17:33 ` [PATCH v4 3/6] drm/msm: Validate lazy VM is created in GEM_SUBMIT Rob Clark
2026-07-08 17:53   ` sashiko-bot
2026-07-08 17:33 ` [PATCH v4 4/6] drm/msm: Validate lazy VM in GEM_NEW Rob Clark
2026-07-08 17:33 ` [PATCH v4 5/6] drm/msm: Fix per-process-pgtables check Rob Clark
2026-07-08 17:47   ` sashiko-bot
2026-07-08 17:33 ` [PATCH v4 6/6] drm/msm: Remove invalid overflow check Rob Clark
2026-07-08 17:40   ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260708174026.5A8B61F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=robin.clark@oss.qualcomm.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.