ksmbd: prevent rename with empty string

Client can send empty newname string to ksmbd server.
It will cause a kernel oops from d_alloc.
This patch return the error when attempting to rename
a file or directory with an empty new name string.

Cc: stable@vger.kernel.org
Reported-by: Norbert Szetei <norbert@doyensec.com>
Tested-by: Norbert Szetei <norbert@doyensec.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
Namjae Jeon 2025-04-30 11:18:28 +09:00 committed by Steve French
parent ca91b95001
commit 53e3e5babc
1 changed files with 5 additions and 0 deletions

View File

@ -633,6 +633,11 @@ smb2_get_name(const char *src, const int maxlen, struct nls_table *local_nls)
return name;
}
if (*name == '\0') {
kfree(name);
return ERR_PTR(-EINVAL);
}
if (*name == '\\') {
pr_err("not allow directory name included leading slash\n");
kfree(name);