Skip to contentSkip to conversation

Is this racy?

DISCUSSION Michal Jaegermann 2 participants 2 messages Oct 7, 2002

lore
Share & tools
lore
#0 lore raw

In fs/proc/array.c (2.4.20-pre9, 2.4.19 and likely many other versions) in function 'proc_pid_stat()' there is a code like that:

	......
	read_lock(&tasklist_lock);
	ppid = task->pid ? task->p_opptr->pid : 0;
	read_unlock(&tasklist_lock);
	res = sprintf(buffer,"<long format string>",
		task->pid,
		......
		ppid,
		......

So assignment to ppid is locked but other reads from fiels of 'task' structure are not guarded that way. Is this ok or if not we do not particularly care? Function 'task_state()' in the same file seems to be more careful about this.

Michal

#1 lore raw
Quoted 13 lines · Michal Jaegermann

In fs/proc/array.c (2.4.20-pre9, 2.4.19 and likely many other versions) in function 'proc_pid_stat()' there is a code like that:

	......
	read_lock(&tasklist_lock);
	ppid = task->pid ? task->p_opptr->pid : 0;
	read_unlock(&tasklist_lock);
	res = sprintf(buffer,"<long format string>",
		task->pid,
		......
		ppid,
		......
Quoted 4 lines

So assignment to ppid is locked but other reads from fiels of 'task' structure are not guarded that way. Is this ok or if not we do not particularly care? Function 'task_state()' in the same file seems to be more careful about this.

I think the lock is just so that p_opptr->pid doesn't change while we're looking at it.

Signature · 2 lines
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer