linux/arch/um
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
..
configs This pull request contains the following changes for UML: 2024-11-30 10:34:54 -08:00
drivers treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
include um: fix _nofault accesses 2025-05-05 10:06:51 +02:00
kernel um: fix _nofault accesses 2025-05-05 10:06:51 +02:00
os-Linux um: Rewrite the sigio workaround based on epoll and tgkill 2025-03-20 09:28:44 +01:00
scripts um: prevent user code in modules 2023-04-20 23:06:38 +02:00
.gitignore um: gitignore: Add kernel/capflags.c 2021-12-21 21:22:43 +01:00
Kbuild um: use obj-y to descend into arch/um/*/ 2023-08-26 22:41:34 +02:00
Kconfig um: mark rodata read-only and implement _nofault accesses 2025-03-18 11:03:14 +01:00
Kconfig.debug um: Disable CONFIG_GCOV with MODULES 2021-04-15 23:10:33 +02:00
Makefile um: always include kconfig.h and compiler-version.h 2024-11-07 17:36:30 +01:00
Makefile-os-Linux
Makefile-skas um: fix stub exe build with CONFIG_GCOV 2024-10-26 16:06:10 +02:00