[PATCH] cifs: fix an OOB issue in cifsConvertToUTF16()
From: Ding Hui
Date: Sat Jul 05 2025 - 23:33:10 EST
The OOB can be triggered by making symlink in reparse=native mode.
Limit the srclen can not greater than maxlen.
Fixes: 2503a0dba989 ("CIFS: Add SMB2 support for is_path_accessible")
Signed-off-by: Ding Hui <dinghui@xxxxxxxxxxxxxx>
---
fs/smb/client/cifs_unicode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/smb/client/cifs_unicode.c b/fs/smb/client/cifs_unicode.c
index 4cc6e0896fad..cee43e71fa87 100644
--- a/fs/smb/client/cifs_unicode.c
+++ b/fs/smb/client/cifs_unicode.c
@@ -636,7 +636,7 @@ cifs_strndup_to_utf16(const char *src, const int maxlen, int *utf16_len,
*utf16_len = 0;
return NULL;
}
- cifsConvertToUTF16(dst, src, strlen(src), cp, remap);
+ cifsConvertToUTF16(dst, src, strnlen(src, maxlen), cp, remap);
*utf16_len = len;
return dst;
}
--
2.17.1