linux/Documentation/core-api
Thomas Gleixner 05c033db7e entry, treewide: Make syscall_enter_from_user_mode[_work]() indicate syscall execution
The return values of syscall_enter_from_user_mode[_work]() are
non-intuitive. Both functions return the syscall number which should be
invoked by the architecture specific syscall entry code. The returned
number can be:

  - the unmodified syscall number which was handed in by the caller

  - a modified syscall number (ptrace, seccomp, trace/probe/bpf)

That has an additional twist. If the return value is -1L then the caller is
not allowed to modify the return value as that indicates that the modifying
entity requests to abort the syscall and set the return value already. That
can obviously not be differentiated from a syscall which handed in -1 as
syscall number.

The most trivial way to deal with that is:

    set_return_value(regs, -ENOSYS);
    nr = syscall_enter_from_user_mode(regs, nr);
    if (valid(nr))
    	handle_syscall(regs, nr);

That's what LOONGARCH, RISCV, and X86 do. But PowerPC and S390 do not
preset the return value, so when user space hands in -1 and there is
nothing setting the return value in the entry work code, then the syscall
is skipped but the return value is whatever random data has been in the
return value register.

Change the return values of syscall_enter_from_user_mode[_work]() to
boolean and return false, when either ptrace or seccomp request to skip the
syscall. If they return true, update the syscall number as it might have
been changed.

That results in slightly different behaviour of the architectures versus
tracing.

If the syscall tracepoint has probe/BPF attached, those might set the
syscall number to -1 and also set the return value. PowerPC and S390 will
then overwrite that value with -ENOSYS. The other architectures will just
ignore it like any other invalid syscall and use the modified one.

