Commit 4012abe8 authored by Joshua Rogers's avatar Joshua Rogers Committed by Steve French
Browse files

smb: client: validate change notify buffer before copy



SMB2_change_notify called smb2_validate_iov() but ignored the return
code, then kmemdup()ed using server provided OutputBufferOffset/Length.

Check the return of smb2_validate_iov() and bail out on error.

Discovered with help from the ZeroPath security tooling.

Signed-off-by: default avatarJoshua Rogers <linux@joshua.hu>
Reviewed-by: default avatarPaulo Alcantara (Red Hat) <pc@manguebit.org>
Cc: stable@vger.kernel.org
Fixes: e3e94634 ("smb3: improve SMB3 change notification support")
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent b540de9e
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -4054,9 +4054,12 @@ SMB2_change_notify(const unsigned int xid, struct cifs_tcon *tcon,

		smb_rsp = (struct smb2_change_notify_rsp *)rsp_iov.iov_base;

		smb2_validate_iov(le16_to_cpu(smb_rsp->OutputBufferOffset),
				le32_to_cpu(smb_rsp->OutputBufferLength), &rsp_iov,
		rc = smb2_validate_iov(le16_to_cpu(smb_rsp->OutputBufferOffset),
				le32_to_cpu(smb_rsp->OutputBufferLength),
				&rsp_iov,
				sizeof(struct file_notify_information));
		if (rc)
			goto cnotify_exit;

		*out_data = kmemdup((char *)smb_rsp + le16_to_cpu(smb_rsp->OutputBufferOffset),
				le32_to_cpu(smb_rsp->OutputBufferLength), GFP_KERNEL);