Re: [PATCH v4 2/2] selftests/ptrace: check that PTRACE_SET_SYSCALL_INFO rejects invalid error values
From: Bradley Morgan
Date: Tue Nov 17 2026 - 10:46:24 EST
On 16 November 2026 23:36:42 GMT, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
wrote:
>On Mon, 16 Nov 2026 14:40:46 +0100 Renzo Davoli <renzo@xxxxxxxxxxx> wrote:
>
>> At every exit stop of the set_syscall_info test, try to set with
>> is_error set a few values outside [-MAX_ERRNO, -1], check that
>> PTRACE_SET_SYSCALL_INFO fails with ERANGE and that the return value
>> of the system call is left untouched.
>
>Thanks.
>
>LLM suggested a little fixup here, please check.
>
>
>
>From: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
>Subject: selftests/ptrace: test the lowest valid syscall error
>Date: Mon, 16 Nov 2026 22:27:14 +0000
>
>PTRACE_SET_SYSCALL_INFO must reject values below -MAX_ERRNO while
>accepting -MAX_ERRNO itself. Name the bound locally for this userspace
>selftest, and add a successful exit-stop case at that boundary. Retain
>the existing -EISDIR case. The tracee checks the resulting errno.
>
>Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Reviewed-by: Bradley Morgan <bradley.morgan@xxxxxxxxx>
>Cc: Renzo Davoli <renzo@xxxxxxxxxxx>
>
> tools/testing/selftests/ptrace/set_syscall_info.c | 25 +++++++++++-
> 1 file changed, 24 insertions(+), 1 deletion(-)
>
>--- a/tools/testing/selftests/ptrace/set_syscall_info.c~selftests-ptrace-check-that-ptrace_set_syscall_info-rejects-invalid-error-values-fix
>+++ a/tools/testing/selftests/ptrace/set_syscall_info.c
>@@ -15,6 +15,8 @@
> #include <linux/types.h>
> #include <linux/ptrace.h>
>
>+#define MAX_ERRNO 4095
>+
> #if defined(_MIPS_SIM) && _MIPS_SIM == _MIPS_SIM_NABI32
> /*
> * MIPS N32 is the only architecture where __kernel_ulong_t
>@@ -131,7 +133,7 @@ static const long long bad_error_rval[]
> 0,
> 1,
> ESRCH,
>- -4095 - 1, /* -MAX_ERRNO - 1 */
>+ -MAX_ERRNO - 1,
> -2147483647LL - 1,
> #if __SIZEOF_LONG__ > 4
> 0x100000000LL,
>@@ -325,6 +327,27 @@ TEST(set_syscall_info)
> }
> },
>
>+ /* change scno, change non-error rval to -MAX_ERRNO */
>+ {
>+ {
>+ {
>+ __NR_chdir,
>+ {
>+ dummy[0], dummy[1], dummy[2],
>+ dummy[3], dummy[4], dummy[5]
>+ }
>+ }, {
>+ __NR_getppid,
>+ {
>+ dummy[0], dummy[1], dummy[2],
>+ dummy[3], dummy[4], dummy[5]
>+ }
>+ }
>+ }, {
>+ { 0, tracer_pid }, { 1, -MAX_ERRNO }
>+ }
>+ },
>+
> /* change scno and all args, change non-error rval */
> {
> {
>_
>
>
--- Thanks!