linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "tip-bot2 for Thomas Gleixner" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Kyle Huey <me@kylehuey.com>, Thomas Gleixner <tglx@linutronix.de>,
	Kees Cook <keescook@chromium.org>, x86 <x86@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [tip: core/urgent] core/entry: Respect syscall number rewrites
Date: Fri, 21 Aug 2020 14:21:41 -0000	[thread overview]
Message-ID: <159801970100.3192.5947326764367261896.tip-bot2@tip-bot2> (raw)
In-Reply-To: <87blj6ifo8.fsf@nanos.tec.linutronix.de>

The following commit has been merged into the core/urgent branch of tip:

Commit-ID:     d88d59b64ca35abae208e2781fdb45e69cbed56c
Gitweb:        https://git.kernel.org/tip/d88d59b64ca35abae208e2781fdb45e69cbed56c
Author:        Thomas Gleixner <tglx@linutronix.de>
AuthorDate:    Wed, 19 Aug 2020 21:44:39 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 21 Aug 2020 16:17:29 +02:00

core/entry: Respect syscall number rewrites

The transcript of the x86 entry code to the generic version failed to
reload the syscall number from ptregs after ptrace and seccomp have run,
which both can modify the syscall number in ptregs. It returns the original
syscall number instead which is obviously not the right thing to do.

Reload the syscall number to fix that.

Fixes: 142781e108b1 ("entry: Provide generic syscall entry functionality")
Reported-by: Kyle Huey <me@kylehuey.com> 
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Kyle Huey <me@kylehuey.com> 
Tested-by: Kees Cook <keescook@chromium.org>
Acked-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/87blj6ifo8.fsf@nanos.tec.linutronix.de

---
 kernel/entry/common.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/entry/common.c b/kernel/entry/common.c
index 9852e0d..fcae019 100644
--- a/kernel/entry/common.c
+++ b/kernel/entry/common.c
@@ -65,7 +65,8 @@ static long syscall_trace_enter(struct pt_regs *regs, long syscall,
 
 	syscall_enter_audit(regs, syscall);
 
-	return ret ? : syscall;
+	/* The above might have changed the syscall number */
+	return ret ? : syscall_get_nr(current, regs);
 }
 
 noinstr long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall)

  parent reply	other threads:[~2020-08-21 14:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-19 17:14 [REGRESSION] x86/entry: Tracer no longer has opportunity to change the syscall number at entry via orig_ax Kyle Huey
2020-08-19 19:44 ` Thomas Gleixner
2020-08-20 17:26   ` Kyle Huey
2020-08-20 21:09   ` Kees Cook
2020-08-21  0:35     ` Thomas Gleixner
2020-08-21 14:21   ` tip-bot2 for Thomas Gleixner [this message]
     [not found]   ` <87a6xzrr89.fsf@mpe.ellerman.id.au>
2020-09-11 18:58     ` Kees Cook
2020-09-12  0:10     ` Kees Cook
2020-09-13  7:44       ` Michael Ellerman
2020-09-13 18:27         ` Thomas Gleixner
2020-09-14 20:04           ` Kees Cook
2020-09-17  0:39             ` Michael Ellerman

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=159801970100.3192.5947326764367261896.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=me@kylehuey.com \
    --cc=tglx@linutronix.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).