Skip to content

Commit b956140

Browse files
Zisen Yegregkh
authored andcommitted
smb/client: fix out-of-bounds read in symlink_data()
commit d62b8d2 upstream. Since smb2_check_message() returns success without length validation for the symlink error response, in symlink_data() it is possible for iov->iov_len to be smaller than sizeof(struct smb2_err_rsp). If the buffer only contains the base SMB2 header (64 bytes), accessing err->ErrorContextCount (at offset 66) or err->ByteCount later in symlink_data() will cause an out-of-bounds read. Link: https://lore.kernel.org/linux-cifs/297d8d9b-adf7-42fd-a1c2-5b1f230032bc@chenxiaosong.com/ Fixes: 76894f3 ("cifs: improve symlink handling for smb2+") Cc: Stable@vger.kernel.org Signed-off-by: Zisen Ye <zisenye@stu.xidian.edu.cn> Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a16f70a commit b956140

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

fs/smb/client/smb2misc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ smb2_check_message(char *buf, unsigned int pdu_len, unsigned int len,
241241
if (len != calc_len) {
242242
/* create failed on symlink */
243243
if (command == SMB2_CREATE_HE &&
244-
shdr->Status == STATUS_STOPPED_ON_SYMLINK)
244+
shdr->Status == STATUS_STOPPED_ON_SYMLINK &&
245+
len > calc_len)
245246
return 0;
246247
/* Windows 7 server returns 24 bytes more */
247248
if (calc_len + 24 == len && command == SMB2_OPLOCK_BREAK_HE)

0 commit comments

Comments
 (0)