Skip to content

Commit cf74fcd

Browse files
metze-sambasmfrench
authored andcommitted
smb: client: let send_done handle a completion without IB_SEND_SIGNALED
With smbdirect_send_batch processing we likely have requests without IB_SEND_SIGNALED, which will be destroyed in the final request that has IB_SEND_SIGNALED set. If the connection is broken all requests are signaled even without explicit IB_SEND_SIGNALED. Cc: <stable@vger.kernel.org> # 6.18.x Cc: Steve French <smfrench@gmail.com> Cc: Tom Talpey <tom@talpey.com> Cc: Long Li <longli@microsoft.com> Cc: Namjae Jeon <linkinjeon@kernel.org> Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 5b1c614 commit cf74fcd

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

fs/smb/client/smbdirect.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,32 @@ static void send_done(struct ib_cq *cq, struct ib_wc *wc)
554554
log_rdma_send(INFO, "smbdirect_send_io 0x%p completed wc->status=%s\n",
555555
request, ib_wc_status_msg(wc->status));
556556

557+
if (unlikely(!(request->wr.send_flags & IB_SEND_SIGNALED))) {
558+
/*
559+
* This happens when smbdirect_send_io is a sibling
560+
* before the final message, it is signaled on
561+
* error anyway, so we need to skip
562+
* smbdirect_connection_free_send_io here,
563+
* otherwise is will destroy the memory
564+
* of the siblings too, which will cause
565+
* use after free problems for the others
566+
* triggered from ib_drain_qp().
567+
*/
568+
if (wc->status != IB_WC_SUCCESS)
569+
goto skip_free;
570+
571+
/*
572+
* This should not happen!
573+
* But we better just close the
574+
* connection...
575+
*/
576+
log_rdma_send(ERR,
577+
"unexpected send completion wc->status=%s (%d) wc->opcode=%d\n",
578+
ib_wc_status_msg(wc->status), wc->status, wc->opcode);
579+
smbd_disconnect_rdma_connection(sc);
580+
return;
581+
}
582+
557583
/*
558584
* Free possible siblings and then the main send_io
559585
*/
@@ -567,6 +593,7 @@ static void send_done(struct ib_cq *cq, struct ib_wc *wc)
567593
lcredits += 1;
568594

569595
if (wc->status != IB_WC_SUCCESS || wc->opcode != IB_WC_SEND) {
596+
skip_free:
570597
if (wc->status != IB_WC_WR_FLUSH_ERR)
571598
log_rdma_send(ERR, "wc->status=%s wc->opcode=%d\n",
572599
ib_wc_status_msg(wc->status), wc->opcode);

0 commit comments

Comments
 (0)