From: Chris Wright Date: Fri, 12 Jan 2007 16:10:13 +0000 (-0800) Subject: Add Eric's fix for reparenting w/in thread group X-Git-Tag: v2.6.19.3~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0054f278825e76b0e2dcbbba91874d990dc11fe2;p=thirdparty%2Fkernel%2Fstable-queue.git Add Eric's fix for reparenting w/in thread group --- diff --git a/queue-2.6.19/fix-reparenting-to-the-same-thread-group.patch b/queue-2.6.19/fix-reparenting-to-the-same-thread-group.patch new file mode 100644 index 00000000000..ca396f00f56 --- /dev/null +++ b/queue-2.6.19/fix-reparenting-to-the-same-thread-group.patch @@ -0,0 +1,82 @@ +From b2b2cbc4b2a2f389442549399a993a8306420baf Mon Sep 17 00:00:00 2001 +From: Eric W. Biederman +Date: Thu, 21 Dec 2006 21:28:40 -0700 +Subject: [PATCH] Fix reparenting to the same thread group. (take 2) + +This patch fixes the case when we reparent to a different thread in the +same thread group. This modifies the code so that we do not send +signals and do not change the signal to send to SIGCHLD unless we have +change the thread group of our parents. It also suppresses sending +pdeath_sig in this cas as well since the result of geppid doesn't +change. + +Thanks to Oleg for spotting my bug of only fixing this for non-ptraced +tasks. + +Signed-off-by: Eric W. Biederman +Cc: Mike Galbraith +Cc: Albert Cahalan +Cc: Andrew Morton +Cc: Roland McGrath +Cc: Ingo Molnar +Cc: Coywolf Qi Hunt +Acked-by: Oleg Nesterov +Signed-off-by: Linus Torvalds +[chrisw: fold in 241ceee0b442, Oleg's fix to restore user visible behaviour] +Signed-off-by: Chris Wright +--- + kernel/exit.c | 29 ++++++++++++++++++----------- + 1 file changed, 18 insertions(+), 11 deletions(-) + +--- linux-2.6.19.2.orig/kernel/exit.c ++++ linux-2.6.19.2/kernel/exit.c +@@ -603,10 +603,6 @@ choose_new_parent(struct task_struct *p, + static void + reparent_thread(struct task_struct *p, struct task_struct *father, int traced) + { +- /* We don't want people slaying init. */ +- if (p->exit_signal != -1) +- p->exit_signal = SIGCHLD; +- + if (p->pdeath_signal) + /* We already hold the tasklist_lock here. */ + group_send_sig_info(p->pdeath_signal, SEND_SIG_NOINFO, p); +@@ -626,13 +622,7 @@ reparent_thread(struct task_struct *p, s + p->parent = p->real_parent; + add_parent(p); + +- /* If we'd notified the old parent about this child's death, +- * also notify the new parent. +- */ +- if (p->exit_state == EXIT_ZOMBIE && p->exit_signal != -1 && +- thread_group_empty(p)) +- do_notify_parent(p, p->exit_signal); +- else if (p->state == TASK_TRACED) { ++ if (p->state == TASK_TRACED) { + /* + * If it was at a trace stop, turn it into + * a normal stop since it's no longer being +@@ -642,6 +632,23 @@ reparent_thread(struct task_struct *p, s + } + } + ++ /* If this is a threaded reparent there is no need to ++ * notify anyone anything has happened. ++ */ ++ if (p->real_parent->group_leader == father->group_leader) ++ return; ++ ++ /* We don't want people slaying init. */ ++ if (p->exit_signal != -1) ++ p->exit_signal = SIGCHLD; ++ ++ /* If we'd notified the old parent about this child's death, ++ * also notify the new parent. ++ */ ++ if (!traced && p->exit_state == EXIT_ZOMBIE && ++ p->exit_signal != -1 && thread_group_empty(p)) ++ do_notify_parent(p, p->exit_signal); ++ + /* + * process group orphan check + * Case ii: Our child is in a different pgrp diff --git a/queue-2.6.19/series b/queue-2.6.19/series index 0f014c2e0b4..48aea6a8c2b 100644 --- a/queue-2.6.19/series +++ b/queue-2.6.19/series @@ -9,3 +9,4 @@ netfilter-tcp-conntrack-fix-ip_ct_tcp_flag_close_init-value.patch netfilter-arp_tables-fix-userspace-compilation.patch repair-snd-usb-usx2y-over-ohci.patch ib-mthca-fix-off-by-one-in-fmr-handling-on-memfree.patch +fix-reparenting-to-the-same-thread-group.patch