From: Eric W. Biederman Date: Mon, 2 Oct 2006 09:17:27 +0000 (-0700) Subject: [PATCH] file: Add locking to f_getown X-Git-Tag: v2.6.19-rc1~463 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43fa1adb9334bf4585cd53144eb5911488f85bc7;p=linux-2.6 [PATCH] file: Add locking to f_getown 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 Cc: Oleg Nesterov Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/fs/fcntl.c b/fs/fcntl.c index e7c66a1bf8..e4f26165f1 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -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; }