exfat: Return ENAMETOOLONG consistently for oversized paths
authorTakashi Iwai <tiwai@suse.de>
Tue, 26 Jul 2022 08:39:25 +0000 (10:39 +0200)
committerNamjae Jeon <linkinjeon@kernel.org>
Mon, 1 Aug 2022 01:14:06 +0000 (10:14 +0900)
commit86da53e8ff5dcfbbbd345edc0caef7d21ce567ae
treec4d407237355b1fc970d3db733265a525b006f62
parentbe17b1ccd4e82a66b9d9676dec8edce137e967d8
exfat: Return ENAMETOOLONG consistently for oversized paths

LTP has a test for oversized file path renames and it expects the
return value to be ENAMETOOLONG.  However, exfat returns EINVAL
unexpectedly in some cases, hence LTP test fails.  The further
investigation indicated that the problem happens only when iocharset
isn't set to utf8.

The difference comes from that, in the case of utf8,
exfat_utf8_to_utf16() returns the error -ENAMETOOLONG directly and
it's treated as the final error code.  Meanwhile, on other iocharsets,
exfat_nls_to_ucs2() returns the max path size but it sets
NLS_NAME_OVERLEN to lossy flag instead; the caller side checks only
whether lossy flag is set or not, resulting in always -EINVAL
unconditionally.

This patch aligns the return code for both cases by checking the lossy
flag bit and returning ENAMETOOLONG when NLS_NAME_OVERLEN bit is set.

BugLink: https://bugzilla.suse.com/show_bug.cgi?id=1201725
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
fs/exfat/namei.c