]> err.no Git - linux-2.6/commitdiff
[PATCH] file: Add locking to f_getown
authorEric W. Biederman <ebiederm@xmission.com>
Mon, 2 Oct 2006 09:17:27 +0000 (02:17 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 2 Oct 2006 14:57:15 +0000 (07:57 -0700)
This has been needed for a long time, but now with the advent of a
reference counted struct pid there are real consequences for getting this
wrong.

Someone I think it was Oleg Nesterov pointed out that this construct was
missing locking, when I introduced struct pid.  After taking time to review
the locking construct already present I figured out which lock needs to be
taken.  The other paths that access f_owner.pid take either the f_owner
read or the write lock.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/fcntl.c

index e7c66a1bf8310e4728e9560cf4b16688042fc697..e4f26165f12a22567526a74d2f463aa6d6798547 100644 (file)
@@ -305,9 +305,11 @@ void f_delown(struct file *filp)
 pid_t f_getown(struct file *filp)
 {
        pid_t pid;
+       read_lock(&filp->f_owner.lock);
        pid = pid_nr(filp->f_owner.pid);
        if (filp->f_owner.pid_type == PIDTYPE_PGID)
                pid = -pid;
+       read_unlock(&filp->f_owner.lock);
        return pid;
 }