Re: [PATCH v2 0/2] Add test for atomic uaccess with permission overlay

From: Kevin Brodsky

Date: Thu Nov 19 2026 - 05:38:37 EST


On 19/11/2026 10:54, Kevin Brodsky wrote:
> 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@xxxxxxx>
>
> [1] https://lore.kernel.org/r/20261109-kpkeys-v10-0-aa6c4d9603bc@xxxxxxx
> [2] https://sashiko.dev/#/patchset/20260505-kpkeys-v7-0-20c0bdd97197%40arm.com?part=3
> [3] https://lore.kernel.org/r/sashiko-outbox-207324@xxxxxxxxxx
>
> ---
> 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@xxxxxxx/
>
> ---
> To: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
> Cc: Catalin Marinas <catalin.marinas@xxxxxxx>
> Cc: Joey Gouly <joey.gouly@xxxxxxx>
> Cc: Linu Cherian <linu.cherian@xxxxxxx>
> Cc: Mark Brown <broonie@xxxxxxxxxx>
> Cc: Shuah Khan <shuah@xxxxxxxxxx>
> Cc: Will Deacon <will@xxxxxxxxxx>
> Cc: Yeoreum Yun <yeoreum.yun@xxxxxxx>
> Cc: linux-kernel@xxxxxxxxxxxxxxx
> Cc: linux-kselftest@xxxxxxxxxxxxxxx
>
> ---
> Kevin Brodsky (2):
> arm64: mm: Add note about overlays in PIE_EL1
> kselftest/arm64: Add test for atomic futex uaccess with POE

I completely forgot to address Mark's comment from v1... Please ignore
this for now, sending a v3 soon.

- Kevin