summaryrefslogtreecommitdiffstats
path: root/fs/locks.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@poochiereds.net>2014-05-09 14:13:04 -0400
committerJeff Layton <jlayton@poochiereds.net>2014-06-02 08:09:29 -0400
commit130d1f956ab367bab855336279afa3b19acdc9a1 (patch)
tree8372682ec959aa89df1d280e93c3ab8119801dea /fs/locks.c
parentcf01f4eef9fe367ec0d85b38dd7214e29e376cdb (diff)
downloadlinux-130d1f956ab367bab855336279afa3b19acdc9a1.tar.gz
linux-130d1f956ab367bab855336279afa3b19acdc9a1.tar.bz2
linux-130d1f956ab367bab855336279afa3b19acdc9a1.zip
locks: ensure that fl_owner is always initialized properly in flock and lease codepaths
Currently, the fl_owner isn't set for flock locks. Some filesystems use byte-range locks to simulate flock locks and there is a common idiom in those that does: fl->fl_owner = (fl_owner_t)filp; fl->fl_start = 0; fl->fl_end = OFFSET_MAX; Since flock locks are generally "owned" by the open file description, move this into the common flock lock setup code. The fl_start and fl_end fields are already set appropriately, so remove the unneeded setting of that in flock ops in those filesystems as well. Finally, the lease code also sets the fl_owner as if they were owned by the process and not the open file description. This is incorrect as leases have the same ownership semantics as flock locks. Set them the same way. The lease code doesn't actually use the fl_owner value for anything, so this is more for consistency's sake than a bugfix. Reported-by: Trond Myklebust <trond.myklebust@primarydata.com> Signed-off-by: Jeff Layton <jlayton@poochiereds.net> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (Staging portion) Acked-by: J. Bruce Fields <bfields@fieldses.org>
Diffstat (limited to 'fs/locks.c')
-rw-r--r--fs/locks.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/locks.c b/fs/locks.c
index e390bd9ae068..77aff897fef3 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -322,6 +322,7 @@ static int flock_make_lock(struct file *filp, struct file_lock **lock,
return -ENOMEM;
fl->fl_file = filp;
+ fl->fl_owner = (fl_owner_t)filp;
fl->fl_pid = current->tgid;
fl->fl_flags = FL_FLOCK;
fl->fl_type = type;
@@ -427,7 +428,7 @@ static int lease_init(struct file *filp, long type, struct file_lock *fl)
if (assign_type(fl, type) != 0)
return -EINVAL;
- fl->fl_owner = current->files;
+ fl->fl_owner = (fl_owner_t)filp;
fl->fl_pid = current->tgid;
fl->fl_file = filp;
@@ -2316,6 +2317,7 @@ void locks_remove_file(struct file *filp)
if (filp->f_op->flock) {
struct file_lock fl = {
+ .fl_owner = (fl_owner_t)filp,
.fl_pid = current->tgid,
.fl_file = filp,
.fl_flags = FL_FLOCK,