public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Roland McGrath <roland@redhat.com>
Cc: Jeff Dike <jdike@addtoit.com>,
	utrace-devel@redhat.com, linux-kernel@vger.kernel.org
Subject: [RFC, PATCH 0/2] utrace/ptrace: simplify/cleanup ptrace attach
Date: Sun, 3 May 2009 20:55:37 +0200	[thread overview]
Message-ID: <20090503185537.GA17071@redhat.com> (raw)

Shouldn't be applied without Roland's ack.

I just don't know how to merge the second patch properly. I think it would be
really nice to cleanup ptrace attach before "ptracee data structures cleanup",
but this depends on utrace-core.patch which adds exclude_ptrace().

With the first patch, the second one (and hopefully the further cleanups) does
not depend on utrace.

Or, we can start with something like the patch below. Or, instead we can move
the "already traced" check into exclude_ptrace, this way only this helper will
depend on utrace changes. But personally I'd prefer to remove exclude_ptrace()
for now and add the correct checks later.

Roland, what do you think?

Oleg.

--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -190,6 +190,9 @@ int ptrace_attach(struct task_struct *ta
 
 	audit_ptrace(task);
 
+	if (exclude_ptrace(task))
+		return -EBUSY;
+
 	retval = -EPERM;
 	if (same_thread_group(task, current))
 		goto out;
@@ -221,11 +224,6 @@ repeat:
 		goto repeat;
 	}
 
-	if (exclude_ptrace(task)) {
-		retval = -EBUSY;
-		goto bad;
-	}
-
 	if (!task->mm)
 		goto bad;
 	/* the same process cannot be attached many times */
@@ -597,14 +595,14 @@ int ptrace_traceme(void)
 {
 	int ret = -EPERM;
 
+	if (exclude_ptrace(current))
+		return -EBUSY;
 	/*
 	 * Are we already being traced?
 	 */
 repeat:
 	task_lock(current);
-	if (exclude_ptrace(current)) {
-		ret = -EBUSY;
-	} else if (!(current->ptrace & PT_PTRACED)) {
+	if (!(current->ptrace & PT_PTRACED)) {
 		/*
 		 * See ptrace_attach() comments about the locking here.
 		 */


             reply	other threads:[~2009-05-03 19:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-03 18:55 Oleg Nesterov [this message]
2009-05-04 18:49 ` [RFC, PATCH 0/2] utrace/ptrace: simplify/cleanup ptrace attach Roland McGrath
2009-05-04 19:30   ` Oleg Nesterov
2009-05-04 19:43     ` Roland McGrath
2009-05-04 23:31       ` Andrew Morton
2009-05-05  1:12         ` Roland McGrath
2009-05-05 23:06         ` Oleg Nesterov
2009-05-06  8:12           ` Ingo Molnar
2009-05-06  8:23             ` Christoph Hellwig
2009-05-06  9:05               ` Ingo Molnar
2009-05-06  9:11                 ` Christoph Hellwig
2009-05-06  9:37                   ` Ingo Molnar
2009-05-07  6:13                     ` Roland McGrath
2009-05-08 15:08                       ` Ingo Molnar

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=20090503185537.GA17071@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=jdike@addtoit.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=roland@redhat.com \
    --cc=utrace-devel@redhat.com \
    /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