[PATCH] ksmbd: don't create a missing stream for FILE_OVERWRITE
From: Ian Bridges
Date: Fri Nov 27 2026 - 19:39:27 EST
An open of a named stream that does not exist fails with
STATUS_OBJECT_NAME_NOT_FOUND only for FILE_OPEN. With FILE_OVERWRITE
the stream is created and the open succeeds. MS-FSA 2.1.5.1.2 fails
both dispositions when the stream is not found. Fail FILE_OVERWRITE the
same way. FILE_OVERWRITE_IF still creates the stream.
Signed-off-by: Ian Bridges <icb@xxxxxxxxxxxx>
---
Tested on ksmbd-for-next b9eab18ab72e with KASAN. A FILE_OVERWRITE open
of a missing named stream now fails with STATUS_OBJECT_NAME_NOT_FOUND,
and no stream is created. FILE_OVERWRITE of an existing stream and
FILE_OVERWRITE_IF of a missing one still succeed. smbtorture gives the
same results as on the base.
This patch was developed with LLM assistance.
fs/smb/server/smb2pdu.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index f286f9818643..e073b96d92a6 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -3747,6 +3747,10 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,
return -EBADF;
}
+ /* FILE_OVERWRITE does not create a missing stream (MS-FSA 2.1.5.1.2) */
+ if (fp->cdoption == FILE_OVERWRITE_LE)
+ return -EBADF;
+
if (!test_tree_conn_flag(fp->tcon, KSMBD_TREE_CONN_FLAG_WRITABLE))
return -EACCES;
base-commit: b9eab18ab72ec25abf431cba58e5239f695632f7
--
2.47.3