lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87646c67-78b8-41c5-9b72-361cb3b733d1@suswa.mountain>
Date: Wed, 6 Aug 2025 15:48:11 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: Stefan Metzmacher <metze@...ba.org>
Cc: Steve French <sfrench@...ba.org>, Paulo Alcantara <pc@...guebit.org>,
	Ronnie Sahlberg <ronniesahlberg@...il.com>,
	Shyam Prasad N <sprasad@...rosoft.com>, Tom Talpey <tom@...pey.com>,
	Bharath SM <bharathsm@...rosoft.com>, linux-cifs@...r.kernel.org,
	samba-technical@...ts.samba.org, linux-kernel@...r.kernel.org,
	kernel-janitors@...r.kernel.org
Subject: Re: [PATCH next] smb: client: Fix use after free in send_done()

On Wed, Aug 06, 2025 at 02:20:56PM +0200, Stefan Metzmacher wrote:
> 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@...aro.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?

This was a Smatch static checker warning.  You need to have the cross
function DB to detect it.

regards,
dan carpenter


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