[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <202502190917.5A3251484@keescook>
Date: Wed, 19 Feb 2025 09:19:34 -0800
From: Kees Cook <kees@...nel.org>
To: Dmitry Vyukov <dvyukov@...gle.com>
Cc: krisman@...labora.com, tglx@...utronix.de, luto@...nel.org,
peterz@...radead.org, gregory.price@...verge.com,
Marco Elver <elver@...gle.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/3] selftests: Fix errno checking in
syscall_user_dispatch test
On Tue, Feb 18, 2025 at 05:04:35PM +0100, Dmitry Vyukov wrote:
> 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.
>
> Signed-off-by: Dmitry Vyukov <dvyukov@...gle.com>
Reviewed-by: Kees Cook <kees@...nel.org>
Yeah, these all look good to me.
--
Kees Cook
Powered by blists - more mailing lists