mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Will Drewry <wad@chromium.org>
To: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org
Cc: fengxj325@gmail.com, eparis@redhat.com, keescook@chromium.org,
	james.l.morris@oracle.com, hpa@zytor.com, cevans@chromium.org,
	luto@mit.edu, rob@landley.net, linux-doc@vger.kernel.org,
	Will Drewry <wad@chromium.org>
Subject: [PATCH 2/3] vsyscall_64: allow SECCOMP_RET_TRACErs to skip
Date: Sat, 14 Jul 2012 10:32:53 -0500	[thread overview]
Message-ID: <1342279974-26917-2-git-send-email-wad@chromium.org> (raw)
In-Reply-To: <1342279974-26917-1-git-send-email-wad@chromium.org>

Current quirky ptrace behavior with vsyscall and seccomp
does not allow tracers to bypass the call.  This change
provides that ability by checking if orig_ax changed.

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

diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
index 5db36ca..5f9640c 100644
--- a/arch/x86/kernel/vsyscall_64.c
+++ b/arch/x86/kernel/vsyscall_64.c
@@ -142,11 +142,15 @@ static int addr_to_vsyscall_nr(unsigned long addr)
 #ifdef CONFIG_SECCOMP
 static int vsyscall_seccomp(struct task_struct *tsk, int syscall_nr)
 {
+	int ret;
 	if (!seccomp_mode(&tsk->seccomp))
 		return 0;
 	task_pt_regs(tsk)->orig_ax = syscall_nr;
 	task_pt_regs(tsk)->ax = syscall_nr;
-	return __secure_computing(syscall_nr);
+	ret = __secure_computing(syscall_nr);
+	if (task_pt_regs(tsk)->orig_ax != syscall_nr)
+		return 1; /* ptrace syscall skip */
+	return ret;
 }
 #else
 #define vsyscall_seccomp(_tsk, _nr) 0
@@ -278,9 +282,9 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)
 	current_thread_info()->sig_on_uaccess_error = prev_sig_on_uaccess_error;
 
 	if (skip) {
-		if ((long)regs->ax <= 0L) /* seccomp errno emulation */
+		if ((long)regs->ax <= 0L || skip == 1) /* seccomp errno/trace */
 			goto do_ret;
-		goto done; /* seccomp trace/trap */
+		goto done; /* seccomp trap */
 	}
 
 	if (ret == -EFAULT) {
-- 
1.7.9.5


  reply	other threads:[~2012-07-14 15:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-14 15:32 [PATCH 1/3] vsyscall_64: add missing ifdef CONFIG_SECCOMP Will Drewry
2012-07-14 15:32 ` Will Drewry [this message]
     [not found]   ` <CAObL_7GX0q_qywY4g1S2iRZWPS95ar01wtvv9wDW=zswwaZ6fQ@mail.gmail.com>
2012-07-14 15:50     ` [PATCH 2/3] vsyscall_64: allow SECCOMP_RET_TRACErs to skip Will Drewry
2012-07-14 15:57       ` Will Drewry
2012-07-14 16:15         ` Andrew Lutomirski
2012-07-14 16:21           ` Andrew Lutomirski
2012-07-14 16:55             ` Will Drewry
2012-08-10  9:14               ` James Morris
2012-08-13 18:17                 ` Andrew Lutomirski
2012-07-14 15:32 ` [PATCH 3/3] Documentation: add a caveat for seccomp filter and vsyscall emulation Will Drewry

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=1342279974-26917-2-git-send-email-wad@chromium.org \
    --to=wad@chromium.org \
    --cc=cevans@chromium.org \
    --cc=eparis@redhat.com \
    --cc=fengxj325@gmail.com \
    --cc=hpa@zytor.com \
    --cc=james.l.morris@oracle.com \
    --cc=keescook@chromium.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@mit.edu \
    --cc=rob@landley.net \
    --cc=torvalds@linux-foundation.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

all inboxes | Powered by JetHome®