Skip to content

Commit 2d204ee

Browse files
Dan CarpenterSteve French
authored andcommitted
cifs: integer overflow in in SMB2_ioctl()
The "le32_to_cpu(rsp->OutputOffset) + *plen" addition can overflow and wrap around to a smaller value which looks like it would lead to an information leak. Fixes: 4a72daf ("SMB2 FSCTL and IOCTL worker function") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Steve French <[email protected]> Reviewed-by: Aurelien Aptel <[email protected]> CC: Stable <[email protected]>
1 parent 56446f2 commit 2d204ee

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
@@ -2459,14 +2459,14 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
24592459
/* We check for obvious errors in the output buffer length and offset */
24602460
if (*plen == 0)
24612461
goto ioctl_exit; /* server returned no data */
2462-
else if (*plen > 0xFF00) {
2462+
else if (*plen > rsp_iov.iov_len || *plen > 0xFF00) {
24632463
cifs_dbg(VFS, "srv returned invalid ioctl length: %d\n", *plen);
24642464
*plen = 0;
24652465
rc = -EIO;
24662466
goto ioctl_exit;
24672467
}
24682468

2469-
if (rsp_iov.iov_len < le32_to_cpu(rsp->OutputOffset) + *plen) {
2469+
if (rsp_iov.iov_len - *plen < le32_to_cpu(rsp->OutputOffset)) {
24702470
cifs_dbg(VFS, "Malformed ioctl resp: len %d offset %d\n", *plen,
24712471
le32_to_cpu(rsp->OutputOffset));
24722472
*plen = 0;

0 commit comments

Comments
 (0)