From: sashiko-bot@kernel.org
To: "Taimuraz Kaitmazov" <taimuraz@kaitmazov.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 1/2] accel/amdxdna: check the command chain payload before using it
Date: Wed, 26 Aug 2026 15:48:46 +0000 [thread overview]
Message-ID: <20260826154847.454671F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260826153121.133507-2-taimuraz@kaitmazov.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] amdxdna_cmd_set_error() writes the error state to the wrong chain command BO by hardcoding index 0.
--
commit 5dc0906b3cc41016d562034c7287f924681a97d7
Author: Taimuraz Kaitmazov <taimuraz@kaitmazov.com>
accel/amdxdna: check the command chain payload before using it
This commit updates amdxdna_cmd_get_payload() to make the size parameter
mandatory and introduces amdxdna_cmd_get_chain() to ensure the command
count fits within the BO before returning the chain payload.
> diff --git a/drivers/accel/amdxdna/amdxdna_ctx.c b/drivers/accel/amdxdna/amdxdna_ctx.c
> index 888e857ec5582..caf7295a2b5b9 100644
> --- a/drivers/accel/amdxdna/amdxdna_ctx.c
> +++ b/drivers/accel/amdxdna/amdxdna_ctx.c
[ ... ]
> @@ -177,8 +199,13 @@ int amdxdna_cmd_set_error(struct amdxdna_gem_obj *abo,
> cmd->header |= FIELD_PREP(AMDXDNA_CMD_STATE, error_state);
>
> if (amdxdna_cmd_get_op(abo) == ERT_CMD_CHAIN) {
> - cc = amdxdna_cmd_get_payload(abo, NULL);
> - cc->error_index = (cmd_idx < cc->command_count) ? cmd_idx : 0;
> + u32 ccnt;
> +
> + cc = amdxdna_cmd_get_chain(abo, &ccnt);
> + if (!cc || !ccnt)
> + return -EINVAL;
> +
> + cc->error_index = (cmd_idx < ccnt) ? cmd_idx : 0;
> abo = amdxdna_gem_get_obj(client, cc->data[0], AMDXDNA_BO_SHARE);
[Severity: High]
This isn't a bug introduced by this patch, but does this logic write the
error state to the wrong command BO?
In amdxdna_cmd_set_error(), the code correctly assigns cc->error_index based
on cmd_idx, but then it hardcodes cc->data[0] when looking up the BO. If a
chained command fails at an index greater than 0, won't this clobber the
first command in the chain with error data and completely ignore the actual
failing command?
> if (!abo)
> return -EINVAL;
> cmd = amdxdna_gem_vmap(abo);
> if (!cmd) {
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260826153121.133507-1-taimuraz@kaitmazov.com?part=1
next prev parent reply other threads:[~2026-08-26 15:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 14:30 [PATCH 0/2] accel/amdxdna: make the shared command header safe to read Taimuraz Kaitmazov
2026-08-26 14:30 ` [PATCH 1/2] accel/amdxdna: check the command chain payload before using it Taimuraz Kaitmazov
2026-08-26 14:43 ` sashiko-bot
2026-08-26 14:30 ` [PATCH 2/2] accel/amdxdna: use READ_ONCE/WRITE_ONCE on the command header Taimuraz Kaitmazov
2026-08-26 14:50 ` sashiko-bot
2026-08-26 15:31 ` [PATCH v2 0/2] accel/amdxdna: make the shared command header safe to read Taimuraz Kaitmazov
2026-08-26 15:31 ` [PATCH v2 1/2] accel/amdxdna: check the command chain payload before using it Taimuraz Kaitmazov
2026-08-26 15:48 ` sashiko-bot [this message]
2026-08-26 21:32 ` Lizhi Hou
2026-08-26 22:13 ` [PATCH v3] accel/amdxdna: use READ_ONCE/WRITE_ONCE on the command header Taimuraz Kaitmazov
2026-08-26 22:27 ` sashiko-bot
2026-08-26 15:31 ` [PATCH v2 2/2] " Taimuraz Kaitmazov
2026-08-26 23:16 ` Lizhi Hou
2026-08-27 0:20 ` Taimuraz Kaitmazov
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=20260826154847.454671F00A3D@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=taimuraz@kaitmazov.com \
/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