Skip to content

Commit d339adc

Browse files
aaptelSteve French
authored andcommitted
CIFS: fix use-after-free of the lease keys
The request buffers are freed right before copying the pointers. Use the func args instead which are identical and still valid. Simple reproducer (requires KASAN enabled) on a cifs mount: echo foo > foo ; tail -f foo & rm foo Cc: <stable@vger.kernel.org> # 4.20 Fixes: 179e44d ("smb3: add tracepoint for sending lease break responses to server") Signed-off-by: Aurelien Aptel <aaptel@suse.com> Signed-off-by: Steve French <stfrench@microsoft.com> Reviewed-by: Paulo Alcantara <palcantara@suse.de>
1 parent 082aaa8 commit d339adc

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
@@ -4441,8 +4441,8 @@ SMB2_lease_break(const unsigned int xid, struct cifs_tcon *tcon,
44414441
rc = cifs_send_recv(xid, ses, &rqst, &resp_buf_type, flags, &rsp_iov);
44424442
cifs_small_buf_release(req);
44434443

4444-
please_key_low = (__u64 *)req->LeaseKey;
4445-
please_key_high = (__u64 *)(req->LeaseKey+8);
4444+
please_key_low = (__u64 *)lease_key;
4445+
please_key_high = (__u64 *)(lease_key+8);
44464446
if (rc) {
44474447
cifs_stats_fail_inc(tcon, SMB2_OPLOCK_BREAK_HE);
44484448
trace_smb3_lease_err(le32_to_cpu(lease_state), tcon->tid,

0 commit comments

Comments
 (0)