From: Lizhi Hou <lizhi.hou@amd.com>
To: Taimuraz Kaitmazov <taimuraz@kaitmazov.com>, <mamin506@gmail.com>,
<ogabbay@kernel.org>
Cc: <christian.koenig@amd.com>, <sumit.semwal@linaro.org>,
<alexdeucher@gmail.com>, <max.zhen@amd.com>,
<sonal.santan@amd.com>, <dri-devel@lists.freedesktop.org>,
<linux-kernel@vger.kernel.org>, <linux-media@vger.kernel.org>,
<linaro-mm-sig@lists.linaro.org>
Subject: Re: [PATCH v4 2/5] accel/amdxdna: check the sync range for overflow on a device BO
Date: Wed, 19 Aug 2026 13:49:23 -0700 [thread overview]
Message-ID: <65774c6e-ec7e-8e5b-bbd4-a25c6ab1299e@amd.com> (raw)
In-Reply-To: <20260817230707.356828-3-taimuraz@kaitmazov.com>
On 8/17/26 16:07, Taimuraz Kaitmazov wrote:
> amdxdna_drm_sync_bo_ioctl() forms the range for a device BO by adding the
> caller's offset and size to the BO address without checking either, while
> amdxdna_flush_bo() one call down guards the same arithmetic with
> check_add_overflow().
>
> A size that wraps flush_end leaves it below the heap it is clamped
> against, so every heap fails the start >= end test, and a sync that asked
> for more than the address space holds reports success having flushed
> nothing. Reject it instead.
>
> Signed-off-by: Taimuraz Kaitmazov <taimuraz@kaitmazov.com>
> ---
> drivers/accel/amdxdna/amdxdna_gem.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/accel/amdxdna/amdxdna_gem.c b/drivers/accel/amdxdna/amdxdna_gem.c
> index f88b5349cd4b..77a9493cd7ba 100644
> --- a/drivers/accel/amdxdna/amdxdna_gem.c
> +++ b/drivers/accel/amdxdna/amdxdna_gem.c
> @@ -1274,8 +1274,13 @@ int amdxdna_drm_sync_bo_ioctl(struct drm_device *dev,
> struct amdxdna_gem_obj *heap;
> unsigned long heap_id;
> u64 bo_start = amdxdna_gem_dev_addr(abo);
> - u64 flush_start = bo_start + args->offset;
> - u64 flush_end = flush_start + args->size;
> + u64 flush_start, flush_end;
> +
> + if (check_add_overflow(bo_start, args->offset, &flush_start) ||
> + check_add_overflow(flush_start, args->size, &flush_end)) {
> + ret = -EINVAL;
> + goto put_obj;
> + }
Reviewed-by: Lizhi Hou <lizhi.hou@amd.com>
>
> xa_for_each_range(&client->dev_heap_xa, heap_id, heap,
> abo->heap_start_id, abo->heap_end_id) {
next prev parent reply other threads:[~2026-08-19 20:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-17 23:07 [PATCH v4 0/5] accel/amdxdna: SYNC_BO correctness fixes Taimuraz Kaitmazov
2026-08-17 23:07 ` [PATCH v4 1/5] accel/amdxdna: refuse an I/O memory mapping of an imported BO Taimuraz Kaitmazov
2026-08-19 20:39 ` Lizhi Hou
2026-08-17 23:07 ` [PATCH v4 2/5] accel/amdxdna: check the sync range for overflow on a device BO Taimuraz Kaitmazov
2026-08-19 20:49 ` Lizhi Hou [this message]
2026-08-17 23:07 ` [PATCH v4 3/5] accel/amdxdna: do not warn when a sync request is rejected Taimuraz Kaitmazov
2026-08-19 20:57 ` Lizhi Hou
2026-08-17 23:07 ` [PATCH v4 4/5] accel/amdxdna: refuse to flush an imported BO Taimuraz Kaitmazov
2026-08-19 21:00 ` Lizhi Hou
2026-08-17 23:07 ` [PATCH v4 5/5] accel/amdxdna: do not fail a sync for a BO with no debug context Taimuraz Kaitmazov
2026-08-19 21:05 ` Lizhi Hou
2026-08-18 21:40 ` [PATCH v4 0/5] accel/amdxdna: SYNC_BO correctness fixes Taimuraz Kaitmazov
2026-08-19 16:30 ` 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=65774c6e-ec7e-8e5b-bbd4-a25c6ab1299e@amd.com \
--to=lizhi.hou@amd.com \
--cc=alexdeucher@gmail.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mamin506@gmail.com \
--cc=max.zhen@amd.com \
--cc=ogabbay@kernel.org \
--cc=sonal.santan@amd.com \
--cc=sumit.semwal@linaro.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.