From: ChenXiaoSong <chenxiaosong@chenxiaosong.com>
To: Ian Bridges <icb@fastmail.org>, linkinjeon@kernel.org
Cc: senozhatsky@chromium.org, tom@talpey.com,
linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] ksmbd: fail FILE_CREATE of a named stream that exists
Date: Tue, 1 Dec 2026 13:50:04 +0800 [thread overview]
Message-ID: <1b25ec93-28e1-498a-884a-fbdbcfd34083@chenxiaosong.com> (raw)
In-Reply-To: <20261201034720.2178803-1-icb@fastmail.org>
Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
On 12/1/26 11:47, Ian Bridges 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@chenxiaosong.com>
> Signed-off-by: Ian Bridges<icb@fastmail.org>
> ---
> v2: Make the handle a stream handle only after the stream is opened,
> as ChenXiaoSong suggested. Sashiko found that the failed FILE_CREATE
> could remove the existing stream when another handle of the file has
> delete-on-close on a stream.
>
> Tested on ksmbd-for-next 87ff512becd4, on x86_64 with KASAN. A script
> sent FILE_CREATE of an existing named stream in several forms, and the
> other dispositions, to the base and to the patched server. Each
> FILE_CREATE of an existing stream got STATUS_OBJECT_NAME_COLLISION and
> left the stream as it was. The others gave the same results as on the
> base. A second script held delete-on-close on one stream of a file and
> then sent a FILE_CREATE of another existing stream of the file. With
> v1 the existing stream was removed. With v2 the existing stream was
> kept. smbtorture gives the same results as on the base, and KASAN
> reported nothing.
>
> This patch was developed with LLM assistance.
>
> fs/smb/server/smb2pdu.c | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
--
ChenXiaoSong <chenxiaosong@chenxiaosong.com>
Chinese Homepage: https://chenxiaosong.com
English Homepage: https://chenxiaosong.com/en
next prev parent reply other threads:[~2026-12-01 5:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 3:47 Ian Bridges
2026-12-01 5:50 ` ChenXiaoSong [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-12-01 2:22 [PATCH] " Ian Bridges
2026-12-01 3:41 ` [PATCH v2] " Ian Bridges
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1b25ec93-28e1-498a-884a-fbdbcfd34083@chenxiaosong.com \
--to=chenxiaosong@chenxiaosong.com \
--cc=icb@fastmail.org \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=senozhatsky@chromium.org \
--cc=tom@talpey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®