Skip to content

Commit 2dfded8

Browse files
committed
Merge tag 'locks-v3.16-2' of git://git.samba.org/jlayton/linux
Pull file locking fixes from Jeff Layton: "File locking related bugfixes Nothing too earth-shattering here. A fix for a potential regression due to a patch in pile #1, and the addition of a memory barrier to prevent a race condition between break_deleg and generic_add_lease" * tag 'locks-v3.16-2' of git://git.samba.org/jlayton/linux: locks: set fl_owner for leases back to current->files locks: add missing memory barrier in break_deleg
2 parents 532f513 + 0c27362 commit 2dfded8

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

fs/locks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ static int lease_init(struct file *filp, long type, struct file_lock *fl)
431431
if (assign_type(fl, type) != 0)
432432
return -EINVAL;
433433

434-
fl->fl_owner = (fl_owner_t)filp;
434+
fl->fl_owner = (fl_owner_t)current->files;
435435
fl->fl_pid = current->tgid;
436436

437437
fl->fl_file = filp;

include/linux/fs.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,6 +1921,12 @@ static inline int break_lease(struct inode *inode, unsigned int mode)
19211921

19221922
static inline int break_deleg(struct inode *inode, unsigned int mode)
19231923
{
1924+
/*
1925+
* Since this check is lockless, we must ensure that any refcounts
1926+
* taken are done before checking inode->i_flock. Otherwise, we could
1927+
* end up racing with tasks trying to set a new lease on this file.
1928+
*/
1929+
smp_mb();
19241930
if (inode->i_flock)
19251931
return __break_lease(inode, mode, FL_DELEG);
19261932
return 0;

0 commit comments

Comments
 (0)