diff options
author | Murphy Zhou <jencce.kernel@gmail.com> | 2020-02-21 05:30:01 +0300 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2020-03-23 06:49:09 +0300 |
commit | 0667059d0b4ad231e7258aa571f28574b313f34f (patch) | |
tree | b995ee03cd22850baf2f37291d46e1ca8288f06d /fs/cifs/smb2file.c | |
parent | c7e9f78f7b459885ee472d661473aa87a0f24c04 (diff) | |
download | linux-0667059d0b4ad231e7258aa571f28574b313f34f.tar.xz |
cifs: allow unlock flock and OFD lock across fork
Since commit d0677992d2af ("cifs: add support for flock") added
support for flock, LTP/flock03[1] testcase started to fail.
This testcase is testing flock lock and unlock across fork.
The parent locks file and starts the child process, in which
it unlock the same fd and lock the same file with another fd
again. All the lock and unlock operation should succeed.
Now the child process does not actually unlock the file, so
the following lock fails. Fix this by allowing flock and OFD
lock go through the unlock routine, not skipping if the unlock
request comes from another process.
Patch has been tested by LTP/xfstests on samba and Windows
server, v3.11, with or without cache=none mount option.
[1] https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/syscalls/flock/flock03.c
Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Acked-by: Pavel Shilovsky <pshilov@microsoft.com>
Diffstat (limited to 'fs/cifs/smb2file.c')
-rw-r--r-- | fs/cifs/smb2file.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/fs/cifs/smb2file.c b/fs/cifs/smb2file.c index 0a19d6d8e1cc..2fa3ba354cc9 100644 --- a/fs/cifs/smb2file.c +++ b/fs/cifs/smb2file.c @@ -152,7 +152,12 @@ smb2_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock, (li->offset + li->length)) continue; if (current->tgid != li->pid) - continue; + /* + * flock and OFD lock are associated with an open + * file description, not the process. + */ + if (!(flock->fl_flags & (FL_FLOCK | FL_OFDLCK))) + continue; if (cinode->can_cache_brlcks) { /* * We can cache brlock requests - simply remove a lock |