From: Sebastian Brzezinka <sebastian.brzezinka@intel.com>
To: Krzysztof Karas <krzysztof.karas@intel.com>,
Sebastian Brzezinka <sebastian.brzezinka@intel.com>
Cc: <intel-gfx@lists.freedesktop.org>, <andi.shyti@linux.intel.com>,
<krzysztof.niemiec@intel.com>, <chris.p.wilson@intel.com>
Subject: Re: [PATCH] drm/i915/selftests: Fix unlocked mm.stolen in reset selftest
Date: Wed, 26 Aug 2026 11:11:53 +0200 [thread overview]
Message-ID: <DKYRCL2JVY3Y.LW8NV6GLHX2O@intel.com> (raw)
In-Reply-To: <gtwlq6zu74cvjm2k3xbs76s64v7ex3srq2umj6ix3mfote4h2r@7rtohsh6hgs5>
Hi,
On Wed Aug 26, 2026 at 10:49 AM CEST, Krzysztof Karas wrote:
> Hi Sebastian,
>
> On 2026-08-21 at 15:40:44 +0200, Sebastian Brzezinka wrote:
>> __igt_reset_stolen() use via __drm_mm_interval_first(), but
>> does so without holding i915->mm.stolen_lock. Every writer of this
>> (i915_gem_stolen.c: drm_mm_insert_node_in_range(), drm_mm_reserve_node(),
>> drm_mm_remove_node()) takes stolen_lock, so the selftest's unlocked
>> reader can race.
>>
>> This was observed as a NULL pointer dereference in
>> __drm_mm_interval_first() during igt_reset_device_stolen():
>>
>> BUG: kernel NULL pointer dereference, address: 0000000000000010
>> ...
>> RIP: 0010:__drm_mm_interval_first+0x2c/0x90
>> ...
>> Call Trace:
>> __igt_reset_stolen+0x565/0x6a0 [i915]
>> igt_reset_device_stolen+0x1a/0x30 [i915]
>> __i915_subtests+0xb8/0x250 [i915]
>> ...
>>
>> Fixes: 3da3c5c1c982 ("drm/i915: Exclude low pages (128KiB) of stolen from use")
>> Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/work_items/16841
>> Signed-off-by: Sebastian Brzezinka <sebastian.brzezinka@intel.com>
>> ---
>> drivers/gpu/drm/i915/gt/selftest_reset.c | 20 +++++++++++++-------
>> 1 file changed, 13 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/gt/selftest_reset.c b/drivers/gpu/drm/i915/gt/selftest_reset.c
>> index 2cfc23c58e90..eb6b2261329d 100644
>> --- a/drivers/gpu/drm/i915/gt/selftest_reset.c
>> +++ b/drivers/gpu/drm/i915/gt/selftest_reset.c
>> @@ -30,6 +30,7 @@ __igt_reset_stolen(struct intel_gt *gt,
>> void *tmp;
>> u32 *crc;
>> int err;
>> + bool unused;
> You should ensure the mutex is initialized:
>
> if (!drm_mm_initialized(>->i915->mm.stolen))
> return 0;
I don't think it's necessary, and even if it were, it would be outside
the scope of this patch.
>
>>
>> if (!drm_mm_node_allocated(&ggtt->error_capture))
>> return 0;
>> @@ -95,9 +96,12 @@ __igt_reset_stolen(struct intel_gt *gt,
>> ggtt->error_capture.start,
>> PAGE_SIZE);
>>
>> - if (!__drm_mm_interval_first(>->i915->mm.stolen,
>> - page << PAGE_SHIFT,
>> - ((page + 1) << PAGE_SHIFT) - 1))
>> + mutex_lock(>->i915->mm.stolen_lock);
>> + unused = !__drm_mm_interval_first(>->i915->mm.stolen,
>> + page << PAGE_SHIFT,
>> + ((page + 1) << PAGE_SHIFT) - 1);
>> + mutex_unlock(>->i915->mm.stolen_lock);
>> + if (unused)
>> memset_io(s, STACK_MAGIC, PAGE_SIZE);
>>
>> in = (void __force *)s;
>> @@ -143,10 +147,12 @@ __igt_reset_stolen(struct intel_gt *gt,
>> in = tmp;
>> x = crc32_le(0, in, PAGE_SIZE);
>>
>> - if (x != crc[page] &&
>> - !__drm_mm_interval_first(>->i915->mm.stolen,
>> - page << PAGE_SHIFT,
>> - ((page + 1) << PAGE_SHIFT) - 1)) {
>> + mutex_lock(>->i915->mm.stolen_lock);
>> + unused = !__drm_mm_interval_first(>->i915->mm.stolen,
>> + page << PAGE_SHIFT,
>> + ((page + 1) << PAGE_SHIFT) - 1);
>> + mutex_unlock(>->i915->mm.stolen_lock);
>> + if (x != crc[page] && unused) {
>> pr_debug("unused stolen page %pa modified by GPU reset\n",
>> &page);
>> if (count++ == 0)
>> --
>> 2.55.0
>>
--
Best regards,
Sebastian
next prev parent reply other threads:[~2026-08-26 9:10 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 13:40 [PATCH] drm/i915/selftests: Fix unlocked mm.stolen in reset selftest Sebastian Brzezinka
2026-08-21 13:48 ` sashiko-bot
2026-08-21 14:36 ` ✓ i915.CI.BAT: success for " Patchwork
2026-08-21 18:19 ` ✗ i915.CI.Full: failure " Patchwork
2026-08-25 16:29 ` ✓ i915.CI.BAT: success for drm/i915/selftests: Fix unlocked mm.stolen in reset selftest (rev2) Patchwork
2026-08-25 19:36 ` ✗ i915.CI.Full: failure " Patchwork
2026-08-26 8:49 ` [PATCH] drm/i915/selftests: Fix unlocked mm.stolen in reset selftest Krzysztof Karas
2026-08-26 9:11 ` Sebastian Brzezinka [this message]
2026-08-26 17:31 ` Andi Shyti
2026-08-27 8:39 ` Sebastian Brzezinka
2026-08-27 23:17 ` Andi Shyti
2026-09-16 9:17 ` Sebastian Brzezinka
2026-09-17 12:09 ` ✗ i915.CI.BAT: failure for drm/i915/selftests: Fix unlocked mm.stolen in reset selftest (rev3) 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=DKYRCL2JVY3Y.LW8NV6GLHX2O@intel.com \
--to=sebastian.brzezinka@intel.com \
--cc=andi.shyti@linux.intel.com \
--cc=chris.p.wilson@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=krzysztof.karas@intel.com \
--cc=krzysztof.niemiec@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.