]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests: Fix errno checking in syscall_user_dispatch test
authorDmitry Vyukov <dvyukov@google.com>
Wed, 21 May 2025 15:04:28 +0000 (17:04 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Fri, 13 Jun 2025 16:36:39 +0000 (18:36 +0200)
commitb89732c8c8357487185f260a723a060b3476144e
treedd92dbcf19613d8249e8d33658c8d8ee3bb1169e
parent19272b37aa4f83ca52bdf9c16d5d81bdd1354494
selftests: Fix errno checking in syscall_user_dispatch test

Successful syscalls don't change errno, so checking errno is wrong
to ensure that a syscall has failed. For example for the following
sequence:

prctl(PR_SET_SYSCALL_USER_DISPATCH, op, 0x0, 0xff, 0);
EXPECT_EQ(EINVAL, errno);
prctl(PR_SET_SYSCALL_USER_DISPATCH, op, 0x0, 0x0, &sel);
EXPECT_EQ(EINVAL, errno);

only the first syscall may fail and set errno, but the second may succeed
and keep errno intact, and the check will falsely pass.
Or if errno happened to be EINVAL before, even the first check may falsely
pass.

Also use EXPECT/ASSERT consistently. Currently there is an inconsistent mix
without obvious reasons for usage of one or another.

Fixes: 179ef035992e ("selftests: Add kselftest for syscall user dispatch")
Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/af6a04dbfef9af8570f5bab43e3ef1416b62699a.1747839857.git.dvyukov@google.com
tools/testing/selftests/syscall_user_dispatch/sud_test.c