Skip to content

Commit

Permalink
cifs: prevent copying past input buffer boundaries
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
pcacjr authored and Steve French committed Oct 13, 2022
1 parent 69ccafd commit 9ee2afe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/cifs/smb2pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -3485,7 +3485,7 @@ smb2_validate_and_copy_iov(unsigned int offset, unsigned int buffer_length,
if (rc)
return rc;

memcpy(data, begin_of_buf, buffer_length);
memcpy(data, begin_of_buf, minbufsize);

return 0;
}
Expand Down Expand Up @@ -3609,7 +3609,7 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon,

rc = smb2_validate_and_copy_iov(le16_to_cpu(rsp->OutputBufferOffset),
le32_to_cpu(rsp->OutputBufferLength),
&rsp_iov, min_len, *data);
&rsp_iov, dlen ? *dlen : min_len, *data);
if (rc && allocated) {
kfree(*data);
*data = NULL;
Expand Down

0 comments on commit 9ee2afe

Please sign in to comment.