ksmbd: don't allow O_TRUNC open on read-only share
authorNamjae Jeon <linkinjeon@kernel.org>
Sun, 7 Jan 2024 12:24:07 +0000 (21:24 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 20 Jan 2024 10:51:48 +0000 (11:51 +0100)
commitab5c25b6988f5b0227a80ae69420a2f8ab1b96e7
tree82c85af2221f4aee1d2900a09b1835393b183e13
parent71be0f674070a5ad54a1c4fb112bb2923b28ea50
ksmbd: don't allow O_TRUNC open on read-only share

commit d592a9158a112d419f341f035d18d02f8d232def upstream.

When file is changed using notepad on read-only share(read_only = yes in
ksmbd.conf), There is a problem where existing data is truncated.
notepad in windows try to O_TRUNC open(FILE_OVERWRITE_IF) and all data
in file is truncated. This patch don't allow  O_TRUNC open on read-only
share and add KSMBD_TREE_CONN_FLAG_WRITABLE check in smb2_set_info().

Cc: stable@vger.kernel.org
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/smb/server/smb2pdu.c