Skip to content

Commit 9ee2afe

Browse files
pcacjrSteve French
authored and
Steve French
committed
cifs: prevent copying past input buffer boundaries
Prevent copying past @DaTa buffer in smb2_validate_and_copy_iov() as the output buffer in @Iov might be potentially bigger and thus copying more bytes than requested in @minbufsize. Signed-off-by: Paulo Alcantara (SUSE) <[email protected]> Reviewed-by: Ronnie Sahlberg <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 69ccafd commit 9ee2afe

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/cifs/smb2pdu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3485,7 +3485,7 @@ smb2_validate_and_copy_iov(unsigned int offset, unsigned int buffer_length,
34853485
if (rc)
34863486
return rc;
34873487

3488-
memcpy(data, begin_of_buf, buffer_length);
3488+
memcpy(data, begin_of_buf, minbufsize);
34893489

34903490
return 0;
34913491
}
@@ -3609,7 +3609,7 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon,
36093609

36103610
rc = smb2_validate_and_copy_iov(le16_to_cpu(rsp->OutputBufferOffset),
36113611
le32_to_cpu(rsp->OutputBufferLength),
3612-
&rsp_iov, min_len, *data);
3612+
&rsp_iov, dlen ? *dlen : min_len, *data);
36133613
if (rc && allocated) {
36143614
kfree(*data);
36153615
*data = NULL;

0 commit comments

Comments
 (0)