]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
smb3: fix broken cached reads when posix locks
authorSteve French <stfrench@microsoft.com>
Thu, 15 Aug 2024 23:31:36 +0000 (18:31 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Aug 2024 15:36:10 +0000 (17:36 +0200)
commit5364577629334ed29ca85339d875fa57cd74dd50
tree2c01ab5147181fefe9fd365289d17ff74e78289b
parent89523523298a84a4d1dab2c590faef343a9dadd8
smb3: fix broken cached reads when posix locks

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@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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/smb/client/file.c