Skip to contentSkip to conversation

setpgid(child) fails if the child was forked by sub-thread

PATCH In review Oleg Nesterov 3 participants 5 messages Aug 22, 2007 – Aug 23, 2007 2 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]/

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

PATCH 1/1 setpgid(child) fails if the child was forked by sub-thread

Spotted by Marcin Kowalczyk <[email protected]>.

sys_setpgid(child) fails if the child was forked by sub-thread.

Fix the "is it our child" check. The previous commit ee0acf90d320c29916ba8c5c1b2e908d81f5057d was not complete.

(this patch asks for the new same_thread_group() helper, but mainline doesn't
have it yet).

kernel/sys.c renamed from kernel/sys.c~SETPGID +1 -2
@@ -1442,7 +1442,6 @@ asmlinkage long sys_times(struct tms __u
  * Auch. Had to add the 'did_exec' flag to conform completely to POSIX.
  * LBT 04.03.94
  */
-
 asmlinkage long sys_setpgid(pid_t pid, pid_t pgid)
 {
 	struct task_struct *p;
@@ -1470,7 +1469,7 @@ asmlinkage long sys_setpgid(pid_t pid, p
 	if (!thread_group_leader(p))
 		goto out;
 
-	if (p->real_parent == group_leader) {
+	if (p->real_parent->tgid == group_leader->tgid) {
 		err = -EPERM;
 		if (task_session(p) != task_session(group_leader))
 			goto out;
#3 lore raw

On Wed, 22 Aug 2007 20:55:39 +0400 Oleg Nesterov wrote:

so "fixes http://bugzilla.kernel.org/show_bug.cgi?id=8921" ??

Quoted 23 lines

Spotted by Marcin Kowalczyk <[email protected]>.

sys_setpgid(child) fails if the child was forked by sub-thread.

Fix the "is it our child" check. The previous commit ee0acf90d320c29916ba8c5c1b2e908d81f5057d was not complete.

(this patch asks for the new same_thread_group() helper, but mainline doesn't
have it yet).

kernel/sys.c renamed from kernel/sys.c~SETPGID +0 -1
@@ -1442,7 +1442,6 @@ asmlinkage long sys_times(struct tms __u
  * Auch. Had to add the 'did_exec' flag to conform completely to POSIX.
  * LBT 04.03.94
  */
-
 asmlinkage long sys_setpgid(pid_t pid, pid_t pgid)
 {
 	struct task_struct *p;

kernel/sys.c asmlinkage long sys_setpgid(pid_t pid, p

Quoted 10 lines
kernel/sys.c renamed from kernel/sys.c~SETPGID +1 -2
@@ -1470,7 +1469,7 @@ asmlinkage long sys_setpgid(pid_t pid, p
 	if (!thread_group_leader(p))
 		goto out;
 
-	if (p->real_parent == group_leader) {
+	if (p->real_parent->tgid == group_leader->tgid) {
 		err = -EPERM;
 		if (task_session(p) != task_session(group_leader))
 			goto out;
 
-

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

#5 lore raw
Quoted 8 lines · On Wed, 22 Aug 2007 21:24:36 +0400 Oleg Nesterov wrote:
Quoted 5 lines · Randy Dunlap

On Wed, 22 Aug 2007 20:55:39 +0400 Oleg Nesterov wrote:

so "fixes http://bugzilla.kernel.org/show_bug.cgi?id=8921" ??

Hopefully yes... should I add some note at /bugzilla.kernel.org?

I think that it can wait until Marcin confirms that it's fixed (if he does so soon), then mark 8921 as fixed.

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

#6 lore raw

Dnia 22-08-2007, Śr o godzinie 10:30 -0700, Randy Dunlap napisał(a):

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

so "fixes http://bugzilla.kernel.org/show_bug.cgi?id=8921" ??

Hopefully yes... should I add some note at /bugzilla.kernel.org?

I think that it can wait until Marcin confirms that it's fixed (if he does so soon), then mark 8921 as fixed.

Yes, it's fixed. Thank you!

Signature · 3 lines
   __("<         Marcin Kowalczyk
   \__/       [email protected]
    ^^     http://qrnik.knm.org.pl/~qrczak/