FAILED: patch "[PATCH] ksmbd: enforce the read-only share flag when creating a stream" failed to apply to 6.1-stable tree
Subsystems (2)
Sasha Levin
maintainerThe patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 09139429fab3a5114c18d7c15fb161511d4d66c9
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 6.1.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From 09139429fab3a5114c18d7c15fb161511d4d66c9 Mon Sep 17 00:00:00 2001
From: Ian Bridges <[email protected]>
Date: Wed, 28 Oct 2026 20:25:32 -0500
Subject: [PATCH] ksmbd: enforce the read-only share flag when creating a
stream
When a share is read-only, smb2_open() rejects opens that would create or truncate a file. Creating a named stream on an existing file with streams_xattr sets neither O_CREAT nor O_TRUNC, so it passes this check, and smb2_set_stream_name_xattr() then creates the stream. On a Time Machine share, opening a missing AFP_AfpInfo stream also writes one. A user who can write a file at the filesystem level can therefore add streams to it through a read-only share.
Do not create a stream or synthesize AFP_AfpInfo when the share is not writable. Existing streams still open normally, and a missing stream opened with FILE_OPEN still returns STATUS_OBJECT_NAME_NOT_FOUND.
--- fs/smb/server/smb2pdu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/smb/server/smb2pdu.c +5 -1
@@ -3566,7 +3566,8 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,if (fp->cdoption ==FILE_OPEN_LE ) {if (!strcmp (stream_name,"AFP_AfpInfo" ) &&test_share_config_flag (fp->tcon->share_conf, -KSMBD_SHARE_FLAG_TIME_MACHINE )) { +KSMBD_SHARE_FLAG_TIME_MACHINE ) && +test_tree_conn_flag (fp->tcon,KSMBD_TREE_CONN_FLAG_WRITABLE )) {/* * Synthesize an empty AFP_AfpInfo xattr on first access. * type=0/creator=0 tells macOS to use the file extension
@@ -3593,6 +3594,9 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,return -EBADF ; } +if (!test_tree_conn_flag (fp->tcon,KSMBD_TREE_CONN_FLAG_WRITABLE )) +return -EACCES ; + rc =ksmbd_vfs_setxattr (idmap, path, xattr_stream_name,NULL ,0 ,0 , false);if (rc <0 )pr_err ("Failed to store XATTR stream name :%d\n" , rc);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ksmbd: enforce the read-only share flag when creating a stream
From: Ian Bridges <[email protected]>
[ Upstream commit 09139429fab3a5114c18d7c15fb161511d4d66c9 ]
When a share is read-only, smb2_open() rejects opens that would create or truncate a file. Creating a named stream on an existing file with streams_xattr sets neither O_CREAT nor O_TRUNC, so it passes this check, and smb2_set_stream_name_xattr() then creates the stream. On a Time Machine share, opening a missing AFP_AfpInfo stream also writes one. A user who can write a file at the filesystem level can therefore add streams to it through a read-only share.
Do not create a stream or synthesize AFP_AfpInfo when the share is not writable. Existing streams still open normally, and a missing stream opened with FILE_OPEN still returns STATUS_OBJECT_NAME_NOT_FOUND.
--- fs/smb/server/smb2pdu.c | 3 +++ 1 file changed, 3 insertions(+)
fs/smb/server/smb2pdu.c +3 -0
@@ -2559,6 +2559,9 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,return -EBADF ; } +if (!test_tree_conn_flag (fp->tcon,KSMBD_TREE_CONN_FLAG_WRITABLE )) +return -EACCES ; + rc =ksmbd_vfs_setxattr (user_ns, path, xattr_stream_name,NULL ,0 ,0 , false);if (rc <0 )pr_err ("Failed to store XATTR stream name :%d\n" , rc);
Signature · 1 line
2.53.0