Re: 2.6.0-test9 and sleeping function called from invalid context

From: Manfred Spraul
Date: Sun Oct 26 2003 - 06:06:12 EST


Andrew Morton wrote:

What protects against concurrent execution of proc_pid_lookup() and
proc_task_lookup()? I think nothing, because one is at /proc/42 and the
other is at /proc/41/42; the parent dir inodes are different. hmm.


Ugs.
/proc/1 and /proc/1/task/1 are two different dentrys.
proc_task_lookup happily overwrites task->proc_dentry. Which means the task patch broke tsk->proc_dentry.
I think the cure is simple: proc_task_lookup should not write proc_dentry, only proc_pid_lookup should do that.
tsk->proc_dentry is only used by proc_pid_flush: If a task exits, all entries below /proc/<pid> are stale, and a shrink_dcache_parent on the /proc/<pid> dentry recovers the memory.
There is a race between in proc_pid_lookup between checking that the task is still running and setting tsk->proc_dentry, but AFAICS the race is not critical: In the worst case, the stale dentries remain around. They are never returned to user space, d_revalidate prevents that.

--
Manfred


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/