kernel_samsung_a53x/arch/arm64/include/asm
Lorenzo Stoakes d1811067ee mm: refactor arch_calc_vm_flag_bits() and arm64 MTE handling
[ Upstream commit 5baf8b037debf4ec60108ccfeccb8636d1dbad81 ]

Currently MTE is permitted in two circumstances (desiring to use MTE
having been specified by the VM_MTE flag) - where MAP_ANONYMOUS is
specified, as checked by arch_calc_vm_flag_bits() and actualised by
setting the VM_MTE_ALLOWED flag, or if the file backing the mapping is
shmem, in which case we set VM_MTE_ALLOWED in shmem_mmap() when the mmap
hook is activated in mmap_region().

The function that checks that, if VM_MTE is set, VM_MTE_ALLOWED is also
set is the arm64 implementation of arch_validate_flags().

Unfortunately, we intend to refactor mmap_region() to perform this check
earlier, meaning that in the case of a shmem backing we will not have
invoked shmem_mmap() yet, causing the mapping to fail spuriously.

It is inappropriate to set this architecture-specific flag in general mm
code anyway, so a sensible resolution of this issue is to instead move the
check somewhere else.

We resolve this by setting VM_MTE_ALLOWED much earlier in do_mmap(), via
the arch_calc_vm_flag_bits() call.

This is an appropriate place to do this as we already check for the
MAP_ANONYMOUS case here, and the shmem file case is simply a variant of
the same idea - we permit RAM-backed memory.

This requires a modification to the arch_calc_vm_flag_bits() signature to
pass in a pointer to the struct file associated with the mapping, however
this is not too egregious as this is only used by two architectures anyway
- arm64 and parisc.

So this patch performs this adjustment and removes the unnecessary
assignment of VM_MTE_ALLOWED in shmem_mmap().

[akpm@linux-foundation.org: fix whitespace, per Catalin]
Link: https://lkml.kernel.org/r/ec251b20ba1964fb64cf1607d2ad80c47f3873df.1730224667.git.lorenzo.stoakes@oracle.com
Fixes: deb0f6562884 ("mm/mmap: undo ->mmap() when arch_validate_flags() fails")
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Suggested-by: Catalin Marinas <catalin.marinas@arm.com>
Reported-by: Jann Horn <jannh@google.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Andreas Larsson <andreas@gaisler.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Helge Deller <deller@gmx.de>
Cc: James E.J. Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Peter Xu <peterx@redhat.com>
Cc: Will Deacon <will@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-12-17 13:23:57 +01:00
..
vdso Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
xen Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
acenv.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
acpi.h Revert "arm64: acpi: Move get_cpu_for_acpi_id() to a header" 2024-11-24 00:23:36 +01:00
alternative-macros.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
alternative.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
arch_gicv3.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
arch_timer.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
archrandom.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
arm-cci.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
arm_dsu_pmu.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
asm-bug.h arm64: asm-bug: Add .align 2 to the end of __BUG_ENTRY 2024-11-19 12:27:09 +01:00
asm-offsets.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
asm-prototypes.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
asm-uaccess.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
asm_pointer_auth.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
assembler.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
atomic.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
atomic_ll_sc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
atomic_lse.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
barrier.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
bitops.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
bitrev.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
boot.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
brk-imm.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
bug.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cache.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cacheflush.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
checksum.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
clocksource.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cmpxchg.h arm64: lse: Always use LSE atomic instructions 2024-11-17 17:45:05 +01:00
compat.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
compiler.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cpu.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cpu_ops.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cpucaps.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cpufeature.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cpuidle.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cputype.h Revert "arm64: Add Cortex-715 CPU part definition" 2024-11-24 00:23:00 +01:00
current.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
daifflags.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dcc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
debug-monitors.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
device.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dma-mapping-noalias.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dmi.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
efi.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
el2_setup.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
elf.h arm64: determine stack entropy based on mmap entropy 2024-11-30 02:16:49 +01:00
esr.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
exception.h arm64: allow kprobes on EL0 handlers 2024-11-08 11:26:02 +01:00
exec.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
extable.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fb.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fixmap.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fpsimd.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fpsimdmacros.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ftrace.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
futex.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hardirq.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hugetlb.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hw_breakpoint.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hwcap.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hyp_image.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hypervisor.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
image.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
insn.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
io.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
irq.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
irq_work.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
irqflags.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
jump_label.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kasan.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Kbuild Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kernel-pgtable.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kexec.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kfence.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kgdb.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kprobes.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kvm_arm.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kvm_asm.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kvm_emulate.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kvm_host.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kvm_hyp.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kvm_mmu.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kvm_pgtable.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kvm_ptrauth.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kvm_ras.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kvm_types.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
linkage.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
lse.h arm64: lse: Always use LSE atomic instructions 2024-11-17 17:45:05 +01:00
memory.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mman.h mm: refactor arch_calc_vm_flag_bits() and arm64 MTE handling 2024-12-17 13:23:57 +01:00
mmu.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mmu_context.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mmzone.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
module.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
module.lds.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mte-def.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mte-kasan.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mte.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
neon-intrinsics.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
neon.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
numa.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
page-def.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
page.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
paravirt.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pci.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
percpu.h arm64: lse: Always use LSE atomic instructions 2024-11-17 17:45:05 +01:00
perf_event.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pgalloc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pgtable-hwdef.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pgtable-prot.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pgtable-types.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pgtable.h arm64: mm: Always make sw-dirty PTEs hw-dirty in pte_modify 2024-11-18 12:11:57 +01:00
pointer_auth.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
preempt.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
probes.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
proc-fns.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
processor.h arm64: lse: Always use LSE atomic instructions 2024-11-17 17:45:05 +01:00
ptdump.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ptrace.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pvclock-abi.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rwonce.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scs.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdei.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
seccomp.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sections.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
setup.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
shmparam.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
signal.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
signal32.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
simd.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smp.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smp_plat.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sparsemem.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
spectre.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
spinlock.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
spinlock_types.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
stack_pointer.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
stackprotector.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
stacktrace.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
stage2_pgtable.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
stat.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
string.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
suspend.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sync_bitops.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
syscall.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
syscall_wrapper.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sysreg.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
system_misc.h arm64: die(): pass 'err' as long 2024-11-08 11:25:59 +01:00
thread_info.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
timex.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tlb.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tlbflush.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
topology.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
traps.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
uaccess.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
unistd.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
unistd32.h syscalls: fix compat_sys_io_pgetevents_time64 usage 2024-11-19 14:19:34 +01:00
uprobes.h arm64/uprobes: change the uprobe_opcode_t typedef to fix the sparse warning 2024-11-23 23:22:02 +01:00
vdso.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vectors.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vermagic.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
virt.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vmalloc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vmap_stack.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
word-at-a-time.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
xor.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00