cifs: fix buffer overrun in parse_DFS_referrals
PATCH 1/1 cifs: fix buffer overrun in parse_DFS_referrals
While testing a kernel with memory poisoning enabled, I saw some warnings about the redzone getting clobbered when chasing DFS referrals. The buffer allocation for the unicode converted version of the searchName is too small and needs to take null termination into account.
Signed-off-by Jeff Layton <[email protected]>
--- fs/cifs/cifssmb.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
fs/cifs/cifssmb.c +2 -1
@@ -3992,7 +3992,8 @@ parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr, node->flags =le16_to_cpu (pSMBr->DFSFlags);if (is_unicode) { -__le16 *tmp =kmalloc (strlen (searchName)*2 ,GFP_KERNEL ); +__le16 *tmp =kmalloc (strlen (searchName)*2 +2 , +GFP_KERNEL );cifsConvertToUCS ((__le16 *) tmp, searchName,PATH_MAX , nls_codepage, remap); node->path_consumed = hostlen_fromUCS(tmp,
Signature · 1 line
1.5.5.1
Jeff.
Would you add my ack, and the cc: for stable and send to Linus? I think this should go in.
Quoted 28 lines · Jeff Layton
While testing a kernel with memory poisoning enabled, I saw some warnings about the redzone getting clobbered when chasing DFS referrals. The buffer allocation for the unicode converted version of the searchName is too small and needs to take null termination into account.
Signed-off-by Jeff Layton <[email protected]>--- fs/cifs/cifssmb.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)fs/cifs/cifssmb.c +2
-2@@ -3992,7 +3992,8 @@ parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr, node->flags =le16_to_cpu (pSMBr->DFSFlags);if (is_unicode) { -__le16 *tmp =kmalloc (strlen (searchName)*2 ,GFP_KERNEL ); +__le16 *tmp =kmalloc (strlen (searchName)*2 +2 , +GFP_KERNEL );cifsConvertToUCS ((__le16 *) tmp, searchName,PATH_MAX , nls_codepage, remap); node->path_consumed = hostlen_fromUCS(tmp, --1.5.5.1
Signature · 3 lines
Thanks, Steve