From: sashiko-bot@kernel.org
To: "Jan Maslak" <jan.maslak@intel.com>, intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v5 2/4] drm/xe/xe_migrate: Align MEM_COPY pitch with destination address
Date: Wed, 14 Oct 2026 14:41:47 +0000 [thread overview]
Message-ID: <sashiko-outbox-171439@kernel.org> (raw)
In-Reply-To: <20261014142706.598490-3-jan.maslak@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] drm/xe: negative integer overflow in xe_migrate_access_memory length chunking
--
commit 742737639ebd031db7d22e7a2865500651dcc226
Author: Christoph Manszewski <c.manszewski@gmail.com>
drm/xe/xe_migrate: Align MEM_COPY pitch with destination address
This commit modifies xe_migrate_copy_pitch() to incorporate the destination
address into pitch selection. It ensures the chosen pitch is aligned to both
the copy length and the destination address to prevent memory corruption in
MATRIX_COPY mode.
> diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migrate.c
> index 3711d4542ad3d..4b995c93fcea9 100644
> --- a/drivers/gpu/drm/xe/xe_migrate.c
> +++ b/drivers/gpu/drm/xe/xe_migrate.c
[ ... ]
> @@ -2535,7 +2540,9 @@ int xe_migrate_access_memory(struct xe_migrate *m, struct xe_bo *bo,
> else
> current_bytes = min_t(int, bytes_left, cursor.size);
>
> - pitch = xe_migrate_copy_pitch(xe, current_bytes);
> + pitch = xe_migrate_copy_pitch(xe, current_bytes,
> + write ? vram_addr :
> + (unsigned long)buf & ~PAGE_MASK);
> if (xe->info.has_mem_copy_instr)
> current_bytes = min_t(int, current_bytes, U16_MAX * pitch);
[Severity: High]
Does this code risk a negative integer overflow?
The min_t macro casts both arguments to a signed int. On systems with a
64KB PAGE_SIZE (e.g. ARM64 or PPC64), if pitch is PAGE_SIZE, U16_MAX * pitch
evaluates to 4294901760 (0xFFFE0000). When cast to int, this becomes the
negative number -131072.
This would cause current_bytes to become negative. When this negative chunk
size is passed down the call chain:
xe_migrate_access_memory()
...
__fence = xe_migrate_vram(m, current_bytes, ...)
Inside xe_migrate_vram(), this negative length is implicitly cast to an
unsigned long, becoming a massive value that either triggers a kernel panic
via xe_assert(xe, npages * PAGE_SIZE <= MAX_PREEMPTDISABLE_TRANSFER), or
causes the batch buffer allocation xe_bb_new() to fail with -ENOMEM.
Note that follow-up Patch 3 in the series simply moves this broken min_t
logic into a new block, failing to resolve the signed overflow.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261014142706.598490-1-jan.maslak@intel.com?part=2
next prev parent reply other threads:[~2026-10-14 14:41 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 14:27 [PATCH v5 0/4] drm/xe/xe_migrate: Fix memory corruption with unaligned dst in MEM_COPY Jan Maslak
2026-10-14 14:27 ` [PATCH v5 1/4] drm/xe/xe_migrate: Fix page tracking in access_memory Jan Maslak
2026-10-14 14:47 ` sashiko-bot
2026-10-14 14:27 ` [PATCH v5 2/4] drm/xe/xe_migrate: Align MEM_COPY pitch with destination address Jan Maslak
2026-10-14 14:41 ` sashiko-bot [this message]
2026-10-14 14:27 ` [PATCH v5 3/4] drm/xe/xe_migrate: Optimize unaligned access_memory copies Jan Maslak
2026-10-14 14:36 ` sashiko-bot
2026-10-14 14:27 ` [PATCH v5 4/4] drm/xe/tests: Add xe_migrate_access_memory subtest Jan Maslak
2026-10-14 14:45 ` sashiko-bot
2026-10-14 16:11 ` ✗ CI.checkpatch: warning for drm/xe/xe_migrate: Fix memory corruption with unaligned dst in MEM_COPY (rev5) Patchwork
2026-10-14 16:13 ` ✓ CI.KUnit: success " Patchwork
2026-10-14 23:56 ` ✗ Xe.CI.BAT: failure " Patchwork
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=sashiko-outbox-171439@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=jan.maslak@intel.com \
--cc=sashiko-reviews@lists.linux.dev \
/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