Skip to content

Commit 8d29ac0

Browse files
rohiths-msftksacilotto
authored andcommitted
smb3: Handle error case during offload read path
BugLink: https://bugs.launchpad.net/bugs/1908562 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]> Signed-off-by: Kamal Mostafa <[email protected]> Signed-off-by: Ian May <[email protected]>
1 parent f4876d4 commit 8d29ac0

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
@@ -4222,7 +4222,25 @@ static void smb2_decrypt_offload(struct work_struct *work)
42224222
dw->server->vals->read_rsp_size,
42234223
dw->ppages, dw->npages, dw->len,
42244224
true);
4225-
mid->callback(mid);
4225+
if (rc >= 0) {
4226+
#ifdef CONFIG_CIFS_STATS2
4227+
mid->when_received = jiffies;
4228+
#endif
4229+
mid->callback(mid);
4230+
} else {
4231+
spin_lock(&GlobalMid_Lock);
4232+
if (dw->server->tcpStatus == CifsNeedReconnect) {
4233+
mid->mid_state = MID_RETRY_NEEDED;
4234+
spin_unlock(&GlobalMid_Lock);
4235+
mid->callback(mid);
4236+
} else {
4237+
mid->mid_state = MID_REQUEST_SUBMITTED;
4238+
mid->mid_flags &= ~(MID_DELETED);
4239+
list_add_tail(&mid->qhead,
4240+
&dw->server->pending_mid_q);
4241+
spin_unlock(&GlobalMid_Lock);
4242+
}
4243+
}
42264244
cifs_mid_q_entry_release(mid);
42274245
}
42284246

0 commit comments

Comments
 (0)