Re: [PATCH v2] ksmbd: fail FILE_CREATE of a named stream that exists

From: Namjae Jeon

Date: Tue Dec 01 2026 - 09:36:19 EST


On Tue, Dec 1, 2026 at 12:47 PM Ian Bridges <icb@xxxxxxxxxxxx> wrote:
>
> An open with FILE_CREATE of a named stream that already exists
> succeeds, and the client gets a handle to the existing stream. The
> stream lookup ignores case, so a name that differs only in case also
> opens the existing stream. A client that uses FILE_CREATE to make a new
> stream cannot tell that the stream existed, and its writes change the
> existing data.
>
> Fail an open with FILE_CREATE of an existing named stream with
> STATUS_OBJECT_NAME_COLLISION, as an open with FILE_CREATE of an
> existing file already fails.
>
> The handle gets its stream name before the stream is looked up, so a
> failed open of a stream is closed as a stream handle. When another
> handle of the file has delete-on-close on a stream, that close can
> remove the stream that the failed open named. The new failure would
> then delete the existing stream. Make the handle a stream handle only
> after the stream is opened.
>
> Suggested-by: ChenXiaoSong <chenxiaosong@xxxxxxxxxxxxxxxx>
> Signed-off-by: Ian Bridges <icb@xxxxxxxxxxxx>
Applied it with ChenXiaoSong's tags to #ksmbd-for-next.
Thanks!