mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Will Drewry <wad@chromium.org>
To: linux-kernel@vger.kernel.org
Cc: mcgrathr@google.com, hpa@zytor.com, indan@nul.nu,
	netdev@parisplace.org, linux-security-module@vger.kernel.org,
	kernel-hardening@lists.openwall.com, mingo@redhat.com,
	oleg@redhat.com, peterz@infradead.org, rdunlap@xenotime.net,
	tglx@linutronix.de, luto@mit.edu, serge.hallyn@canonical.com,
	pmoore@redhat.com, akpm@linux-foundation.org, corbet@lwn.net,
	markus@chromium.org, coreyb@linux.vnet.ibm.com,
	keescook@chromium.org, viro@zeniv.linux.org.uk,
	jmorris@namei.org, Will Drewry <wad@chromium.org>
Subject: [RFC PATCH 2/3] arch/x86: move secure_computing after ptrace
Date: Thu, 24 May 2012 11:08:00 -0500	[thread overview]
Message-ID: <1337875681-20717-3-git-send-email-wad@chromium.org> (raw)
In-Reply-To: <1337875681-20717-1-git-send-email-wad@chromium.org>

At present, seccomp modes 1 and 2 may have their
behavior changed by a ptrace()ing task.  The ptracer
cannot change blocked/disallowed system calls, but it can
change allowed system calls to calls that would otherwise
not be allowed by the seccomp policy.

Signed-off-by: Will Drewry <wad@chromium.org>
---
 arch/x86/kernel/ptrace.c |   13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index 13b1990..ad649a6 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -1479,13 +1479,6 @@ long syscall_trace_enter(struct pt_regs *regs)
 	if (test_thread_flag(TIF_SINGLESTEP))
 		regs->flags |= X86_EFLAGS_TF;
 
-	/* do the secure computing check first */
-	if (secure_computing(regs->orig_ax)) {
-		/* seccomp failures shouldn't expose any additional code. */
-		ret = -1L;
-		goto out;
-	}
-
 	if (unlikely(test_thread_flag(TIF_SYSCALL_EMU)))
 		ret = -1L;
 
@@ -1493,6 +1486,12 @@ long syscall_trace_enter(struct pt_regs *regs)
 	    tracehook_report_syscall_entry(regs))
 		ret = -1L;
 
+	/* check secure computing after userspace can't change the syscall. */
+	if (!ret && secure_computing(regs->orig_ax)) {
+		ret = -1L;
+		goto out;
+	}
+
 	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
 		trace_sys_enter(regs, regs->orig_ax);
 
-- 
1.7.9.5


  parent reply	other threads:[~2012-05-24 16:08 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-21 18:21 seccomp and ptrace. what is the correct order? Eric Paris
2012-05-21 18:25 ` Roland McGrath
2012-05-21 19:20   ` Indan Zupancic
2012-05-22 16:23     ` Will Drewry
2012-05-22 16:26       ` Will Drewry
2012-05-22 17:39       ` Al Viro
2012-05-22 20:26         ` Will Drewry
2012-05-22 20:34           ` H. Peter Anvin
2012-05-22 20:48             ` Will Drewry
2012-05-22 21:07               ` Al Viro
2012-05-22 21:17                 ` Roland McGrath
2012-05-22 21:18                   ` H. Peter Anvin
2012-05-22 22:20                   ` Al Viro
2012-05-22 21:09               ` H. Peter Anvin
2012-05-22 21:14                 ` Will Drewry
2012-05-22 21:37                   ` H. Peter Anvin
2012-05-24 16:07         ` [RFC PATCH 0/3] move the secure_computing call Will Drewry
2012-05-24 16:07           ` [RFC PATCH 1/3] seccomp: Don't allow tracers to abuse RET_TRACE Will Drewry
2012-05-24 17:54             ` Indan Zupancic
2012-05-24 18:24               ` Will Drewry
2012-05-24 20:17                 ` Indan Zupancic
2012-05-24 16:08           ` Will Drewry [this message]
2012-05-24 16:08           ` [RFC PATCH 3/3] arch/*: move secure_computing after trace Will Drewry
2012-05-24 16:13           ` [RFC PATCH 0/3] move the secure_computing call H. Peter Anvin
2012-05-24 18:07             ` Roland McGrath
2012-05-24 18:27               ` Indan Zupancic
2012-05-24 18:45                 ` H. Peter Anvin
2012-05-24 19:39                   ` Indan Zupancic
2012-05-24 22:00           ` Andrew Morton
2012-05-25  1:55             ` Will Drewry
2012-05-24 23:40           ` James Morris
2012-05-24 23:43             ` Andrew Lutomirski
2012-05-24 23:56               ` H. Peter Anvin
2012-05-25  0:26                 ` Andrew Lutomirski
2012-05-25  0:38                   ` H. Peter Anvin
2012-05-25  0:55                     ` Andrew Lutomirski
2012-05-21 18:47 ` seccomp and ptrace. what is the correct order? richard -rw- weinberger
2012-05-21 19:13   ` H. Peter Anvin

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=1337875681-20717-3-git-send-email-wad@chromium.org \
    --to=wad@chromium.org \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=coreyb@linux.vnet.ibm.com \
    --cc=hpa@zytor.com \
    --cc=indan@nul.nu \
    --cc=jmorris@namei.org \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=luto@mit.edu \
    --cc=markus@chromium.org \
    --cc=mcgrathr@google.com \
    --cc=mingo@redhat.com \
    --cc=netdev@parisplace.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=pmoore@redhat.com \
    --cc=rdunlap@xenotime.net \
    --cc=serge.hallyn@canonical.com \
    --cc=tglx@linutronix.de \
    --cc=viro@zeniv.linux.org.uk \
    /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

all inboxes | Powered by JetHome®