acrn-kernel/arch
Catalin Marinas 96122e776f arm64: mte: Fix/clarify the PG_mte_tagged semantics
commit e059853d14 upstream.

Currently the PG_mte_tagged page flag mostly means the page contains
valid tags and it should be set after the tags have been cleared or
restored. However, in mte_sync_tags() it is set before setting the tags
to avoid, in theory, a race with concurrent mprotect(PROT_MTE) for
shared pages. However, a concurrent mprotect(PROT_MTE) with a copy on
write in another thread can cause the new page to have stale tags.
Similarly, tag reading via ptrace() can read stale tags if the
PG_mte_tagged flag is set before actually clearing/restoring the tags.

Fix the PG_mte_tagged semantics so that it is only set after the tags
have been cleared or restored. This is safe for swap restoring into a
MAP_SHARED or CoW page since the core code takes the page lock. Add two
functions to test and set the PG_mte_tagged flag with acquire and
release semantics. The downside is that concurrent mprotect(PROT_MTE) on
a MAP_SHARED page may cause tag loss. This is already the case for KVM
guests if a VMM changes the page protection while the guest triggers a
user_mem_abort().

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
[pcc@google.com: fix build with CONFIG_ARM64_MTE disabled]
Signed-off-by: Peter Collingbourne <pcc@google.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Steven Price <steven.price@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Peter Collingbourne <pcc@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20221104011041.290951-3-pcc@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-03-11 13:55:44 +01:00
..
alpha alpha: fix FEN fault handling 2023-03-10 09:34:25 +01:00
arc
arm ARM: dts: spear320-hmi: correct STMPE GPIO compatible 2023-03-11 13:55:28 +01:00
arm64 arm64: mte: Fix/clarify the PG_mte_tagged semantics 2023-03-11 13:55:44 +01:00
csky
hexagon
ia64 ia64: fix build error due to switch case label appearing next to declaration 2023-02-09 11:28:23 +01:00
loongarch LoongArch, bpf: Use 4 instructions for function address in JIT 2023-03-10 09:33:06 +01:00
m68k m68k: Check syscall_trace_enter() return code 2023-03-10 09:33:51 +01:00
microblaze
mips MIPS: DTS: CI20: fix otg power gpio 2023-03-10 09:34:30 +01:00
nios2
openrisc
parisc parisc: Wire up PTRACE_GETREGS/PTRACE_SETREGS for compat case 2023-02-09 11:28:20 +01:00
powerpc powerpc: Remove linker flag from KBUILD_AFLAGS 2023-03-10 09:33:41 +01:00
riscv riscv: ftrace: Reduce the detour code size to half 2023-03-10 09:34:30 +01:00
s390 KVM: s390: disable migration mode when dirty tracking is disabled 2023-03-10 09:34:05 +01:00
sh sh: define RUNTIME_DISCARD_EXIT 2023-02-25 11:25:42 +01:00
sparc sparc: allow PM configs for sparc32 COMPILE_TEST 2023-03-10 09:33:27 +01:00
um um: virt-pci: properly remove PCI device from bus 2023-03-11 13:55:23 +01:00
x86 x86/resctl: fix scheduler confusion with 'current' 2023-03-11 13:55:41 +01:00
xtensa
.gitignore
Kconfig