From: Stefan Metzmacher <metze@samba.org>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Steve French <sfrench@samba.org>,
Paulo Alcantara <pc@manguebit.org>,
Ronnie Sahlberg <ronniesahlberg@gmail.com>,
Shyam Prasad N <sprasad@microsoft.com>,
Tom Talpey <tom@talpey.com>, Bharath SM <bharathsm@microsoft.com>,
linux-cifs@vger.kernel.org, samba-technical@lists.samba.org,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH next] smb: client: Fix use after free in send_done()
Date: Wed, 6 Aug 2025 14:20:56 +0200 [thread overview]
Message-ID: <ad2e9d94-2d95-4351-b800-627f20672209@samba.org> (raw)
In-Reply-To: <aJNASZzOWtg8aljM@stanley.mountain>
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@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);
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@samba.org/T/#m98a8607d7b83a11fd78547306836a872a2a27192
What was the test that triggered the problem?
Or did you only noticed it by looking at the code?
Thanks!
metze
next prev parent reply other threads:[~2025-08-06 12:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-06 11:45 Dan Carpenter
2025-08-06 12:20 ` Stefan Metzmacher [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ad2e9d94-2d95-4351-b800-627f20672209@samba.org \
--to=metze@samba.org \
--cc=bharathsm@microsoft.com \
--cc=dan.carpenter@linaro.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pc@manguebit.org \
--cc=ronniesahlberg@gmail.com \
--cc=samba-technical@lists.samba.org \
--cc=sfrench@samba.org \
--cc=sprasad@microsoft.com \
--cc=tom@talpey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®