diff options
author | Jeff Layton <jlayton@redhat.com> | 2014-02-03 12:13:06 -0500 |
---|---|---|
committer | Jeff Layton <jlayton@redhat.com> | 2014-03-31 08:24:42 -0400 |
commit | 24cbe7845ea50b636ab2218b9d648270ff55f148 (patch) | |
tree | 89769bf1271ff804c830d0ba7898294a5762b7a6 /Makefile | |
parent | 18156e7e66e5147d2483382a1e3817d2401ca1a8 (diff) | |
download | lwn-24cbe7845ea50b636ab2218b9d648270ff55f148.tar.gz lwn-24cbe7845ea50b636ab2218b9d648270ff55f148.zip |
locks: close potential race between setlease and open
As Al Viro points out, there is an unlikely, but possible race between
opening a file and setting a lease on it. generic_add_lease is done with
the i_lock held, but the inode->i_flock check in break_lease is
lockless. It's possible for another task doing an open to do the entire
pathwalk and call break_lease between the point where generic_add_lease
checks for a conflicting open and adds the lease to the list. If this
occurs, we can end up with a lease set on the file with a conflicting
open.
To guard against that, check again for a conflicting open after adding
the lease to the i_flock list. If the above race occurs, then we can
simply unwind the lease setting and return -EAGAIN.
Because we take dentry references and acquire write access on the file
before calling break_lease, we know that if the i_flock list is empty
when the open caller goes to check it then the necessary refcounts have
already been incremented. Thus the additional check for a conflicting
open will see that there is one and the setlease call will fail.
Cc: Bruce Fields <bfields@fieldses.org>
Cc: David Howells <dhowells@redhat.com>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Reported-by: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: J. Bruce Fields <bfields@fieldses.org>
Diffstat (limited to 'Makefile')
0 files changed, 0 insertions, 0 deletions