Skip to content

Commit 0760e66

Browse files
rohiths-msftgregkh
authored andcommitted
smb3: Handle error case during offload read path
commit 1254100 upstream. Mid callback needs to be called only when valid data is read into pages. These patches address a problem found during decryption offload: CIFS: VFS: trying to dequeue a deleted mid that could cause a refcount use after free: Workqueue: smb3decryptd smb2_decrypt_offload [cifs] Signed-off-by: Rohith Surabattula <[email protected]> Reviewed-by: Pavel Shilovsky <[email protected]> CC: Stable <[email protected]> #5.4+ Signed-off-by: Steve French <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent fc0caf4 commit 0760e66

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

fs/cifs/smb2ops.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4415,7 +4415,25 @@ static void smb2_decrypt_offload(struct work_struct *work)
44154415
dw->server->vals->read_rsp_size,
44164416
dw->ppages, dw->npages, dw->len,
44174417
true);
4418-
mid->callback(mid);
4418+
if (rc >= 0) {
4419+
#ifdef CONFIG_CIFS_STATS2
4420+
mid->when_received = jiffies;
4421+
#endif
4422+
mid->callback(mid);
4423+
} else {
4424+
spin_lock(&GlobalMid_Lock);
4425+
if (dw->server->tcpStatus == CifsNeedReconnect) {
4426+
mid->mid_state = MID_RETRY_NEEDED;
4427+
spin_unlock(&GlobalMid_Lock);
4428+
mid->callback(mid);
4429+
} else {
4430+
mid->mid_state = MID_REQUEST_SUBMITTED;
4431+
mid->mid_flags &= ~(MID_DELETED);
4432+
list_add_tail(&mid->qhead,
4433+
&dw->server->pending_mid_q);
4434+
spin_unlock(&GlobalMid_Lock);
4435+
}
4436+
}
44194437
cifs_mid_q_entry_release(mid);
44204438
}
44214439

0 commit comments

Comments
 (0)