Skip to content

Commit dfb29d6

Browse files
Dan Carpentergregkh
authored andcommitted
cifs: read overflow in is_valid_oplock_break()
[ Upstream commit 097f586 ] We need to verify that the "data_offset" is within bounds. Reported-by: Dr Silvio Cesare of InfoSect <silvio.cesare@gmail.com> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Steve French <stfrench@microsoft.com> Reviewed-by: Aurelien Aptel <aaptel@suse.com> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7d60f98 commit dfb29d6

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

fs/cifs/misc.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,17 @@ is_valid_oplock_break(char *buffer, struct TCP_Server_Info *srv)
398398
(struct smb_com_transaction_change_notify_rsp *)buf;
399399
struct file_notify_information *pnotify;
400400
__u32 data_offset = 0;
401+
size_t len = srv->total_read - sizeof(pSMBr->hdr.smb_buf_length);
402+
401403
if (get_bcc(buf) > sizeof(struct file_notify_information)) {
402404
data_offset = le32_to_cpu(pSMBr->DataOffset);
403405

406+
if (data_offset >
407+
len - sizeof(struct file_notify_information)) {
408+
cifs_dbg(FYI, "invalid data_offset %u\n",
409+
data_offset);
410+
return true;
411+
}
404412
pnotify = (struct file_notify_information *)
405413
((char *)&pSMBr->hdr.Protocol + data_offset);
406414
cifs_dbg(FYI, "dnotify on %s Action: 0x%x\n",

0 commit comments

Comments
 (0)