* [PATCH] ksmbd: fail an open whose stream cannot be created
@ 2026-11-28 0:59 Ian Bridges
2026-11-28 1:16 ` Namjae Jeon
0 siblings, 1 reply; 2+ messages in thread
From: Ian Bridges @ 2026-11-28 0:59 UTC (permalink / raw)
To: linkinjeon
Cc: senozhatsky, tom, chenxiaosong, linux-cifs, linux-kernel,
Ian Bridges, stable
When smb2_set_stream_name_xattr() cannot store the xattr of a new named
stream, it logs the error and returns success. The open then succeeds
with FILE_CREATED, although the stream does not exist. This happens,
for example, when the caller cannot write the file. Return the error
so that the open fails instead of reporting a stream that was never
created.
Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
Cc: stable@vger.kernel.org
Signed-off-by: Ian Bridges <icb@fastmail.org>
---
Tested on ksmbd-for-next b9eab18ab72e with KASAN. A user created a
named stream on another user's file that the user could only read. On
the base the open succeeded with no stream. With the patch it fails
with STATUS_ACCESS_DENIED. The same holds for a new stream on an
immutable file, where storing the xattr fails with -EPERM. A stream on
the user's own file is still created. smbtorture gives the same results
as on the base.
This patch was developed with LLM assistance.
fs/smb/server/smb2pdu.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index f286f9818643..3eb275a2ed5e 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -3751,10 +3751,12 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,
return -EACCES;
rc = ksmbd_vfs_setxattr(idmap, path, xattr_stream_name, NULL, 0, 0, true);
- if (rc < 0)
+ if (rc < 0) {
pr_err("Failed to store XATTR stream name :%d\n", rc);
- else
- *created = true;
+ /* smb2_open() reports -EPERM as a sharing violation */
+ return rc == -EPERM ? -EACCES : rc;
+ }
+ *created = true;
return 0;
}
base-commit: b9eab18ab72ec25abf431cba58e5239f695632f7
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] ksmbd: fail an open whose stream cannot be created
2026-11-28 0:59 [PATCH] ksmbd: fail an open whose stream cannot be created Ian Bridges
@ 2026-11-28 1:16 ` Namjae Jeon
0 siblings, 0 replies; 2+ messages in thread
From: Namjae Jeon @ 2026-11-28 1:16 UTC (permalink / raw)
To: Ian Bridges
Cc: senozhatsky, tom, chenxiaosong, linux-cifs, linux-kernel, stable
On Sat, Nov 28, 2026 at 9:59 AM Ian Bridges <icb@fastmail.org> wrote:
>
> When smb2_set_stream_name_xattr() cannot store the xattr of a new named
> stream, it logs the error and returns success. The open then succeeds
> with FILE_CREATED, although the stream does not exist. This happens,
> for example, when the caller cannot write the file. Return the error
> so that the open fails instead of reporting a stream that was never
> created.
>
> Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
> Cc: stable@vger.kernel.org
> Signed-off-by: Ian Bridges <icb@fastmail.org>
Applied it to #ksmbd-for-next.
Thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-28 1:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-28 0:59 [PATCH] ksmbd: fail an open whose stream cannot be created Ian Bridges
2026-11-28 1:16 ` Namjae Jeon
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®