]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
cifs: Fix calling CIFSFindFirst() for root path without msearch
authorPali Rohár <pali@kernel.org>
Mon, 30 Dec 2024 19:54:11 +0000 (20:54 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:21:27 +0000 (16:21 +0200)
[ Upstream commit b460249b9a1dab7a9f58483e5349d045ad6d585c ]

To query root path (without msearch wildcard) it is needed to
send pattern '\' instead of '' (empty string).

This allows to use CIFSFindFirst() to query information about root path
which is being used in followup changes.

This change fixes the stat() syscall called on the root path on the mount.
It is because stat() syscall uses the cifs_query_path_info() function and
it can fallback to the CIFSFindFirst() usage with msearch=false.

Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/cifs/cifssmb.c

index f924f05b18290ab42335cddb57044893f9a3ae1f..ea444c8d0c40315368d6d5ddf5cad8eb8a08070e 100644 (file)
@@ -4544,6 +4544,12 @@ findFirstRetry:
                        pSMB->FileName[name_len] = 0;
                        pSMB->FileName[name_len+1] = 0;
                        name_len += 2;
+               } else if (!searchName[0]) {
+                       pSMB->FileName[0] = CIFS_DIR_SEP(cifs_sb);
+                       pSMB->FileName[1] = 0;
+                       pSMB->FileName[2] = 0;
+                       pSMB->FileName[3] = 0;
+                       name_len = 4;
                }
        } else {
                name_len = copy_path_name(pSMB->FileName, searchName);
@@ -4555,6 +4561,10 @@ findFirstRetry:
                        pSMB->FileName[name_len] = '*';
                        pSMB->FileName[name_len+1] = 0;
                        name_len += 2;
+               } else if (!searchName[0]) {
+                       pSMB->FileName[0] = CIFS_DIR_SEP(cifs_sb);
+                       pSMB->FileName[1] = 0;
+                       name_len = 2;
                }
        }