]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ksmbd: make utf-8 file name comparison work in __caseless_lookup()
authorAtte Heikkilä <atteh.mailbox@gmail.com>
Mon, 18 Dec 2023 15:33:21 +0000 (00:33 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Dec 2023 09:41:53 +0000 (10:41 +0100)
commitb3e852bea8a7440af69c577545cbc602aa8539d5
tree1e47f675fe6abc168847f879c7c03fab3cbe43cc
parent131e308593e6d03a2d93b75a8c8c45f13e39cf93
ksmbd: make utf-8 file name comparison work in __caseless_lookup()

[ Upstream commit dbab80e2071ad8c702e50dab43326608a127d27b ]

Case-insensitive file name lookups with __caseless_lookup() use
strncasecmp() for file name comparison. strncasecmp() assumes an
ISO8859-1-compatible encoding, which is not the case here as UTF-8
is always used. As such, use of strncasecmp() here produces correct
results only if both strings use characters in the ASCII range only.
Fix this by using utf8_strncasecmp() if CONFIG_UNICODE is set. On
failure or if CONFIG_UNICODE is not set, fallback to strncasecmp().
Also, as we are adding an include for `linux/unicode.h', include it
in `fs/ksmbd/connection.h' as well since it should be explicit there.

Signed-off-by: Atte Heikkilä <atteh.mailbox@gmail.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ksmbd/connection.h
fs/ksmbd/vfs.c
fs/ksmbd/vfs.h