Skip to content

Commit e4be320

Browse files
committed
smb3: fix broken cached reads when posix locks
Mandatory locking is enforced for cached reads, which violates default posix semantics, and also it is enforced inconsistently. This affected recent versions of libreoffice, and can be demonstrated by opening a file twice from the same client, locking it from handle one and trying to read from it from handle two (which fails, returning EACCES). There is already a mount option "forcemandatorylock" (which defaults to off), so with this change only when the user intentionally specifies "forcemandatorylock" on mount will we break posix semantics on read to a locked range (ie we will only fail in this case, if the user mounts with "forcemandatorylock"). An earlier patch fixed the write path. Fixes: 85160e0 ("CIFS: Implement caching mechanism for mandatory brlocks") Cc: [email protected] Cc: Pavel Shilovsky <[email protected]> Reviewed-by: David Howells <[email protected]> Reported-by: [email protected] Reported-by: Kevin Ottens <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 47ac09b commit e4be320

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

fs/smb/client/file.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2912,9 +2912,7 @@ cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to)
29122912
if (!CIFS_CACHE_READ(cinode))
29132913
return netfs_unbuffered_read_iter(iocb, to);
29142914

2915-
if (cap_unix(tcon->ses) &&
2916-
(CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) &&
2917-
((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) {
2915+
if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0) {
29182916
if (iocb->ki_flags & IOCB_DIRECT)
29192917
return netfs_unbuffered_read_iter(iocb, to);
29202918
return netfs_buffered_read_iter(iocb, to);

0 commit comments

Comments
 (0)