[PATCH 2/2] ksmbd: skip metadata-only stream opens in the delete check
From: Ian Bridges
Date: Wed Nov 04 2026 - 13:59:46 EST
A READ_CONTROL open of a named stream without FILE_SHARE_DELETE makes a
DELETE open of the file fail with STATUS_SHARING_VIOLATION. Setting the
file delete pending fails the same way.
ksmbd_has_stream_without_delete_share() counts every stream open without
FILE_SHARE_DELETE, whatever access it holds.
Count a stream open only when it holds FILE_EXECUTE, FILE_READ_DATA,
FILE_WRITE_DATA, FILE_APPEND_DATA or DELETE.
Fixes: 19043971c947 ("ksmbd: honor stream delete sharing for base file")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Ian Bridges <icb@xxxxxxxxxxxx>
---
Notes:
Any share with "vfs objects = streams_xattr" is affected. A READ_CONTROL
stream open without FILE_SHARE_DELETE blocks every DELETE open of the
file and setting it delete pending.
Tested on ksmbd-for-next e49296d51ccb with KASAN, with no reports or
warnings. In targeted stream tests and a KUnit matrix every changed
result removes a sharing violation that MS-FSA does not make.
smbtorture gives the same results as on the base.
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..6675c6652c13 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
+ * never conflicts
+ */
+ if (!(prev_fp->saccess & FILE_SHARE_DELETE_LE) &&
+ prev_fp->daccess & FILE_SHARE_CHECKED_ACCESS_LE) {
ret = true;
break;
}
--
2.47.3