From 86f901803080056668cdaf23b01c8e81d2e77956 Mon Sep 17 00:00:00 2001 From: Gael Blivet Date: Thu, 9 Jul 2026 02:01:10 +0200 Subject: [PATCH] ksmbd: don't check directory emptiness when deleting a stream set_file_disposition_info() checks S_ISDIR(inode->i_mode) && ksmbd_vfs_empty_dir(fp) == -ENOTEMPTY to refuse deleting a non-empty directory. A stream handle's fp->filp refers to the same underlying inode as its base file or directory (streams are xattr-backed on that same inode), so this check also fires when the target is actually a stream attached to a directory, not the directory itself -- deleting the stream then incorrectly fails with -EBUSY whenever the directory happens to be non-empty, even though removing an xattr has nothing to do with the directory's contents. Skip the directory-emptiness check for stream handles, matching how ksmbd_stream_fd() is already used elsewhere in this function. Assisted-by: Claude:claude-sonnet-5 Signed-off-by: Gael Blivet Signed-off-by: Namjae Jeon --- 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 1cb570bbde8a..1a81391e95ef 100644 --- a/fs/smb/server/smb2pdu.c +++ b/fs/smb/server/smb2pdu.c @@ -7253,7 +7253,7 @@ static int set_file_disposition_info(struct ksmbd_work *work, if (ksmbd_has_stream_without_delete_share(fp)) return -ESHARE; - if (S_ISDIR(inode->i_mode) && + if (S_ISDIR(inode->i_mode) && !ksmbd_stream_fd(fp) && ksmbd_vfs_empty_dir(fp) == -ENOTEMPTY) return -EBUSY; smb_break_all_levII_oplock_for_delete(work, fp);