Skip to content

Commit cd4b9b6

Browse files
Ye Bingregkh
authored andcommitted
smb/client: fix possible infinite loop and oob read in symlink_data()
commit 7d9a7f1 upstream. On 32-bit architectures, the infinite loop is as follows: len = p->ErrorDataLength == 0xfffffff8 u8 *next = p->ErrorContextData + len next == p On 32-bit architectures, the out-of-bounds read is as follows: len = p->ErrorDataLength == 0xfffffff0 u8 *next = p->ErrorContextData + len next == (u8 *)p - 8 Reported-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Fixes: 76894f3 ("cifs: improve symlink handling for smb2+") Cc: stable@vger.kernel.org Signed-off-by: Ye Bin <yebin10@huawei.com> 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 0df9f45 commit cd4b9b6

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

fs/smb/client/smb2file.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ static struct smb2_symlink_err_rsp *symlink_data(const struct kvec *iov)
4949
__func__, le32_to_cpu(p->ErrorId));
5050

5151
len = ALIGN(le32_to_cpu(p->ErrorDataLength), 8);
52+
if (len > end - ((u8 *)p + sizeof(*p)))
53+
return ERR_PTR(-EINVAL);
54+
5255
p = (struct smb2_error_context_rsp *)(p->ErrorContextData + len);
5356
}
5457
} else if (le32_to_cpu(err->ByteCount) >= sizeof(*sym) &&

0 commit comments

Comments
 (0)