Commit b4b61e46 authored by Yongjian Sun's avatar Yongjian Sun
Browse files

ksmbd: fix Out-of-Bounds Write in ksmbd_vfs_stream_write

mainline inclusion
from mainline-v6.12-rc3
commit 313dab082289e460391c82d855430ec8a28ddf81
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBEAP7
CVE: CVE-2024-56626

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=313dab082289e460391c82d855430ec8a28ddf81



--------------------------------

An offset from client could be a negative value, It could allows
to write data outside the bounds of the allocated buffer.
Note that this issue is coming when setting
'vfs objects = streams_xattr parameter' in ksmbd.conf.

Cc: stable@vger.kernel.org # v5.15+
Reported-by: default avatarJordy Zomer <jordyzomer@google.com>
Signed-off-by: default avatarJordy Zomer <jordyzomer@google.com>
Signed-off-by: default avatarNamjae Jeon <linkinjeon@kernel.org>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
Signed-off-by: default avatarSun Yongjian <sunyongjian1@huawei.com>
parent 604e996d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -6866,6 +6866,8 @@ int smb2_write(struct ksmbd_work *work)
	}

	offset = le64_to_cpu(req->Offset);
	if (offset < 0)
		return -EINVAL;
	length = le32_to_cpu(req->Length);

	if (req->Channel == SMB2_CHANNEL_RDMA_V1 ||