smb3: fix broken cached reads when posix locks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Steve French <stfrench@xxxxxxxxxxxxx>

commit e4be320eeca842a3d7648258ee3673f1755a5a59 upstream.

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: 85160e03a79e ("CIFS: Implement caching mechanism for mandatory brlocks")
Cc: stable@xxxxxxxxxxxxxxx
Cc: Pavel Shilovsky <piastryyy@xxxxxxxxx>
Reviewed-by: David Howells <dhowells@xxxxxxxxxx>
Reported-by: abartlet@xxxxxxxxx
Reported-by: Kevin Ottens <kevin.ottens@xxxxxxxxxx>
Signed-off-by: Steve French <stfrench@xxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 fs/smb/client/file.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -2912,9 +2912,7 @@ cifs_strict_readv(struct kiocb *iocb, st
 	if (!CIFS_CACHE_READ(cinode))
 		return netfs_unbuffered_read_iter(iocb, to);
 
-	if (cap_unix(tcon->ses) &&
-	    (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) &&
-	    ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) {
+	if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0) {
 		if (iocb->ki_flags & IOCB_DIRECT)
 			return netfs_unbuffered_read_iter(iocb, to);
 		return netfs_buffered_read_iter(iocb, to);


Patches currently in stable-queue which might be from stfrench@xxxxxxxxxxxxx are

queue-6.10/smb3-fix-broken-cached-reads-when-posix-locks.patch
queue-6.10/smb-client-ignore-unhandled-reparse-tags.patch
queue-6.10/ksmbd-the-buffer-of-smb2-query-dir-response-has-at-least-1-byte.patch
queue-6.10/cifs-add-a-tracepoint-to-track-credits-involved-in-r.patch
queue-6.10/smb3-fix-lock-breakage-for-cached-writes.patch
queue-6.10/smb-client-avoid-possible-null-dereference-in-cifs_f.patch




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux