mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ksmbd: fail FILE_CREATE of a named stream that exists
@ 2026-12-01  2:22 Ian Bridges
  2026-12-01  3:13 ` ChenXiaoSong
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ian Bridges @ 2026-12-01  2:22 UTC (permalink / raw)
  To: linkinjeon
  Cc: senozhatsky, tom, chenxiaosong, linux-cifs, linux-kernel, Ian Bridges

An open with FILE_CREATE of a named stream that already exists
succeeds, and the client gets a handle to the existing stream. The
stream lookup ignores case, so a name that differs only in case also
opens the existing stream. A client that uses FILE_CREATE to make a new
stream cannot tell that the stream existed, and its writes change the
existing data.

Fail an open with FILE_CREATE of an existing named stream with
STATUS_OBJECT_NAME_COLLISION, as an open with FILE_CREATE of an
existing file already fails.

Signed-off-by: Ian Bridges <icb@fastmail.org>
---
Tested on ksmbd-for-next 87ff512becd4, on x86_64 with KASAN. A script
sent FILE_CREATE of an existing named stream in several forms, and the
other dispositions, to the base and to the patched server. Each
FILE_CREATE of an existing stream got STATUS_OBJECT_NAME_COLLISION and
left the stream as it was. The others gave the same results as on the
base. smbtorture gives the same results as on the base, and KASAN
reported nothing.

This patch was developed with LLM assistance.

 fs/smb/server/smb2pdu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 89aad1acb370..bb46c85c3894 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -3712,7 +3712,7 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,
 				     xattr_stream_name,
 				     xattr_stream_size, xattr_stream_name);
 	if (rc >= 0)
-		return 0;
+		return fp->cdoption == FILE_CREATE_LE ? -EEXIST : 0;
 	if (rc != -ENOENT && rc != -ENODATA)
 		return rc;
 

base-commit: 87ff512becd45a08c44fd47a9f03e607af9ef6bd
-- 
2.47.3


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-01  3:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-01  2:22 [PATCH] ksmbd: fail FILE_CREATE of a named stream that exists Ian Bridges
2026-12-01  3:13 ` ChenXiaoSong
2026-12-01  3:41 ` [PATCH v2] " Ian Bridges
2026-12-01  3:45 ` [PATCH] " Ian Bridges

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®