dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Bilal Hashim" <AeeSec@126.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] accel/amdxdna: Fix NULL pointer dereference and u32 underflow in aie2_message
Date: Sat, 28 Nov 2026 14:13:34 +0000	[thread overview]
Message-ID: <sashiko-outbox-238762@kernel.org> (raw)
In-Reply-To: <20261128140537.1325-1-AeeSec@126.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] accel/amdxdna: missing Fixes trailers for 71829d7f2f70 and
  3a0ff7b98af4
--

commit 9793e7703171a10921840797a04510b39e48e1d3
Author: Bilal Hashim <AeeSec@126.com>

> accel/amdxdna: Fix NULL pointer dereference and u32 underflow in aie2_message
>
> amdxdna_cmd_get_payload() returns NULL and sets *size = 0 when the
> user-supplied command header in the shared command BO has an invalid
> AMDXDNA_CMD_COUNT (for example, count <= num_masks or exceeding the BO
> size), or if amdxdna_gem_vmap() fails.
>
> However, the eight command payload helpers in aie2_message.c do not
> check the return value of amdxdna_cmd_get_payload() for NULL before
> dereferencing it or passing it to memcpy():
>
> 1. In aie2_init_exec_dpu_req():
>    - `if (cmd_len - sizeof(*sn) > sizeof(dpu_req->payload))` performs an
>      unsigned 32-bit subtraction (`u32 cmd_len - sizeof(*sn)`). If
>      `cmd_len < sizeof(*sn)` (for instance, `cmd_len == 4`), on 64-bit
>      architectures `sizeof(*sn)` is `size_t`, so `(size_t)cmd_len -
>      sizeof(*sn)` wraps around and is rejected, unless `cmd_len` is 0
>      (when `sn == NULL`) or if `sn` is dereferenced when `cmd_len` is
>      valid for the check on 32-bit platforms. More importantly, when
>      `cmd_len < sizeof(*sn)` or `sn == NULL`, `cmd_len < sizeof(*sn)`
>      is not explicitly checked first.
> 2. In aie2_init_exec_cu_req(), aie2_cmdlist_fill_cf(), and
>    aie2_cmdlist_fill_npu_cf():
>    - When `amdxdna_cmd_get_payload()` returns `NULL` with `cmd_len == 0`,
>      the size check (`cmd_len > ...` or `*size < sizeof(...) + cmd_len`)
>      passes, and if `amdxdna_cmd_get_cu_idx()` succeeds (because the CU
>      mask word in the command BO is non-zero), `cmd` (`NULL`) is passed
>      to `memcpy()`, or in future/non-zero paths dereferenced directly.
> 3. Similarly, in aie2_cmdlist_fill_dpu(), aie2_cmdlist_fill_npu_dpu(),
>    aie2_cmdlist_fill_npu_preempt(), and aie2_cmdlist_fill_npu_elf(),
>    checking `!sn` / `!pd` right after `amdxdna_cmd_get_payload()` makes
>    the error handling explicit and consistent with
>    aie2_cmdlist_multi_execbuf().
>
> Add explicit NULL checks after every amdxdna_cmd_get_payload() call and
> check `cmd_len < sizeof(*sn)` in aie2_init_exec_dpu_req() before
> subtracting `sizeof(*sn)`.
>
> Signed-off-by: Bilal Hashim <AeeSec@126.com>

[Severity: Low]
71829d7f2f70 ("accel/amdxdna: Use MSG_OP_CHAIN_EXEC_NPU when supported")
dropped the NULL payload checks when refactoring the CF, DPU, and NPU
helpers, and 3a0ff7b98af4 ("accel/amdxdna: Support preemption requests")
added aie2_cmdlist_fill_npu_preempt() and aie2_cmdlist_fill_npu_elf()
without them.  Should this include:

  Fixes: 71829d7f2f70 ("accel/amdxdna: Use MSG_OP_CHAIN_EXEC_NPU when supported")
  Fixes: 3a0ff7b98af4 ("accel/amdxdna: Support preemption requests")

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261128140537.1325-1-AeeSec@126.com?part=1

  parent reply	other threads:[~2026-11-28 14:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-28 14:05 [PATCH] accel/amdxdna: Fix NULL pointer dereference and u32 underflow in aie2_message Bilal Hashim
2026-11-28 14:05 ` [PATCH] accel/amdxdna: Validate command BO size and payload in amdxdna_ctx Bilal Hashim
2026-11-28 14:24   ` sashiko-bot
2026-11-30 22:20   ` Lizhi Hou
2026-11-28 14:13 ` sashiko-bot [this message]
2026-11-30 21:36 ` [PATCH] accel/amdxdna: Fix NULL pointer dereference and u32 underflow in aie2_message Lizhi Hou

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=sashiko-outbox-238762@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=AeeSec@126.com \
    --cc=dri-devel@lists.freedesktop.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox