]> git.ipfire.org Git - thirdparty/linux.git/commit - fs/locks.c
locks: eliminate false positive conflicts for write lease
authorAmir Goldstein <amir73il@gmail.com>
Fri, 7 Jun 2019 14:24:38 +0000 (17:24 +0300)
committerJeff Layton <jlayton@kernel.org>
Wed, 19 Jun 2019 12:49:38 +0000 (08:49 -0400)
commit387e3746d01c34457d6a73688acd90428725070b
tree575796428aac6a85321113d53a75abe9cfdccbcf
parentd51f527f44f96276a94c191bc160de051f64aeea
locks: eliminate false positive conflicts for write lease

check_conflicting_open() is checking for existing fd's open for read or
for write before allowing to take a write lease.  The check that was
implemented using i_count and d_count is an approximation that has
several false positives.  For example, overlayfs since v4.19, takes an
extra reference on the dentry; An open with O_PATH takes a reference on
the dentry although the file cannot be read nor written.

Change the implementation to use i_readcount and i_writecount to
eliminate the false positive conflicts and allow a write lease to be
taken on an overlayfs file.

The change of behavior with existing fd's open with O_PATH is symmetric
w.r.t. current behavior of lease breakers - an open with O_PATH currently
does not break a write lease.

This increases the size of struct inode by 4 bytes on 32bit archs when
CONFIG_FILE_LOCKING is defined and CONFIG_IMA was not already
defined.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
fs/locks.c
include/linux/fs.h