Re: [PATCH] ksmbd: delete only the stream whose handle has delete-on-close
From: ChenXiaoSong
Date: Tue Dec 01 2026 - 01:23:43 EST
Reviewed-by: ChenXiaoSong <chenxiaosong@xxxxxxxxxx>
On 12/1/26 12:10, Ian Bridges wrote:
A delete-on-close open of a named stream sets a flag on the inode
instead of on the handle. The next stream handle of the file to close
takes the flag and deletes its own stream. So when another stream
handle of the file closes first, that other stream is deleted, and the
stream that was opened with delete-on-close is kept.
The stream is removed with the credentials of the closing handle. A
user who cannot write the file can open one stream with delete-on-close
and make another user's handle delete a different stream on close.
Record delete-on-close on the stream handle, as
FileDispositionInformation on a stream handle already does. Deleting a
stream never removes the file, so delete-on-close of a stream no longer
makes a new delete-on-close open close the disconnected durable handles
of the file.
Fixes: f44158485826 ("cifsd: add file operations")
Cc:stable@xxxxxxxxxxxxxxx
Signed-off-by: Ian Bridges<icb@xxxxxxxxxxxx>
---
Tested on ksmbd-for-next 87ff512becd4, on x86_64 with KASAN. A script
opened named streams of one file with and without delete-on-close, as
the owner and as a user who cannot write the file, and closed the
handles in different orders. On the base, the first stream handle to
close deleted its own stream. With the patch, only the streams opened
with delete-on-close were deleted, and FileDispositionInformation on a
stream behaved as on the base. smbtorture gives the same results as on
the base, and KASAN reported nothing.
This patch was developed with LLM assistance.
fs/smb/server/vfs_cache.c | 41 ++++++++++++++++++---------------------
fs/smb/server/vfs_cache.h | 1 +
2 files changed, 20 insertions(+), 22 deletions(-)
--
ChenXiaoSong <chenxiaosong@xxxxxxxxxxxxxxxx>
Chinese Homepage: https://chenxiaosong.com
English Homepage: https://chenxiaosong.com/en