mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lizhi Hou <lizhi.hou@amd.com>
To: David Zhang <yidong.zhang@amd.com>, <quic_jhugo@quicinc.com>,
	<karol.wachowski@linux.intel.com>, <max.zhen@amd.com>,
	<ogabbay@kernel.org>, <dri-devel@lists.freedesktop.org>,
	<linux-kernel@vger.kernel.org>
Cc: <sonal.santan@amd.com>, <mario.limonciello@amd.com>
Subject: Re: [PATCH V2 3/5] accel/amdxdna: Check mailbox message overflow
Date: Tue, 1 Dec 2026 09:40:17 -0800	[thread overview]
Message-ID: <d9657bcb-2da0-14ac-63ee-0872f8c87c78@amd.com> (raw)
In-Reply-To: <20261130225904.1103363-4-yidong.zhang@amd.com>


On 11/30/26 14:59, David Zhang wrote:
> The message size is the firmware-supplied total_size plus the header
> size, computed in a u32. A total_size near U32_MAX wraps the sum to a
> small value that passes the ring buffer bounds checks, and the consumer
> is then called with the unchecked total_size.
>
> Reject the message when the addition overflows.

This is unnecessary. AMD signed off firmware should never return the 
invalid total_size.

Lizhi

>
> Signed-off-by: David Zhang <yidong.zhang@amd.com>
> ---
>   drivers/accel/amdxdna/amdxdna_mailbox.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/accel/amdxdna/amdxdna_mailbox.c b/drivers/accel/amdxdna/amdxdna_mailbox.c
> index c4701b2703d7..967f6f1eb764 100644
> --- a/drivers/accel/amdxdna/amdxdna_mailbox.c
> +++ b/drivers/accel/amdxdna/amdxdna_mailbox.c
> @@ -381,9 +381,9 @@ static int mailbox_get_msg(struct mailbox_channel *mb_chann)
>   		MB_WARN_ONCE(mb_chann, "Invalid total size 0x%x", header.total_size);
>   		return -EINVAL;
>   	}
> -	msg_size = sizeof(header) + header.total_size;
>   
> -	if (msg_size > ringbuf_size - head || msg_size > tail - head) {
> +	if (check_add_overflow(sizeof(header), header.total_size, &msg_size) ||
> +	    msg_size > ringbuf_size - head || msg_size > tail - head) {
>   		MB_WARN_ONCE(mb_chann, "Invalid message size %d, tail %d, head %d",
>   			     msg_size, tail, head);
>   		return -EINVAL;

  reply	other threads:[~2026-12-01 17:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 22:58 [PATCH V2 0/5] accel/amdxdna: Add AIE4 async events and TDR David Zhang
2026-11-30 22:59 ` [PATCH V2 1/5] accel/amdxdna: Add AIE4 async event buffers David Zhang
2026-12-01 16:43   ` Lizhi Hou
2026-11-30 22:59 ` [PATCH V2 2/5] accel/amdxdna: Add AIE4 context recovery David Zhang
2026-12-01 16:51   ` Lizhi Hou
2026-11-30 22:59 ` [PATCH V2 3/5] accel/amdxdna: Check mailbox message overflow David Zhang
2026-12-01 17:40   ` Lizhi Hou [this message]
2026-11-30 22:59 ` [PATCH V2 4/5] accel/amdxdna: Handle AIE4 firmware notifications David Zhang
2026-12-01 17:20   ` Lizhi Hou
2026-11-30 22:59 ` [PATCH V2 5/5] accel/amdxdna: Recover hung AIE4 contexts David Zhang
2026-12-01 17:21   ` 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=d9657bcb-2da0-14ac-63ee-0872f8c87c78@amd.com \
    --to=lizhi.hou@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=karol.wachowski@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=max.zhen@amd.com \
    --cc=ogabbay@kernel.org \
    --cc=quic_jhugo@quicinc.com \
    --cc=sonal.santan@amd.com \
    --cc=yidong.zhang@amd.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

all inboxes | Powered by JetHome®