OpenVZ Forum


Home » Mailing lists » Devel » [PATCH] file: Add locking to f_getown
[PATCH] file: Add locking to f_getown [message #16649] Sun, 10 September 2006 04:11
ebiederm is currently offline  ebiederm
Messages: 1354
Registered: February 2006
Senior Member
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

_______________________________________________
Containers mailing list
Containers@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/containers
Previous Topic: Re: pspace name
Next Topic: [PATCH] vt: Rework the console spawning variables.
Goto Forum:
  


Current Time: Sun Oct 12 23:30:26 GMT 2025

Total time taken to generate the page: 0.13069 seconds