All of lore.kernel.org
 help / color / mirror / Atom feed
From: akpm@linux-foundation.org
To: tj@kernel.org, oleg@redhat.com, roland@redhat.com,
	stable@kernel.org, mm-commits@vger.kernel.org
Subject: [merged] ptrace-use-safer-wake-up-on-ptrace_detach.patch removed from -mm tree
Date: Mon, 14 Feb 2011 12:19:20 -0800	[thread overview]
Message-ID: <201102142019.p1EKJKrp022980@imap1.linux-foundation.org> (raw)


The patch titled
     ptrace: use safer wake up on ptrace_detach()
has been removed from the -mm tree.  Its filename was
     ptrace-use-safer-wake-up-on-ptrace_detach.patch

This patch was dropped because it was merged into mainline or a subsystem tree

The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/

------------------------------------------------------
Subject: ptrace: use safer wake up on ptrace_detach()
From: Tejun Heo <tj@kernel.org>

The wake_up_process() call in ptrace_detach() is spurious and not
interlocked with the tracee state.  IOW, the tracee could be running or
sleeping in any place in the kernel by the time wake_up_process() is
called.  This can lead to the tracee waking up unexpectedly which can be
dangerous.

The wake_up is spurious and should be removed but for now reduce its
toxicity by only waking up if the tracee is in TRACED or STOPPED state.

This bug can possibly be used as an attack vector.  I don't think it will
take too much effort to come up with an attack which triggers oops
somewhere.  Most sleeps are wrapped in condition test loops and should be
safe but we have quite a number of places where sleep and wakeup
conditions are expected to be interlocked.  Although the window of
opportunity is tiny, ptrace can be used by non-privileged users and with
some loading the window can definitely be extended and exploited.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Roland McGrath <roland@redhat.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 kernel/ptrace.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN kernel/ptrace.c~ptrace-use-safer-wake-up-on-ptrace_detach kernel/ptrace.c
--- a/kernel/ptrace.c~ptrace-use-safer-wake-up-on-ptrace_detach
+++ a/kernel/ptrace.c
@@ -313,7 +313,7 @@ int ptrace_detach(struct task_struct *ch
 		child->exit_code = data;
 		dead = __ptrace_detach(current, child);
 		if (!child->exit_state)
-			wake_up_process(child);
+			wake_up_state(child, TASK_TRACED | TASK_STOPPED);
 	}
 	write_unlock_irq(&tasklist_lock);
 
_

Patches currently in -mm which might be from tj@kernel.org are

origin.patch
linux-next.patch
mm-numa-aware-alloc_task_struct_node.patch
mm-numa-aware-alloc_thread_info_node.patch
kthread-numa-aware-kthread_create_on_cpu.patch
kthread-use-kthread_create_on_cpu.patch
smp-move-smp-setup-functions-to-kernel-smpc.patch
scatterlist-new-helper-functions.patch
fs-devpts_pty_new-return-enomem-if-dentry-allocation-failed.patch


                 reply	other threads:[~2011-02-14 20:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=201102142019.p1EKJKrp022980@imap1.linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mm-commits@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=roland@redhat.com \
    --cc=stable@kernel.org \
    --cc=tj@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.