• Steve French's avatar
    smb3: fix lock breakage for cached writes · 836bb326
    Steve French authored
    Mandatory locking is enforced for cached writes, which violates
    default posix semantics, and also it is enforced inconsistently.
    This apparently breaks recent versions of libreoffice, but can
    also be demonstrated by opening a file twice from the same
    client, locking it from handle one and writing to it from
    handle two (which fails, returning EACCES).
    
    Since there was already a mount option "forcemandatorylock"
    (which defaults to off), with this change only when the user
    intentionally specifies "forcemandatorylock" on mount will we
    break posix semantics on write to a locked range (ie we will
    only fail the write in this case, if the user mounts with
    "forcemandatorylock").
    
    Fixes: 85160e03 ("CIFS: Implement caching mechanism for mandatory brlocks")
    Cc: stable@vger.kernel.org
    Cc: Pavel Shilovsky <piastryyy@gmail.com>
    Reported-by: abartlet@samba.org
    Reported-by: default avatarKevin Ottens <kevin.ottens@enioka.com>
    Reviewed-by: default avatarDavid Howells <dhowells@redhat.com>
    Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
    836bb326
file.c 88.1 KB