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 167A33382DC; Mon, 20 Apr 2026 15:44:15 +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=1776699855; cv=none; b=B08aURjMczGsjQgNb2ncggbjNSIcbRrvBoh5PAueywZ9ILG4auTMHOJl9Jn89PBuG37istGMm6Q+9460xEC6q3k5kBfzNgB03ZgheQC3KKOiE8ye/TTTyic5Pu52dl386fII4nN2I82k26YfaRmwDztq/tfnbDYab6sUTOSCrM4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776699855; c=relaxed/simple; bh=Vk2kKzquFB/Qm4cTL+3E64XGU5EoWCQmeG+FMHAt9zw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A47UbFdJFRcjIH3ab7GyY3LA3X+kzJkGJPQ03YTNrUtWYFxMT31i/OUNKBe7fjjw0e6I47fRM2f5xbIGVwU00SCaLJyOVb81QddQetD3aaZu44MUyEFyyL/yhSMHz4aA2F5PnFE1zVUZ/rCLFFTwVJ7GIq9Cja3Hp6S+24dwVhk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=hLZNLI6m; 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="hLZNLI6m" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7837AC19425; Mon, 20 Apr 2026 15:44:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776699855; bh=Vk2kKzquFB/Qm4cTL+3E64XGU5EoWCQmeG+FMHAt9zw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hLZNLI6mTS8vImQCGH0JqULw8AC0ln0iWVF71wEHSpXD7ZYpYHlZzdkSAHM2OGrfK /boMuYMOiGvGK/1QUcs3q9VlNU9uyUzIPcgc1bsNUknjLLiv3LWqBbPgVzNWZCT1t+ 2r1nTUKdDhT7qfBfZgH3byFfkrgpaBYuFdtYxT1E= 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 7.0 23/76] smb: client: avoid double-free in smbd_free_send_io() after smbd_send_batch_flush() Date: Mon, 20 Apr 2026 17:41:34 +0200 Message-ID: <20260420153911.667528794@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260420153910.810034134@linuxfoundation.org> References: <20260420153910.810034134@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.0-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 @@ -1551,17 +1551,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);