[PATCH v2 2/2] ksmbd: skip metadata-only stream opens in the delete check

From: Ian Bridges

Date: Thu Nov 05 2026 - 22:54:04 EST


A metadata-only named-stream open without FILE_SHARE_DELETE blocks a
later DELETE open of the file. It also blocks setting the file delete
pending.

Ignore a stream open unless its effective access includes data, execute
or delete access. Reuse the sharing-access helper so overwriting a
stream, or creating one on an existing file, still counts as
FILE_WRITE_DATA. The Time Machine AFP_AfpInfo synthesis keeps only its
requested access.

Fixes: 19043971c947 ("ksmbd: honor stream delete sharing for base file")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Ian Bridges <icb@xxxxxxxxxxxx>
---

Notes:
This affects shares that use "vfs objects = streams_xattr".

Tested on ksmbd-for-next 957772008502 with KASAN. Targeted stream tests
and a KUnit matrix covered metadata-only, create and overwrite cases.
smbtorture matched the base. There were no KASAN reports or warnings.

A reproducer is available on request.

This fix was developed with LLM assistance.

fs/smb/server/vfs_cache.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/smb/server/vfs_cache.c b/fs/smb/server/vfs_cache.c
index f9079c529d07..c846023e5ada 100644
--- a/fs/smb/server/vfs_cache.c
+++ b/fs/smb/server/vfs_cache.c
@@ -420,7 +420,12 @@ bool ksmbd_has_stream_without_delete_share(struct ksmbd_file *fp)
if (file_inode(fp->filp) != file_inode(prev_fp->filp))
continue;

- if (!(prev_fp->saccess & FILE_SHARE_DELETE_LE)) {
+ /*
+ * A stream open with no right in FILE_SHARE_CHECKED_ACCESS_LE,
+ * implied writes included, never conflicts.
+ */
+ if (!(prev_fp->saccess & FILE_SHARE_DELETE_LE) &&
+ ksmbd_sharing_daccess(prev_fp) & FILE_SHARE_CHECKED_ACCESS_LE) {
ret = true;
break;
}
--
2.47.3