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

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


What about the attached patch?

The lifetime of dentries is quite long, thus I'd prefer if the race between proc_pid_lookup and sys_exit is closed.

--
Manfred

--- 2.6/fs/proc/base.c 2003-10-09 21:23:15.000000000 +0200
+++ build-2.6/fs/proc/base.c 2003-10-26 16:25:24.000000000 +0100
@@ -1524,6 +1524,7 @@
struct inode *inode;
struct proc_inode *ei;
unsigned tgid;
+ int died;

if (dentry->d_name.len == 4 && !memcmp(dentry->d_name.name,"self",4)) {
inode = new_inode(dir->i_sb);
@@ -1567,12 +1568,21 @@

dentry->d_op = &pid_base_dentry_operations;

+ died = 0;
+ d_add(dentry, inode);
spin_lock(&task->proc_lock);
task->proc_dentry = dentry;
- d_add(dentry, inode);
+ if (!pid_alive(task)) {
+ dentry = proc_pid_unhash(task);
+ died = 1;
+ }
spin_unlock(&task->proc_lock);

put_task_struct(task);
+ if (died) {
+ proc_pid_flush(dentry);
+ goto out;
+ }
return NULL;
out:
return ERR_PTR(-ENOENT);
@@ -1612,10 +1622,7 @@

dentry->d_op = &pid_base_dentry_operations;

- spin_lock(&task->proc_lock);
- task->proc_dentry = dentry;
d_add(dentry, inode);
- spin_unlock(&task->proc_lock);

put_task_struct(task);
return NULL;