From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E48E2D77E5; Mon, 20 Apr 2026 15:53:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776700410; cv=none; b=E27bf36ctcbh2pNoEJf/lkyf6kwFOAC55RKzZ2W1hAlKWF/UsfNXAv7x5ZaoMW3ISC4bicL4Wn0RoERn5Z+qNmplZ6hkzdzXXInxsX43ISxR+ngV2L/qeqE3rsVNgZzTKzIGk24KSIeItdvRnCR9zFXJJbKMZ/gvsENXoc+LwOA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776700410; c=relaxed/simple; bh=Gn8NTj/J3fDGMQJQV5ZoG8/iNG+ZsOmWCsBHO3Yk75I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HNRqf6nXPs2zSJGphNV1uK3O4m9kjehfuwCCYqPplw6kj6KRS2jobuMghTDRmseDMDbz1vBilYP4mTUvviEG5+GCtITzqLxP6g/Fh7v0B8fUdegzQXqCOUwYL43dB9Wryu45KFcPo/KPiAwxZG/lzMIBYfS+ToWGaVXZiRS73m0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ignCnCTs; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ignCnCTs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F56AC19425; Mon, 20 Apr 2026 15:53:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776700410; bh=Gn8NTj/J3fDGMQJQV5ZoG8/iNG+ZsOmWCsBHO3Yk75I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ignCnCTsldfJCUibYi/sm4EvfwdNlC0jubluxw3xv9CgSO9ejdMjsLvs8Nrj4zxgT Bq6PUx01eTUokavo3sPNsuvQyt1n6vrsgDXAoFsS+LD4hWDaf435SY9bXWbmrKnq7Y EalDDpiofbk64W29fBI7xXiMTDRkPbLMLSdPw590= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ruikai Peng , stable@kernel.org, Steve French , Tom Talpey , Long Li , Sergey Senozhatsky , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, security@kernel.org, "Paulo Alcantara (Red Hat)" , Namjae Jeon , Stefan Metzmacher , Steve French Subject: [PATCH 6.19 161/220] smb: client: avoid double-free in smbd_free_send_io() after smbd_send_batch_flush() Date: Mon, 20 Apr 2026 17:41:42 +0200 Message-ID: <20260420153939.825233523@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260420153934.013228280@linuxfoundation.org> References: <20260420153934.013228280@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stefan Metzmacher commit 27b7c3e916218b5eb2ee350211140e961bfc49be upstream. 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 Closes: https://lore.kernel.org/linux-cifs/CAFD3drNOSJ05y3A+jNXSDxW-2w09KHQ0DivhxQ_pcc7immVVOQ@mail.gmail.com/ Fixes: 21538121efe6 ("smb: client: make use of smbdirect_socket.send_io.bcredits") Cc: stable@kernel.org Cc: Steve French Cc: Tom Talpey Cc: Long Li Cc: Ruikai Peng Cc: Sergey Senozhatsky Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Cc: security@kernel.org Acked-by: Paulo Alcantara (Red Hat) Acked-by: Namjae Jeon Signed-off-by: Stefan Metzmacher Tested-by: Ruikai Peng Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/smb/client/smbdirect.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/fs/smb/client/smbdirect.c +++ b/fs/smb/client/smbdirect.c @@ -1525,17 +1525,25 @@ static int smbd_post_send_iter(struct sm rc = smbd_post_send(sc, batch, request); if (!rc) { + /* + * From here request is moved to batch + * and we should not free it explicitly. + */ + if (batch != &_batch) return 0; rc = smbd_send_batch_flush(sc, batch, true); if (!rc) return 0; + + goto err_flush; } err_dma: smbd_free_send_io(request); +err_flush: err_alloc: atomic_inc(&sc->send_io.credits.count); wake_up(&sc->send_io.credits.wait_queue);