Skip to content

Commit 27b7c3e

Browse files
metze-sambasmfrench
authored andcommitted
smb: client: avoid double-free in smbd_free_send_io() after smbd_send_batch_flush()
smbd_send_batch_flush() already calls smbd_free_send_io(), so we should not call it again after smbd_post_send() moved it to the batch list. Reported-by: Ruikai Peng <ruikai@pwno.io> Closes: https://lore.kernel.org/linux-cifs/CAFD3drNOSJ05y3A+jNXSDxW-2w09KHQ0DivhxQ_pcc7immVVOQ@mail.gmail.com/ Fixes: 2153812 ("smb: client: make use of smbdirect_socket.send_io.bcredits") Cc: stable@kernel.org Cc: Steve French <smfrench@gmail.com> Cc: Tom Talpey <tom@talpey.com> Cc: Long Li <longli@microsoft.com> Cc: Ruikai Peng <ruikai@pwno.io> Cc: Sergey Senozhatsky <senozhatsky@chromium.org> Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Cc: security@kernel.org Acked-by: Paulo Alcantara (Red Hat) <pc@manguebit.org> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Tested-by: Ruikai Peng <ruikai@pwno.io> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 3e29889 commit 27b7c3e

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

fs/smb/client/smbdirect.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,17 +1551,25 @@ static int smbd_post_send_iter(struct smbdirect_socket *sc,
15511551

15521552
rc = smbd_post_send(sc, batch, request);
15531553
if (!rc) {
1554+
/*
1555+
* From here request is moved to batch
1556+
* and we should not free it explicitly.
1557+
*/
1558+
15541559
if (batch != &_batch)
15551560
return 0;
15561561

15571562
rc = smbd_send_batch_flush(sc, batch, true);
15581563
if (!rc)
15591564
return 0;
1565+
1566+
goto err_flush;
15601567
}
15611568

15621569
err_dma:
15631570
smbd_free_send_io(request);
15641571

1572+
err_flush:
15651573
err_alloc:
15661574
atomic_inc(&sc->send_io.credits.count);
15671575
wake_up(&sc->send_io.credits.wait_queue);

0 commit comments

Comments
 (0)