mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH next] smb: client: Fix use after free in send_done()
@ 2025-08-06 11:45 Dan Carpenter
  2025-08-06 12:20 ` Stefan Metzmacher
  0 siblings, 1 reply; 11+ messages in thread
From: Dan Carpenter @ 2025-08-06 11:45 UTC (permalink / raw)
  To: Stefan Metzmacher
  Cc: Steve French, Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N,
	Tom Talpey, Bharath SM, linux-cifs, samba-technical,
	linux-kernel, kernel-janitors

The mempool_free() function frees "request".  Don't free the request
until after smbd_disconnect_rdma_connection() to avoid a use after free
bug.

Fixes: 5e65668c75c0 ("smb: client: let send_done() cleanup before calling smbd_disconnect_rdma_connection()")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 fs/smb/client/smbdirect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/smb/client/smbdirect.c b/fs/smb/client/smbdirect.c
index 58321e483a1a..162f8d1c548a 100644
--- a/fs/smb/client/smbdirect.c
+++ b/fs/smb/client/smbdirect.c
@@ -286,8 +286,8 @@ static void send_done(struct ib_cq *cq, struct ib_wc *wc)
 	if (wc->status != IB_WC_SUCCESS || wc->opcode != IB_WC_SEND) {
 		log_rdma_send(ERR, "wc->status=%d wc->opcode=%d\n",
 			wc->status, wc->opcode);
-		mempool_free(request, request->info->request_mempool);
 		smbd_disconnect_rdma_connection(request->info);
+		mempool_free(request, request->info->request_mempool);
 		return;
 	}
 
-- 
2.47.2


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-08-07 15:36 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-06 11:45 [PATCH next] smb: client: Fix use after free in send_done() Dan Carpenter
2025-08-06 12:20 ` Stefan Metzmacher
2025-08-06 12:48   ` Dan Carpenter
2025-08-06 14:17     ` Stefan Metzmacher
2025-08-06 14:39       ` Dan Carpenter
2025-08-07  6:34         ` Using smatch and sparse together (Re: [PATCH next] smb: client: Fix use after free in send_done()) Stefan Metzmacher
2025-08-07  7:22           ` Dan Carpenter
2025-08-07 14:27             ` Stefan Metzmacher
2025-08-07 15:06               ` Dan Carpenter
2025-08-07 15:17                 ` Stefan Metzmacher
2025-08-07 15:36                   ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®