Skip to content

Commit 4012abe

Browse files
Joshua Rogerssmfrench
authored andcommitted
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: Joshua Rogers <linux@joshua.hu> Reviewed-by: Paulo Alcantara (Red Hat) <pc@manguebit.org> Cc: stable@vger.kernel.org Fixes: e3e9463 ("smb3: improve SMB3 change notification support") Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent b540de9 commit 4012abe

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

fs/smb/client/smb2pdu.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4054,9 +4054,12 @@ SMB2_change_notify(const unsigned int xid, struct cifs_tcon *tcon,
40544054

40554055
smb_rsp = (struct smb2_change_notify_rsp *)rsp_iov.iov_base;
40564056

4057-
smb2_validate_iov(le16_to_cpu(smb_rsp->OutputBufferOffset),
4058-
le32_to_cpu(smb_rsp->OutputBufferLength), &rsp_iov,
4057+
rc = smb2_validate_iov(le16_to_cpu(smb_rsp->OutputBufferOffset),
4058+
le32_to_cpu(smb_rsp->OutputBufferLength),
4059+
&rsp_iov,
40594060
sizeof(struct file_notify_information));
4061+
if (rc)
4062+
goto cnotify_exit;
40604063

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

0 commit comments

Comments
 (0)