mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Max Zhen <max.zhen@amd.com>
To: Eva Crystal <0xiviel@gmail.com>
Cc: <ogabbay@kernel.org>, <quic_jhugo@quicinc.com>,
	<dri-devel@lists.freedesktop.org>, <mario.limonciello@amd.com>,
	<karol.wachowski@linux.intel.com>, <lizhi.hou@amd.com>,
	<linux-kernel@vger.kernel.org>, <sonal.santan@amd.com>,
	Min Ma <mamin506@gmail.com>
Subject: Re: [PATCH V1] accel/amdxdna: eliminate GFP_KERNEL allocation from mailbox send path
Date: Thu, 1 Oct 2026 09:23:42 -0700	[thread overview]
Message-ID: <0274009c-3d7e-414d-8298-2e4184fa087d@amd.com> (raw)
In-Reply-To: <CA+pz=kLERMEUwN5OQf7=aDDqkH93CHXHUuD+aA0tuYN2xCk3tQ@mail.gmail.com>



On 9/30/2026 Wed 14:37, Eva Crystal wrote:
> Hi Max,
> 
>> +#define MSG_BUF_SZ(chann)                                    \
>> +     (mailbox_get_ringbuf_size(chann, CHAN_RES_X2I) +        \
>> +      sizeof(struct mailbox_msg))
> 
>> +     mb_chann->msg_buf = kcalloc(n_msg, MSG_BUF_SZ(mb_chann), GFP_KERNEL);
> 
> rb_size comes from the firmware-provided channel info, and with this
> change it now sizes a host allocation as well as the ring itself.
> Nothing bounds it before the kcalloc(), so a bad or compromised
> firmware value turns directly into an arbitrarily large kernel
> allocation. Could rb_size be checked against the ring window it
> describes before the pool is allocated?

The firmware is authenticated and signed by AMD. By design, driver 
should trust this data returned from firmware. There is no need to 
perform this check.
> 
>> +     if (!mb_chann->msg_buf)
>> +             return -ENOMEM;
> 
> This adds another failure path out of xdna_mailbox_start_channel()
> before request_irq(). On failure the caller still holds the freed
> channel pointer, which "accel/amdxdna: clear the mailbox channel
> pointer when starting it fails" (Reviewed-by: Lizhi Hou) fixes, so the
> two patches should be fine in either order.

The patch (accel/amdxdna: clear the mailbox channel
 > pointer when starting it fails) has already been applied to 
drm-misc-next (see 
https://lore.kernel.org/dri-devel/81bcf2ab-cfcd-3e2a-ca91-671e72d93bb8@amd.com/). 
My patch is based on the applied patch, so there should be no order issue.

Thanks,
Max

> 
> Thanks,
> 
> Eva Crystal (0xiviel)
> XSource Security
> https://xsourcesec.com


      reply	other threads:[~2026-10-01 16:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30 16:47 Max Zhen
2026-09-30 21:37 ` Eva Crystal
2026-10-01 16:23   ` Max Zhen [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=0274009c-3d7e-414d-8298-2e4184fa087d@amd.com \
    --to=max.zhen@amd.com \
    --cc=0xiviel@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=karol.wachowski@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizhi.hou@amd.com \
    --cc=mamin506@gmail.com \
    --cc=mario.limonciello@amd.com \
    --cc=ogabbay@kernel.org \
    --cc=quic_jhugo@quicinc.com \
    --cc=sonal.santan@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®