linux/arch/um/kernel
Johannes Berg 68025adfc1 um: fix _nofault accesses
Nathan reported [1] that when built with clang, the um kernel
crashes pretty much immediately. This turned out to be an issue
with the inline assembly I had added, when clang used %rax/%eax
for both operands. Reorder it so current->thread.segv_continue
is written first, and then the lifetime of _faulted won't have
overlap with the lifetime of segv_continue.

In the email thread Benjamin also pointed out that current->mm
is only NULL for true kernel tasks, but we could do this for a
userspace task, so the current->thread.segv_continue logic must
be lifted out of the mm==NULL check.

Finally, while looking at this, put a barrier() so the NULL
assignment to thread.segv_continue cannot be reorder before
the possibly faulting operation.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Closes: https://lore.kernel.org/r/20250402221254.GA384@ax162 [1]
Fixes: d1d7f01f7c ("um: mark rodata read-only and implement _nofault accesses")
Tested-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2025-05-05 10:06:51 +02:00
..
skas um: work around sched_yield not yielding in time-travel mode 2025-03-18 11:06:20 +01:00
asm-offsets.c um: get rid of pointless include "..." where include <...> will do 2012-10-09 22:28:45 +02:00
config.c.in um: Add SPDX headers to files in arch/um/kernel/ 2019-09-15 21:37:17 +02:00
dtb.c This pull request contains the following changes for UML: 2024-11-30 10:34:54 -08:00
dyn.lds.S um: move thread info into task 2024-11-12 14:50:31 +01:00
early_printk.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
exec.c um: Remove the call to SUBARCH_EXECVE1 macro 2024-09-12 20:42:22 +02:00
exitcode.c proc: convert everything to "struct proc_ops" 2020-02-04 03:05:26 +00:00
gprof_syms.c um: Add SPDX headers to files in arch/um/kernel/ 2019-09-15 21:37:17 +02:00
initrd.c um: Do not propagate initrd parameter to kernel 2024-10-23 09:52:49 +02:00
ioport.c um: add PCI over virtio emulation driver 2021-06-17 21:45:43 +02:00
irq.c um: mark rodata read-only and implement _nofault accesses 2025-03-18 11:03:14 +01:00
kmsg_dump.c printk: Add a short description string to kmsg_dump() 2024-07-17 12:35:24 +02:00
ksyms.c um: generalize os_rcv_fd 2024-07-03 12:24:25 +02:00
load_file.c mm/memblock: add memblock_alloc_or_panic interface 2025-01-25 20:22:38 -08:00
Makefile um: remove copy_from_kernel_nofault_allowed 2025-03-18 11:03:29 +01:00
mem.c Updates for UML for this cycle, notably: 2025-04-02 12:25:03 -07:00
physmem.c arch, mm: set max_mapnr when allocating memory map for FLATMEM 2025-03-17 22:06:52 -07:00
process.c um: avoid copying FP state from init_task 2025-02-12 23:40:38 +01:00
ptrace.c um: Move declarations to proper headers 2024-04-22 21:58:48 +02:00
reboot.c um: Remove unused mm_fd field from mm_id 2024-09-12 20:36:22 +02:00
sigio.c um: Rewrite the sigio workaround based on epoll and tgkill 2025-03-20 09:28:44 +01:00
signal.c um: Drop support for hosts without SYSEMU_SINGLESTEP support 2024-01-04 23:29:11 +01:00
stacktrace.c UML: add support for KASAN under x86_64 2022-07-17 23:35:22 +02:00
sysrq.c um: Always dump trace for specified task in show_stack 2024-11-07 18:05:22 +01:00
time.c um: insert scheduler ticks when userspace does not yield 2024-10-23 09:52:49 +02:00
tlb.c um: Rename _PAGE_NEWPAGE to _PAGE_NEEDSYNC 2024-10-23 09:52:49 +02:00
trap.c um: fix _nofault accesses 2025-05-05 10:06:51 +02:00
um_arch.c Updates for UML for this cycle, notably: 2025-04-02 12:25:03 -07:00
um_arch.h um: Move declarations to proper headers 2024-04-22 21:58:48 +02:00
umid.c uml: Remove the initialization of statics to 0 2022-09-19 23:10:07 +02:00
uml.lds.S um: move thread info into task 2024-11-12 14:50:31 +01:00
vmlinux.lds.S UML: define RUNTIME_DISCARD_EXIT 2023-02-13 10:14:31 +01:00