Originally-by: Michal Suchánek <msuchanek@suse.de>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Tested-by: Michal Suchánek <msuchanek@suse.de>
Link: https://patch.msgid.link/20260712141346.772209074@kernel.org
2026-07-20 20:38:40 +02:00
..
irq Documentation: Add managed interrupts 2026-04-11 07:07:02 -06:00
kho kho: add support for linked-block serialization 2026-06-03 21:15:46 +03:00
real-time docs: real-time: Fix duplicated sched(7) text 2026-06-01 13:05:55 -06:00
wrappers
asm-annotations.rst
assoc_array.rst Documentation: assoc_array: Format internal tree layout tables 2025-10-17 14:23:04 -06:00
boot-time-mm.rst
cachetlb.rst
cgroup.rst doc/cgroup: Fix title underline length 2025-01-15 09:46:18 +01:00
circular-buffers.rst
cleanup.rst cleanup: Add usage and style documentation 2024-08-05 16:54:41 +02:00
cpu_hotplug.rst Documentation: core-api/cpu_hotplug: Remove stale cpu0_hotplug docs 2026-05-15 08:44:24 -06:00
debug-objects.rst
debugging-via-ohci1394.rst Documentation: Drop or replace remaining mentions of IA64 2023-09-11 08:13:18 +00:00
dma-api-howto.rst docs: dma-api: document __dma_from_device_group_begin()/end() 2025-12-31 19:28:12 -05:00
dma-api.rst dma-debug: refactor to use physical addresses for page mapping 2025-09-12 00:09:51 +02:00
dma-attributes.rst dma-mapping: Introduce DMA require coherency attribute 2026-03-20 12:05:36 +01:00
dma-isa-lpc.rst
entry.rst entry, treewide: Make syscall_enter_from_user_mode[_work]() indicate syscall execution 2026-07-20 20:38:40 +02:00
errseq.rst
floating-point.rst arch: add ARCH_HAS_KERNEL_FPU_SUPPORT 2024-05-19 14:36:17 -07:00
folio_queue.rst docs: folio_queue: Fix minor typo in folio_queue page 2025-08-12 12:40:15 -06:00
genalloc.rst
generic-radix-tree.rst
genericirq.rst treewide: Update email address 2026-01-11 06:09:11 -10:00
gfp_mask-from-fs-io.rst docs: core-api/gfp_mask-from-fs-io: indicate that vmalloc supports GFP_NOFS/GFP_NOIO 2024-11-22 10:42:37 -07:00
housekeeping.rst docs: housekeeping: Fix struct member access in code example 2026-05-15 08:25:16 -06:00
idr.rst
index.rst A slightly calmer cycle for docs this time around, though there is still a 2026-02-09 20:53:18 -08:00
kernel-api.rst block: Include bvec.h kernel-doc in the htmldocs 2026-05-29 05:34:25 -06:00
kobject.rst docs: Update documentation to avoid mentioning of kernel.h 2025-12-22 14:59:18 -07:00
kref.rst Documentation: adopt new coding style of type-aware kmalloc-family 2026-05-03 08:54:21 -06:00
librs.rst treewide: Update email address 2026-01-11 06:09:11 -10:00
list.rst Documentation: adopt new coding style of type-aware kmalloc-family 2026-05-03 08:54:21 -06:00
liveupdate.rst liveupdate: luo_flb: introduce File-Lifecycle-Bound global state 2026-02-08 00:13:33 -08:00
local_ops.rst
maple_tree.rst maple_tree: update the documentation of maple tree 2023-12-10 16:51:32 -08:00
memory-allocation.rst docs/core-api: memory-allocation: GFP_NOWAIT doesn't need __GFP_NOWARN 2024-07-29 15:10:25 -06:00
memory-hotplug.rst docs: memory-hotplug: fix typo 'fo' -> 'for' in NODE_ADDED_FIRST_MEMORY description 2026-03-17 08:42:05 -06:00
min_heap.rst Documentation/core-api: min_heap: update for variable types change 2025-02-18 13:30:56 -07:00
mm-api.rst mm: rename balloon_compaction.(c|h) to balloon.(c|h) 2026-01-31 14:22:35 -08:00
netlink.rst
packing.rst docs: packing: Fix a typo in example code. 2025-06-09 12:29:50 -06:00
padata.rst
parser.rst Documentation: core-api: add generic parser docbook 2024-12-11 09:07:40 -07:00
pin_user_pages.rst mm: remove page_mkclean() 2024-07-03 19:30:17 -07:00
printk-basics.rst Documentation: printk: Add section about avoiding lockups 2026-03-17 08:37:49 -06:00
printk-formats.rst vsprintf: Add upper case flavour to %p[mM] 2026-06-12 14:20:25 +02:00
printk-index.rst docs:core-api: fixed typos and grammar in printk-index page 2024-05-07 08:01:11 -06:00
protection-keys.rst Documentation/protection-keys: add AArch64 to documentation 2024-10-14 17:27:48 +01:00
rbtree.rst Docs/core-api: fix typos in rbtree.rst 2026-02-14 10:11:43 -07:00
refcount-vs-atomic.rst refcount: provide ops for cases when object's memory can be reused 2025-03-16 22:06:19 -07:00
swiotlb.rst docs/core-api: swiotlb: fix typos 2024-10-17 09:37:05 -06:00
symbol-namespaces.rst docs: symbol-namespaces: mention sysfs attribute 2026-03-19 22:49:37 +00:00
this_cpu_ops.rst docs: Improve discussion of this_cpu_ptr(), add raw_cpu_ptr() 2025-02-04 21:50:06 -08:00
timekeeping.rst
tracepoint.rst
unaligned-memory-access.rst move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
union_find.rst Documentation: Fix the compilation errors in union_find.rst 2024-08-02 08:58:16 -10:00
watch_queue.rst
workqueue.rst docs: workqueue: document WQ_AFFN_CACHE_SHARD affinity scope 2026-04-01 10:24:18 -10:00
xarray.rst xarray: add xas_try_split() to split a multi-index entry 2025-03-17 22:06:59 -07:00