Skip to content

Commit 1254100

Browse files
rohiths-msftSteve French
authored and
Steve French
committed
smb3: Handle error case during offload read path
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]>
1 parent ac873aa commit 1254100

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
@@ -4559,7 +4559,25 @@ static void smb2_decrypt_offload(struct work_struct *work)
45594559
dw->server->vals->read_rsp_size,
45604560
dw->ppages, dw->npages, dw->len,
45614561
true);
4562-
mid->callback(mid);
4562+
if (rc >= 0) {
4563+
#ifdef CONFIG_CIFS_STATS2
4564+
mid->when_received = jiffies;
4565+
#endif
4566+
mid->callback(mid);
4567+
} else {
4568+
spin_lock(&GlobalMid_Lock);
4569+
if (dw->server->tcpStatus == CifsNeedReconnect) {
4570+
mid->mid_state = MID_RETRY_NEEDED;
4571+
spin_unlock(&GlobalMid_Lock);
4572+
mid->callback(mid);
4573+
} else {
4574+
mid->mid_state = MID_REQUEST_SUBMITTED;
4575+
mid->mid_flags &= ~(MID_DELETED);
4576+
list_add_tail(&mid->qhead,
4577+
&dw->server->pending_mid_q);
4578+
spin_unlock(&GlobalMid_Lock);
4579+
}
4580+
}
45634581
cifs_mid_q_entry_release(mid);
45644582
}
45654583

0 commit comments

Comments
 (0)