Re: [RFC v2 PATCH 7/7] x86/entry: use int for syscall number; handle all invalid syscall nrs

From: Ingo Molnar
Date: Wed May 12 2021 - 04:51:38 EST



* H. Peter Anvin <hpa@xxxxxxxxx> wrote:

> From: "H. Peter Anvin (Intel)" <hpa@xxxxxxxxx>
>
> Redefine the system call number consistently to be "int". The value -1
> is a non-system call (which can be poked in by ptrace/seccomp to
> indicate that no further processing should be done and that the return
> value should be the current value in regs->ax, default to -ENOSYS; any
> other value which does not correspond to a valid system call
> unconditionally calls sys_ni_syscall() and returns -ENOSYS just like
> any system call that corresponds to a hole in the system call table.
>
> This is the defined semantics of syscall_get_nr(), so that is what all
> the architecture-independent code already expects. As documented in
> <asm-generic/syscall.h> (which is simply the documentation file for
> <asm/syscall.h>):
>
> /**
> * syscall_get_nr - find what system call a task is executing
> * @task: task of interest, must be blocked
> * @regs: task_pt_regs() of @task
> *
> * If @task is executing a system call or is at system call
> * tracing about to attempt one, returns the system call number.
> * If @task is not executing a system call, i.e. it's blocked
> * inside the kernel for a fault or signal, returns -1.
> *
> * Note this returns int even on 64-bit machines. Only 32 bits of
> * system call number can be meaningful. If the actual arch value
> * is 64 bits, this truncates to 32 bits so 0xffffffff means -1.
> *
> * It's only valid to call this when @task is known to be blocked.
> */
> int syscall_get_nr(struct task_struct *task, struct pt_regs *regs);

I've applied patches 1-6, thanks Peter!

Wrt. patch #7 - the changelog is hedging things a bit and the changes are
non-trivial. Does this patch (intend to) change any actual observable
behavior in the system call interface, and if yes, in which areas?

Or is this a pure cleanup with no observable changes expected?

Thanks,

Ingo