mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Add test for atomic uaccess with permission overlay
@ 2026-11-19  9:54 Kevin Brodsky
  2026-11-19  9:54 ` [PATCH v2 1/2] arm64: mm: Add note about overlays in PIE_EL1 Kevin Brodsky
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Kevin Brodsky @ 2026-11-19  9:54 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Kevin Brodsky, Catalin Marinas, Joey Gouly, Linu Cherian,
	Mark Brown, Shuah Khan, Will Deacon, Yeoreum Yun, linux-kernel,
	linux-kselftest

POE is not currently enabled at EL1, but my series [1] protecting
page tables does exactly that, and it has revealed an interesting
issue.

Regular uaccess uses unprivileged loads/stores, which have overlays
applied and are checked against the user's POR_EL0 as intended (same
restrictions as when accessing memory from userspace). In some
cases, such as atomic operations when FEAT_LSUI isn't available, we
need to use privileged L/S with PAN disabled instead; overlays are
not applied in that case.

Once POE is enabled at EL1, we have to ensure that overlays are
still not applied to these accesses. Otherwise, they will be checked
against POR_EL1, which is completely invalid as kernel
pkeys/POIndices are unrelated to user pkeys.

If PIE is used, then we have to ensure that user memory types do not
have overlays applied in POR_EL1, as Sashiko reported [2] on an
earlier version of my series protecting page tables. Patch 1 tries
to preempt such errors by adding a comment. If PIE isn't available,
then... we're out of luck, as Sashiko reported later on [3]: we
cannot prevent overlays from being applied to user memory. We'll
most likely have to require PIE at least when POE is enabled at
EL1.

To avoid accidents in the future, patch 2 adds a kselftest to ensure
that atomic futex uaccess (which uses privileged loads/stores unless
FEAT_LSUI is available) does work on memory mapped with a
non-default pkey. 

Signed-off-by: Kevin Brodsky <kevin.brodsky@arm.com>

[1] https://lore.kernel.org/r/20261109-kpkeys-v10-0-aa6c4d9603bc@arm.com
[2] https://sashiko.dev/#/patchset/20260505-kpkeys-v7-0-20c0bdd97197%40arm.com?part=3
[3] https://lore.kernel.org/r/sashiko-outbox-207324@kernel.org

---
v1..v2:

* Reworded the cover letter and the commit message of patch 2 in
  light of Sashiko's new findings (when PIE isn't available).
* Rebased on v7.4-rc3

v1: https://lore.kernel.org/all/20260521-poe_futex-v1-0-1da286b8f9b2@arm.com/

---
To: linux-arm-kernel@lists.infradead.org
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Joey Gouly <joey.gouly@arm.com>
Cc: Linu Cherian <linu.cherian@arm.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Will Deacon <will@kernel.org>
Cc: Yeoreum Yun <yeoreum.yun@arm.com>
Cc: linux-kernel@vger.kernel.org
Cc: linux-kselftest@vger.kernel.org

---
Kevin Brodsky (2):
      arm64: mm: Add note about overlays in PIE_EL1
      kselftest/arm64: Add test for atomic futex uaccess with POE

 arch/arm64/include/asm/pgtable-prot.h         |  7 +++
 tools/testing/selftests/arm64/Makefile        |  2 +-
 tools/testing/selftests/arm64/poe/.gitignore  |  2 +
 tools/testing/selftests/arm64/poe/Makefile    |  6 +++
 tools/testing/selftests/arm64/poe/poe_futex.c | 62 +++++++++++++++++++++++++++
 5 files changed, 78 insertions(+), 1 deletion(-)
---
base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
change-id: 20260520-poe_futex-ecb8c2276894


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-19 10:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19  9:54 [PATCH v2 0/2] Add test for atomic uaccess with permission overlay Kevin Brodsky
2026-11-19  9:54 ` [PATCH v2 1/2] arm64: mm: Add note about overlays in PIE_EL1 Kevin Brodsky
2026-11-19 10:14   ` Yeoreum Yun
2026-11-19  9:54 ` [PATCH v2 2/2] kselftest/arm64: Add test for atomic futex uaccess with POE Kevin Brodsky
2026-11-19 10:35   ` Yeoreum Yun
2026-11-19 10:38 ` [PATCH v2 0/2] Add test for atomic uaccess with permission overlay Kevin Brodsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®