From: Mario Limonciello <superm1@kernel.org>
To: Lizhi Hou <lizhi.hou@amd.com>,
ogabbay@kernel.org, quic_jhugo@quicinc.com,
dri-devel@lists.freedesktop.org,
maciej.falkowski@linux.intel.com
Cc: linux-kernel@vger.kernel.org, max.zhen@amd.com, sonal.santan@amd.com
Subject: Re: [PATCH V1] accel/amdxdna: Prevent ubuf size overflow
Date: Tue, 17 Feb 2026 13:54:01 -0600 [thread overview]
Message-ID: <dc7969d1-2f29-450b-98c7-0df251b22e2c@kernel.org> (raw)
In-Reply-To: <20260217192815.1784689-1-lizhi.hou@amd.com>
On 2/17/26 1:28 PM, Lizhi Hou wrote:
> The ubuf size calculation may overflow, resulting in an undersized
> allocation and possible memory corruption.
>
> Use check_add_overflow() helpers to validate the size calculation before
> allocation.
>
> Fixes: bd72d4acda10 ("accel/amdxdna: Support user space allocated buffer")
> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
> ---
> drivers/accel/amdxdna/amdxdna_ubuf.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/accel/amdxdna/amdxdna_ubuf.c b/drivers/accel/amdxdna/amdxdna_ubuf.c
> index 9e3b3b055caa..62a478f6b45f 100644
> --- a/drivers/accel/amdxdna/amdxdna_ubuf.c
> +++ b/drivers/accel/amdxdna/amdxdna_ubuf.c
> @@ -7,6 +7,7 @@
> #include <drm/drm_device.h>
> #include <drm/drm_print.h>
> #include <linux/dma-buf.h>
> +#include <linux/overflow.h>
> #include <linux/pagemap.h>
> #include <linux/vmalloc.h>
>
> @@ -176,7 +177,10 @@ struct dma_buf *amdxdna_get_ubuf(struct drm_device *dev,
> goto free_ent;
> }
>
> - exp_info.size += va_ent[i].len;
> + if (check_add_overflow(exp_info.size, va_ent[i].len, &exp_info.size)) {
> + ret = -EINVAL;
> + goto free_ent;
> + }
> }
>
> ubuf->nr_pages = exp_info.size >> PAGE_SHIFT;
prev parent reply other threads:[~2026-02-17 19:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-17 19:28 Lizhi Hou
2026-02-17 19:54 ` Mario Limonciello [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=dc7969d1-2f29-450b-98c7-0df251b22e2c@kernel.org \
--to=superm1@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizhi.hou@amd.com \
--cc=maciej.falkowski@linux.intel.com \
--cc=max.zhen@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®