Skip to content

Commit bd9bb95

Browse files
committed
smb3: fix broken cached reads when posix locks
JIRA: https://issues.redhat.com/browse/RHEL-57983 Conflicts: - Code difference due to missing 3ee1a1f ("cifs: Cut over to using netfslib"). commit e4be320 Author: Steve French <stfrench@microsoft.com> Date: Thu Aug 15 18:31:36 2024 -0500 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: stable@vger.kernel.org Cc: Pavel Shilovsky <piastryyy@gmail.com> Reviewed-by: David Howells <dhowells@redhat.com> Reported-by: abartlet@samba.org Reported-by: Kevin Ottens <kevin.ottens@enioka.com> Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Paulo Alcantara <paalcant@redhat.com>
1 parent f9865f5 commit bd9bb95

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
@@ -4486,9 +4486,7 @@ cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to)
44864486
if (!CIFS_CACHE_READ(cinode))
44874487
return cifs_user_readv(iocb, to);
44884488

4489-
if (cap_unix(tcon->ses) &&
4490-
(CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) &&
4491-
((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0))
4489+
if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)
44924490
return generic_file_read_iter(iocb, to);
44934491

44944492
/*

0 commit comments

Comments
 (0)