From: Andi Shyti <andi.shyti@linux.intel.com>
To: Krzysztof Karas <krzysztof.karas@intel.com>
Cc: intel-gfx@lists.freedesktop.org,
Andi Shyti <andi.shyti@linux.intel.com>,
Sebastian Brzezinka <sebastian.brzezinka@intel.com>,
Krzysztof Niemiec <krzysztof.niemiec@intel.com>,
Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Subject: Re: [PATCH v7 1/2] drm/i915/selftests: Prevent userspace mapping invalidation
Date: Tue, 28 Apr 2026 16:57:29 +0200 [thread overview]
Message-ID: <afDK2Q_jxoiw0zIM@ashyti-mobl2.lan> (raw)
In-Reply-To: <20260421061716.3341529-2-krzysztof.karas@intel.com>
Hi Krzysztof,
On Tue, Apr 21, 2026 at 06:17:15AM +0000, Krzysztof Karas wrote:
> Migration testing in i915 assumes current task's address space
> to allocate new userspace mapping and uses it without
> registering real user for that address space in mm_struct.
> On single NUMA node setups PCI probe executes in the same
> context as userspace process calling the test (i915_selftest
> from IGT), but when multiple nodes are available, the PCI code
> puts probe into a kernel workqueue. This switches execution to
> a kworker, which does not have its own address space in
> userspace and must borrow such memory from another process, so
> "current->active_mm" is unknown at the start of the test.
>
> It was observed that mm->mm_users would occasionally be 0
> or drop to 0 during the test due to short delay between
> scheduling and executing work in forked process, which reaped
> userspace mappings, further leading to failures upon reading
> from userland memory.
>
> Prevent this by adding a PID parameter to a trusted task, so its
> mm struct may be used if needed.
>
> Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/14204
> Fixes: 34b1c1c71d37 ("i915/selftest/igt_mmap: let mmap tests run in kthread")
> Signed-off-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
...
> + /**
> + * If we are running in a kthread on a multi NUMA system and the user passed
> + * a valid PID of a userspace task, then we may borrow its address space
> + * to prepare a safe environment for the mmap selftests.
> + */
Sebastian is right here, the "**" is more for the documentation,
it can be removed before pushing.
Andi
> + if (!current->mm && u_pid_nr) {
> + mm = get_mm(u_pid_nr);
> + if (mm) {
...
next prev parent reply other threads:[~2026-04-28 14:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-21 6:17 [PATCH v7 0/2] drm/i915/selftests: Use safe userspace memory for mappings Krzysztof Karas
2026-04-21 6:17 ` [PATCH v7 1/2] drm/i915/selftests: Prevent userspace mapping invalidation Krzysztof Karas
2026-04-24 10:06 ` Sebastian Brzezinka
2026-04-24 11:21 ` Janusz Krzysztofik
2026-04-29 6:12 ` Krzysztof Karas
2026-04-28 14:57 ` Andi Shyti [this message]
2026-04-21 6:17 ` [PATCH v7 2/2] drm/i915/selftests: Run vma tests only if current->mm is present Krzysztof Karas
2026-04-24 9:52 ` Sebastian Brzezinka
2026-04-28 15:03 ` Andi Shyti
2026-04-22 8:51 ` ✓ i915.CI.BAT: success for drm/i915/selftests: Use safe userspace memory for mappings Patchwork
2026-04-22 14:45 ` ✓ i915.CI.Full: " 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=afDK2Q_jxoiw0zIM@ashyti-mobl2.lan \
--to=andi.shyti@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=janusz.krzysztofik@linux.intel.com \
--cc=krzysztof.karas@intel.com \
--cc=krzysztof.niemiec@intel.com \
--cc=sebastian.brzezinka@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox