All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Andy Lutomirski <luto@kernel.org>
Cc: x86@kernel.org, LKML <linux-kernel@vger.kernel.org>,
	stable@vger.kernel.org
Subject: Re: [PATCH 2/3] x86/entry: Fix entry/exit mismatch on failed fast 32-bit syscalls
Date: Tue, 23 Feb 2021 12:28:49 +0100	[thread overview]
Message-ID: <YDTm8Q/cvBcfzhPn@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <a0025117242488a30621fb9858918802532f9ee9.1614059335.git.luto@kernel.org>

On Mon, Feb 22, 2021 at 09:50:28PM -0800, Andy Lutomirski wrote:
> On a 32-bit fast syscall that fails to read its arguments from user
> memory, the kernel currently does syscall exit work but not
> syscall exit work.  This would confuse audit and ptrace.
> 
> This is a minimal fix intended for ease of backporting.  A more
> complete cleanup is coming.
> 
> Cc: stable@vger.kernel.org
> Fixes: 0b085e68f407 ("x86/entry: Consolidate 32/64 bit syscall entry")
> Signed-off-by: Andy Lutomirski <luto@kernel.org>
> ---
>  arch/x86/entry/common.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
> index 0904f5676e4d..cf4dcf346ca8 100644
> --- a/arch/x86/entry/common.c
> +++ b/arch/x86/entry/common.c
> @@ -128,7 +128,8 @@ static noinstr bool __do_fast_syscall_32(struct pt_regs *regs)
>  		regs->ax = -EFAULT;
>  
>  		instrumentation_end();
> -		syscall_exit_to_user_mode(regs);
> +		local_irq_disable();
> +		exit_to_user_mode();
>  		return false;
>  	}

I'm confused, twice. Once by your Changelog, and second by the actual
patch. Shouldn't every return to userspace pass through
exit_to_user_mode_prepare() ? We shouldn't ignore NEED_RESCHED or
NOTIFY_RESUME, both of which can be set I think, even if the SYSCALL
didn't actually do anything.

  parent reply	other threads:[~2021-02-23 11:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-23  5:50 [PATCH 0/3] x86/entry: A compat syscall bugfix and some test stuff Andy Lutomirski
2021-02-23  5:50 ` [PATCH 1/3] entry: Check that syscall entries and syscall exits match Andy Lutomirski
2021-02-23  5:50 ` [PATCH 2/3] x86/entry: Fix entry/exit mismatch on failed fast 32-bit syscalls Andy Lutomirski
2021-02-23 10:24   ` Thomas Gleixner
2021-02-23 11:28   ` Peter Zijlstra [this message]
2021-02-23 15:35     ` Andy Lutomirski
2021-02-23  5:50 ` [PATCH 3/3] selftests/x86: Add a missing .note.GNU-stack section to thunks_32.S Andy Lutomirski

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=YDTm8Q/cvBcfzhPn@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.