Re: [PATCH next] smb: client: Fix use after free in send_done()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Dan,

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@xxxxxxxxxx>
---
  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);

The correct fix is to use 'info' instead of 'request->info'
other than that the order needs to stay that way.

I already asked Steve to squash such a change into the
original commit (which is not yet upstream).

See:
https://lore.kernel.org/linux-cifs/cover.1754308712.git.metze@xxxxxxxxx/T/#m98a8607d7b83a11fd78547306836a872a2a27192

What was the test that triggered the problem?
Or did you only noticed it by looking at the code?

Thanks!
metze




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux