ends,
resulting in an out-of-bounds read of 1 byte from the p_cstring stack
memory.

Therefore, to prevent this and properly determine whether nls has been
lost, it should be modified to check if "i" and len are equal, rather than
dereferencing p_cstring.

Cc: <stable@vger.kernel.org>
Reported-by: syzbot+98cc76a76de46b3714d4@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=98cc76a76de46b3714d4
Fixes: 370e812b3ec1 ("exfat: add nls operations")
Signed-off-by: Jeongjun Park <aha310510@gmail.com>
---
 fs/exfat/nls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/exfat/nls.c b/fs/exfat/nls.c
index 8243d94ceaf4..de06abe426d7 100644
--- a/fs/exfat/nls.c
+++ b/fs/exfat/nls.c
@@ -616,7 +616,7 @@ static int exfat_nls_to_ucs2(struct super_block *sb,
 		unilen++;
 	}
 
-	if (p_cstring[i] != '\0')
+	if (i != len)
 		lossy |= NLS_NAME_OVERLEN;
 
 	*uniname = '\0';
--[PATCH v2] exfat: fix out-of-bounds in exfat_nls_to_ucs2()Jeongjun Park <aha310510@gmail.com> undefinedNamjae Jeon <linkinjeon@kernel.org>, Sungjong Seo <sj1557.seo@samsung.com> undefined undefined undefined undefined undefined undefined undefined undefined undefined†'ƒ‹F
