From: Oleg Nesterov <oleg@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
Roland McGrath <roland@redhat.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 4/4] forget_original_parent: cleanup ptrace pathes
Date: Thu, 29 Jan 2009 09:06:03 +0100 [thread overview]
Message-ID: <20090129080603.GA26882@redhat.com> (raw)
No functional changes.
- Fold ptrace_exit() into forget_original_parent(), it is trivial
now. More importantly, this makes the code more symmetrical with
reparent_thread().
- The same for ptrace_exit_finish(), and "ptrace_" is not correct
any longer.
- "ptrace_dead" doesn't match the reality, rename to "dead_list".
- swap the reparent_thread()'s arguments, just to make it more
symmetrical with __ptrace_detach().
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
--- 6.29-rc3/kernel/exit.c~8_CLEANUP 2009-01-29 08:03:18.000000000 +0100
+++ 6.29-rc3/kernel/exit.c 2009-01-29 08:54:14.000000000 +0100
@@ -770,42 +770,8 @@ int __ptrace_detach(struct task_struct *
return 1;
}
-/*
- * Detach all tasks we were using ptrace on.
- * Any that need to be release_task'd are put on the @dead list.
- *
- * Called with write_lock(&tasklist_lock) held.
- */
-static void ptrace_exit(struct task_struct *parent, struct list_head *dead)
-{
- struct task_struct *p, *n;
-
- list_for_each_entry_safe(p, n, &parent->ptraced, ptrace_entry) {
- if (__ptrace_detach(parent, p))
- list_add(&p->ptrace_entry, dead);
- }
-}
-
-/*
- * Finish up exit-time ptrace cleanup.
- *
- * Called without locks.
- */
-static void ptrace_exit_finish(struct task_struct *parent,
- struct list_head *dead)
-{
- struct task_struct *p, *n;
-
- BUG_ON(!list_empty(&parent->ptraced));
-
- list_for_each_entry_safe(p, n, dead, ptrace_entry) {
- list_del_init(&p->ptrace_entry);
- release_task(p);
- }
-}
-
/* Returns nonzero if the child should be released. */
-static int reparent_thread(struct task_struct *p, struct task_struct *father)
+static int reparent_thread(struct task_struct *father, struct task_struct *p)
{
int dead;
@@ -886,14 +852,17 @@ static struct task_struct *find_new_reap
static void forget_original_parent(struct task_struct *father)
{
struct task_struct *p, *n, *reaper;
- LIST_HEAD(ptrace_dead);
+ LIST_HEAD(dead_list);
write_lock_irq(&tasklist_lock);
reaper = find_new_reaper(father);
/*
* First clean up ptrace if we were using it.
*/
- ptrace_exit(father, &ptrace_dead);
+ list_for_each_entry_safe(p, n, &father->ptraced, ptrace_entry) {
+ if (__ptrace_detach(father, p))
+ list_add(&p->ptrace_entry, &dead_list);
+ }
list_for_each_entry_safe(p, n, &father->children, sibling) {
p->real_parent = reaper;
@@ -901,14 +870,18 @@ static void forget_original_parent(struc
BUG_ON(p->ptrace);
p->parent = p->real_parent;
}
- if (reparent_thread(p, father))
- list_add(&p->ptrace_entry, &ptrace_dead);;
+ if (reparent_thread(father, p))
+ list_add(&p->ptrace_entry, &dead_list);;
}
-
write_unlock_irq(&tasklist_lock);
+
BUG_ON(!list_empty(&father->children));
+ BUG_ON(!list_empty(&father->ptraced));
- ptrace_exit_finish(father, &ptrace_dead);
+ list_for_each_entry_safe(p, n, &dead_list, ptrace_entry) {
+ list_del_init(&p->ptrace_entry);
+ release_task(p);
+ }
}
/*
next reply other threads:[~2009-01-29 8:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-29 8:06 Oleg Nesterov [this message]
2009-02-05 2:40 ` [PATCH 4/4] forget_original_parent: cleanup ptrace pathes Roland McGrath
2009-02-05 15:33 ` Oleg Nesterov
2009-02-09 2:36 ` Roland McGrath
2009-02-10 22:47 ` Oleg Nesterov
2009-02-10 23:23 ` Roland McGrath
2009-02-10 23:40 ` Oleg Nesterov
2009-02-10 23:53 ` Roland McGrath
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=20090129080603.GA26882@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=roland@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 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.