mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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] ksmbd: fail FILE_CREATE of a named stream that exists
Date: Tue, 1 Dec 2026 11:13:13 +0800	[thread overview]
Message-ID: <8116c0dc-4eac-486d-ad6a-f676d5400187@chenxiaosong.com> (raw)
In-Reply-To: <20261201022248.2167102-1-icb@fastmail.org>

Sashiko's comment seems valid: 
https://sashiko.dev/#/patchset/20261201022248.2167102-1-icb%40fastmail.org

We can also include the following changes:
```
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -3690,7 +3690,7 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, 
unsigned int buf_len,
  static noinline int smb2_set_stream_name_xattr(const struct path *path,
                                                struct ksmbd_file *fp,
                                                char *stream_name, int 
s_type,
-                                              bool *created)
+                                              struct stream *stream, 
bool *created)
  {
         const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
         size_t xattr_stream_size;
@@ -3704,8 +3704,8 @@ static noinline int 
smb2_set_stream_name_xattr(const struct path *path,
         if (rc)
                 return rc;

-       fp->stream.name = xattr_stream_name;
-       fp->stream.size = xattr_stream_size;
+       stream->name = xattr_stream_name;
+       stream->size = xattr_stream_size;

         /* Keep the existing xattr's case for subsequent writes and 
removal. */
         rc = ksmbd_vfs_casexattr_len(idmap,
@@ -5291,13 +5291,20 @@ int smb2_open(struct ksmbd_work *work)
         }

         if (stream_name) {
+               struct stream stream = {};
+
                 rc = smb2_set_stream_name_xattr(&path,
                                                 fp,
                                                 stream_name,
                                                 s_type,
+                                               &stream,
                                                 &stream_created);
-               if (rc)
+               if (rc) {
+                       kfree(stream.name);
                         goto err_out;
+               }
+               /* Only an opened stream may participate in 
delete-on-close. */
+               fp->stream = stream;
                 file_info = FILE_CREATED;
         }
```

On 12/1/26 10:22, Ian Bridges wrote:
> --- a/fs/smb/server/smb2pdu.c
> +++ b/fs/smb/server/smb2pdu.c
> @@ -3712,7 +3712,7 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,
>   				     xattr_stream_name,
>   				     xattr_stream_size, xattr_stream_name);
>   	if (rc >= 0)
> -		return 0;
> +		return fp->cdoption == FILE_CREATE_LE ? -EEXIST : 0;
>   	if (rc != -ENOENT && rc != -ENODATA)
>   		return rc;
>   

-- 
ChenXiaoSong <chenxiaosong@chenxiaosong.com>
Chinese Homepage: https://chenxiaosong.com
English Homepage: https://chenxiaosong.com/en


  reply	other threads:[~2026-12-01  3:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  2:22 Ian Bridges
2026-12-01  3:13 ` ChenXiaoSong [this message]
2026-12-01  3:41 ` [PATCH v2] " Ian Bridges
2026-12-01  3:45 ` [PATCH] " 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=8116c0dc-4eac-486d-ad6a-f676d5400187@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®