mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] file: Add locking to f_getown
@ 2006-09-10  4:11 Eric W. Biederman
  0 siblings, 0 replies; only message in thread
From: Eric W. Biederman @ 2006-09-10  4:11 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, Linux Containers, Oleg Nesterov


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>
---
 fs/fcntl.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/fs/fcntl.c b/fs/fcntl.c
index 821ebb9..b1dd4d4 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;
 }
 
-- 
1.4.2.rc3.g7e18e-dirty


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-09-10  4:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-10  4:11 [PATCH] file: Add locking to f_getown Eric W. Biederman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®