]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
locks: add missing memory barrier in break_deleg
authorJeff Layton <jlayton@poochiereds.net>
Tue, 10 Jun 2014 16:24:40 +0000 (12:24 -0400)
committerJeff Layton <jlayton@poochiereds.net>
Tue, 10 Jun 2014 16:24:40 +0000 (12:24 -0400)
break_deleg is subject to the same potential race as break_lease. Add
a memory barrier to prevent it.

Signed-off-by: Jeff Layton <jlayton@primarydata.com>
include/linux/fs.h

index c3f46e499dd0027eed7f2bd0a0bc3cd465c3ac44..22ae79650b82024c21c9901c15e3c58f3f0376fb 100644 (file)
@@ -1914,6 +1914,12 @@ static inline int break_lease(struct inode *inode, unsigned int mode)
 
 static inline int break_deleg(struct inode *inode, unsigned int mode)
 {
+       /*
+        * Since this check is lockless, we must ensure that any refcounts
+        * taken are done before checking inode->i_flock. Otherwise, we could
+        * end up racing with tasks trying to set a new lease on this file.
+        */
+       smp_mb();
        if (inode->i_flock)
                return __break_lease(inode, mode, FL_DELEG);
        return 0;