From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: Satyanarayana K V P <satyanarayana.k.v.p@intel.com>,
<intel-xe@lists.freedesktop.org>
Cc: Matthew Brost <matthew.brost@intel.com>,
Maarten Lankhorst <dev@lankhorst.se>
Subject: Re: [PATCH v8 05/10] drm/xe/ggtt: Avoid integer overflow when validating VF GGTT range
Date: Tue, 15 Sep 2026 14:03:28 +0200 [thread overview]
Message-ID: <6d00a237-1785-4593-a4f9-2efee92482a1@intel.com> (raw)
In-Reply-To: <20260915071159.51402-17-satyanarayana.k.v.p@intel.com>
On 9/15/2026 9:12 AM, Satyanarayana K V P wrote:
> Use check_add_overflow() for the VF range check, and rearrange the
> subsequent clamping into the subtraction form so the expression
> does not overflow.
>
Reported-by?
> Fixes: e904c56ba6e0 ("drm/xe: Rewrite GGTT VF initialization")
> Signed-off-by: Satyanarayana K V P <satyanarayana.k.v.p@intel.com>
> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Matthew Brost <matthew.brost@intel.com>
> Cc: Maarten Lankhorst <dev@lankhorst.se>
> ---
> drivers/gpu/drm/xe/xe_ggtt.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
> index 7cac01cef1ee..d65929720704 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.c
> +++ b/drivers/gpu/drm/xe/xe_ggtt.c
> @@ -8,6 +8,7 @@
> #include <kunit/visibility.h>
> #include <linux/fault-inject.h>
> #include <linux/io-64-nonatomic-lo-hi.h>
> +#include <linux/overflow.h>
> #include <linux/sizes.h>
>
> #include <drm/drm_drv.h>
> @@ -394,7 +395,7 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt)
> struct xe_device *xe = tile_to_xe(ggtt->tile);
> struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
> unsigned int gsm_size;
> - u64 ggtt_start, wopcm = xe_wopcm_size(xe), ggtt_size;
> + u64 ggtt_start, wopcm = xe_wopcm_size(xe), ggtt_size, ggtt_end;
as you're touching this line, can we put wopcm in a separate one?
u64 ggtt_start, ggtt_size, ggtt_end;
u64 wopcm = xe_wopcm_size(xe);
> int err;
>
> if (!IS_SRIOV_VF(xe)) {
> @@ -413,9 +414,11 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt)
> ggtt_size = xe_tile_sriov_vf_ggtt(ggtt->tile);
>
> if (ggtt_start < wopcm ||
> - ggtt_start + ggtt_size > GUC_GGTT_TOP) {
> - xe_tile_err(ggtt->tile, "Invalid GGTT configuration: %#llx-%#llx\n",
> - ggtt_start, ggtt_start + ggtt_size - 1);
> + check_add_overflow(ggtt_start, ggtt_size, &ggtt_end) ||
> + ggtt_end > GUC_GGTT_TOP) {
> + xe_tile_err(ggtt->tile,
> + "Invalid GGTT configuration: base %#llx, size %#llx\n",
> + ggtt_start, ggtt_size);
> return -ERANGE;
> }
> }
> @@ -424,7 +427,7 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt)
> if (xe_vram_needs_64k(xe))
> ggtt->flags |= XE_GGTT_FLAGS_64K;
>
> - if (ggtt_size + ggtt_start > GUC_GGTT_TOP)
> + if (ggtt_size > GUC_GGTT_TOP - ggtt_start)
shouldn't this be moved to !IS_VF case above ?
and maybe it also requires check_add_overflow ?
> ggtt_size = GUC_GGTT_TOP - ggtt_start;
>
> if (GRAPHICS_VERx100(xe) >= 1270)
next prev parent reply other threads:[~2026-09-15 12:03 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 7:11 [PATCH v8 00/10] KUnit test for VF provisioning error handling Satyanarayana K V P
2026-09-15 7:11 ` [PATCH v8 01/10] drm/xe/guc: Allow to replace xe_guc_mmio_send_recv() with KUNIT stub Satyanarayana K V P
2026-09-15 7:11 ` [PATCH v8 02/10] drm/xe/vf: Split submission config query helpers Satyanarayana K V P
2026-09-15 7:12 ` [PATCH v8 03/10] drm/xe/vf: Add bounds checking for queried context and doorbell counts Satyanarayana K V P
2026-09-15 11:12 ` Michal Wajdeczko
2026-09-15 7:12 ` [PATCH v8 04/10] drm/xe: Introduce helpers for VRAM alignment Satyanarayana K V P
2026-09-15 7:12 ` [PATCH v8 05/10] drm/xe/ggtt: Avoid integer overflow when validating VF GGTT range Satyanarayana K V P
2026-09-15 12:03 ` Michal Wajdeczko [this message]
2026-09-15 7:12 ` [PATCH v8 06/10] drm/xe/vf: Add bounds checking for queried GGTT base and size Satyanarayana K V P
2026-09-15 7:26 ` sashiko-bot
2026-09-15 7:12 ` [PATCH v8 07/10] drm/xe/pf: Align VF GGTT allocations to PAGE_SIZE Satyanarayana K V P
2026-09-15 7:27 ` sashiko-bot
2026-09-15 7:12 ` [PATCH v8 08/10] drm/xe/vf: Add alignment check for queried VRAM size Satyanarayana K V P
2026-09-15 7:12 ` [PATCH v8 09/10] drm/xe/ggtt: Add KUNIT stub for xe_ggtt_shift_nodes() Satyanarayana K V P
2026-09-15 7:12 ` [PATCH v8 10/10] drm/xe/tests: Add KUnit tests for VF provisioning error handling Satyanarayana K V P
2026-09-15 14:33 ` Michal Wajdeczko
2026-09-15 7:19 ` ✗ CI.checkpatch: warning for KUnit test for VF provisioning error handling (rev8) Patchwork
2026-09-15 7:21 ` ✓ CI.KUnit: success " Patchwork
2026-09-15 8:04 ` ✓ Xe.CI.BAT: " Patchwork
2026-09-15 9:06 ` ✗ Xe.CI.FULL: 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=6d00a237-1785-4593-a4f9-2efee92482a1@intel.com \
--to=michal.wajdeczko@intel.com \
--cc=dev@lankhorst.se \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=satyanarayana.k.v.p@intel.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.