Skip to contentSkip to conversation

Prevent reuse of active thread group id

PATCH In review Dave McCracken 2 participants 2 messages Aug 20, 2001

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Prevent reuse of active thread group id

The thread group id of a task is initially assigned the value of that task's pid, then is inherited for each child task created with CLONE_THREAD. This patch makes sure that the thread group id is never re-used as another task's pid as long as there's an active task with that tgid.

Patch is below.

Dave McCracken

======================================================================
Dave McCracken IBM Linux Base Kernel Team 1-512-838-3059
[email protected] T/L 678-3059

====================

./kernel/fork.c +0 -0
@@ -101,6 +101,7 @@
		for_each_task(p) {
			if(p->pid == last_pid	||
			   p->pgrp == last_pid	||
+			   p->tgid == last_pid	||
			   p->session == last_pid) {
				if(++last_pid >= next_safe) {
					if(last_pid & 0xffff8000)
#1 lore raw
Quoted 5 lines

The thread group id of a task is initially assigned the value of that task's pid, then is inherited for each child task created with CLONE_THREAD. This patch makes sure that the thread group id is never re-used as another task's pid as long as there's an active task with that tgid.

Looks a sensible precaution, otherwise a kill might go to very wrong places. I'll apply it