From 5e47d3792b2202662fac8f48ae376b31f27f03db Mon Sep 17 00:00:00 2001 From: "changqing.gao" Date: Mon, 1 Apr 2019 13:57:55 +0800 Subject: [PATCH] fs: KASAN error in nls uniname cmp [1/1] PD#SWPL-6404 Problem: KASAN error:global-out-of-bounds in nls_uniname_cmp Solution: Append "\0\0" to the string of UNI_CUR_DIR_NAME and UNI_PAR_DIR_NAME Verify: x301 Change-Id: Ic94e837ed7874d337207c31eedfc966b46ab8ecd Signed-off-by: changqing.gao --- fs/exfat/exfat_nls.c | 2 +- fs/exfat/exfat_nls.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/exfat/exfat_nls.c b/fs/exfat/exfat_nls.c index be7fbf9..2f2f491 100644 --- a/fs/exfat/exfat_nls.c +++ b/fs/exfat/exfat_nls.c @@ -106,7 +106,7 @@ s32 nls_uniname_cmp(struct super_block *sb, u16 *a, u16 *b) for (i = 0; i < MAX_NAME_LENGTH; i++, a++, b++) { if (nls_upper(sb, *a) != nls_upper(sb, *b)) return 1; - if (*a == 0x0) + if ((*a == 0x0) || (*b == 0x0)) return 0; } return 0; diff --git a/fs/exfat/exfat_nls.h b/fs/exfat/exfat_nls.h index cdc1755..ef88abc 100644 --- a/fs/exfat/exfat_nls.h +++ b/fs/exfat/exfat_nls.h @@ -48,11 +48,11 @@ #define DOS_PAR_DIR_NAME ".. " #ifdef __LITTLE_ENDIAN -#define UNI_CUR_DIR_NAME ".\0" -#define UNI_PAR_DIR_NAME ".\0.\0" +#define UNI_CUR_DIR_NAME ".\0\0\0" +#define UNI_PAR_DIR_NAME ".\0.\0\0\0" #else -#define UNI_CUR_DIR_NAME "\0." -#define UNI_PAR_DIR_NAME "\0.\0." +#define UNI_CUR_DIR_NAME "\0.\0\0" +#define UNI_PAR_DIR_NAME "\0.\0.\0\0" #endif /*----------------------------------------------------------------------*/ -- 2.7.4