public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <kees@kernel.org>
To: Dmitry Vyukov <dvyukov@google.com>
Cc: krisman@collabora.com, tglx@linutronix.de, luto@kernel.org,
	peterz@infradead.org, gregory.price@memverge.com,
	Marco Elver <elver@google.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] selftests: Fix errno checking in syscall_user_dispatch test
Date: Wed, 19 Feb 2025 09:19:34 -0800	[thread overview]
Message-ID: <202502190917.5A3251484@keescook> (raw)
In-Reply-To: <d83f45b96a9c8d3c1a20a4ff518cf4c13bcacbe4.1739894594.git.dvyukov@google.com>

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@google.com>

Reviewed-by: Kees Cook <kees@kernel.org>

Yeah, these all look good to me.

-- 
Kees Cook

  reply	other threads:[~2025-02-19 17:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1739894594.git.dvyukov@google.com>
2025-02-18 16:04 ` [PATCH 1/3] syscall_user_dispatch: Allow allowed range wrap-around Dmitry Vyukov
2025-02-18 16:58   ` Gregory Price
2025-02-18 17:34     ` Dmitry Vyukov
2025-02-18 18:00       ` Gregory Price
2025-02-19  8:54         ` Dmitry Vyukov
2025-02-19 13:29           ` Gregory Price
2025-02-18 16:04 ` [PATCH 2/3] selftests: Fix errno checking in syscall_user_dispatch test Dmitry Vyukov
2025-02-19 17:19   ` Kees Cook [this message]
2025-02-18 16:04 ` [PATCH 3/3] selftests: Extend syscall_user_dispatch test to check allowed range Dmitry Vyukov
2025-02-20 15:17   ` Gregory Price
2025-02-24  8:48     ` Dmitry Vyukov
2025-03-03 15:57       ` Gregory Price

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202502190917.5A3251484@keescook \
    --to=kees@kernel.org \
    --cc=dvyukov@google.com \
    --cc=elver@google.com \
    --cc=gregory.price@memverge.com \
    --cc=krisman@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox