We definitely have a race between d_kill setting dentry->d_inode = NULL
and proc_sys_compare reading d_inode.
We don't generate negative dentries for /proc/sys.
In dput atomic_dec_and_lock takes the lock before setting the count to 0.
So there is no race there.
Testing for d_unhashed and getting us out of rcu limbo before calling
into the filesystem methods makes the reasoning a lot clearer.
Looks good to me.
Reviewed-by: "Eric W. Biederman" <ebiederm@xmission.com>
--