]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ksmbd: treat unnamed DATA stream as base file
authorNamjae Jeon <linkinjeon@kernel.org>
Thu, 18 Jun 2026 01:36:17 +0000 (10:36 +0900)
committerSteve French <stfrench@microsoft.com>
Tue, 23 Jun 2026 01:15:04 +0000 (20:15 -0500)
The SMB path suffix :: names the unnamed data stream of the base
file, not an alternate data stream backed by a DosStream xattr.

Canonicalize an empty stream name with an explicit  type to a NULL
stream name after parsing. This keeps the base filename produced by
strsep() and lets open continue through the normal base-file path instead
of looking for a non-existent empty stream xattr.

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/server/misc.c

index 966004c414a8c8b7b55d8762aa739507b107b777..2dd91c9e956a54466a189465467ab0262c089fbe 100644 (file)
@@ -121,7 +121,9 @@ int parse_stream_name(char *filename, char **stream_name, int *s_type)
        char *stream_type;
        char *s_name;
        int rc = 0;
+       bool has_stream_type = false;
 
+       *stream_name = NULL;
        s_name = filename;
        filename = strsep(&s_name, ":");
        ksmbd_debug(SMB, "filename : %s, streams : %s\n", filename, s_name);
@@ -137,14 +139,20 @@ int parse_stream_name(char *filename, char **stream_name, int *s_type)
 
                ksmbd_debug(SMB, "stream name : %s, stream type : %s\n", s_name,
                            stream_type);
-               if (!strncasecmp("$data", stream_type, 5))
+               if (!strncasecmp("$data", stream_type, 5)) {
                        *s_type = DATA_STREAM;
-               else if (!strncasecmp("$index_allocation", stream_type, 17))
+                       has_stream_type = true;
+               } else if (!strncasecmp("$index_allocation", stream_type, 17)) {
                        *s_type = DIR_STREAM;
-               else
+                       has_stream_type = true;
+               } else {
                        rc = -ENOENT;
+               }
        }
 
+       if (has_stream_type && !s_name[0] && *s_type == DATA_STREAM)
+               goto out;
+
        *stream_name = s_name;
 out:
        return rc;