From: sashiko-bot@kernel.org
To: "Rob Clark" <robin.clark@oss.qualcomm.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v7 05/17] drm/msm: Move nr_cmds initialization
Date: Wed, 29 Jul 2026 18:14:39 +0000 [thread overview]
Message-ID: <20260729181439.E7A2B1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260729155609.20190-6-robin.clark@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Direct access to lazy-initialized `ctx->vm` without ensuring it exists causes a NULL pointer dereference.
- [Critical] The overflow check `sz > SIZE_MAX` after using `struct_size()` is dead code on 64-bit architectures, providing no protection against integer overflows.
--
--- Patch [5]: [PATCH v7 05/17] drm/msm: Move nr_cmds initialization ---
commit cc137d18d60eae340c7d4959cae7bc281443d450
Author: Rob Clark <robin.clark@oss.qualcomm.com>
drm/msm: Move nr_cmds initialization
Previously if we entered an error path between these two points, we
could leak the relocs tables due to submit->nr_cmds still being zero.
In practice, relocs are disallowed on a6xx+, and non-ancient userspace
will not use relocs on earlier gens unless running on an ancient kernel.
But userspace could use this to trigger a memory leak.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com>
> diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
> index 3c6bc90c3d486..aa48ea4e7f584 100644
> --- a/drivers/gpu/drm/msm/msm_gem_submit.c
> +++ b/drivers/gpu/drm/msm/msm_gem_submit.c
[Severity: Critical]
This is a pre-existing issue, but does submit_create() have a dead code
overflow check?
In drivers/gpu/drm/msm/msm_gem_submit.c:submit_create():
sz = struct_size(submit, bos, nr_bos) +
((u64)nr_cmds * sizeof(submit->cmd[0]));
if (sz > SIZE_MAX)
return ERR_PTR(-ENOMEM);
On 64-bit architectures, sz (a uint64_t) cannot exceed SIZE_MAX. If
struct_size() overflows, it returns SIZE_MAX, and adding to it wraps
around to a small value.
This bypasses the size check and causes an undersized allocation, which
could lead to a heap buffer overflow since nr_bos and nr_cmds are
user-controlled via the MSM_GEM_SUBMIT ioctl.
[Severity: Critical]
This is a pre-existing issue, but does msm_ioctl_gem_submit() dereference
an uninitialized pointer?
In drivers/gpu/drm/msm/msm_gem_submit.c:msm_ioctl_gem_submit():
if (to_msm_vm(ctx->vm)->unusable)
return UERR(EPIPE, dev, "context is unusable");
Since ctx->vm uses lazy initialization, it can be NULL if the DRM context
was just created.
Accessing ctx->vm without calling msm_context_vm() first can lead to a
NULL pointer dereference if a userspace application calls the
MSM_GEM_SUBMIT ioctl immediately after context creation.
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260729155609.20190-1-robin.clark@oss.qualcomm.com?part=5
next prev parent reply other threads:[~2026-07-29 18:14 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-29 15:55 [PATCH v7 00/17] drm/msm: A couple lazy-vm fixes Rob Clark
2026-07-29 15:55 ` [PATCH v7 01/17] drm/msm: Fix barriers accessing ctx vm Rob Clark
2026-07-29 16:15 ` sashiko-bot
2026-07-29 15:55 ` [PATCH v7 02/17] drm/msm: Rework queuelock Rob Clark
2026-07-29 16:21 ` sashiko-bot
2026-07-29 15:55 ` [PATCH v7 03/17] drm/msm: Synchronize VM creation on ctxlock Rob Clark
2026-07-29 16:10 ` sashiko-bot
2026-07-29 15:55 ` [PATCH v7 04/17] drm/msm: Synchronize set_sysprof " Rob Clark
2026-07-29 16:12 ` sashiko-bot
2026-07-29 15:55 ` [PATCH v7 05/17] drm/msm: Move nr_cmds initialization Rob Clark
2026-07-29 18:14 ` sashiko-bot [this message]
2026-07-29 15:55 ` [PATCH v7 06/17] drm/msm: Remove redundant SIZE_MAX check Rob Clark
2026-07-29 16:09 ` sashiko-bot
2026-07-29 15:55 ` [PATCH v7 07/17] drm/msm/a6xx: Access VM directly in submit path Rob Clark
2026-07-29 16:12 ` sashiko-bot
2026-07-29 15:55 ` [PATCH v7 08/17] drm/msm: Add helper to check for per-process pgtables VM Rob Clark
2026-07-29 16:11 ` sashiko-bot
2026-07-29 15:55 ` [PATCH v7 09/17] drm/msm/gem: Fix dma_buf import error paths Rob Clark
2026-07-29 15:55 ` [PATCH v7 10/17] drm/msm/gem: Remove useless locking in GEM import Rob Clark
2026-07-29 16:11 ` sashiko-bot
2026-07-29 15:55 ` [PATCH v7 11/17] drm/msm/gem: Extract bookkeeping init helper Rob Clark
2026-07-29 15:55 ` [PATCH v7 12/17] drm/msm/gem: Set resv before exposing obj Rob Clark
2026-07-29 16:25 ` sashiko-bot
2026-07-29 15:55 ` [PATCH v7 13/17] drm/msm/gem: Validate lazy VM in GEM_NEW Rob Clark
2026-07-29 16:26 ` sashiko-bot
2026-07-29 15:55 ` [PATCH v7 14/17] drm/msm: Allow lazy VM creation to fail Rob Clark
2026-07-29 16:21 ` sashiko-bot
2026-07-29 15:55 ` [PATCH v7 15/17] drm/msm: Don't fallback to shared VM for VM_BIND Rob Clark
2026-07-29 16:27 ` sashiko-bot
2026-07-29 15:55 ` [PATCH v7 16/17] drm/msm: Fix per-process-pgtables check Rob Clark
2026-07-29 15:55 ` [PATCH v7 17/17] drm/msm: Fixup invalid overflow check Rob Clark
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=20260729181439.E7A2B1F000E9@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.