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 F026D3396EE; Mon, 20 Apr 2026 16:04:06 +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=1776701047; cv=none; b=lFhgg2KtspqE15bYubbGa2eObsuqOL0fmLudLdaoBk02bnU7gEcZmNSB8zW8YMhWAMH1FUHfgX9EbAq2BulHUZUO+e7uHY9/LAuuWRwreVwK9M8wdvzQnYAybimGm/P8Hai+dV4k5fCp8FZo5gzYfSxKmCGZMijroKEbuUrKq3M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776701047; c=relaxed/simple; bh=SfVrtRfkFPP7Ft8CkDEohLASef10k2fFJjc/Y/WAdDA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DfeOkx5iGU97WT/6XgaUDH2goA2uQchuiW5U/MneCy1ibHnO1FcZLDWHZG3nV9oJQ96g8NIiqPy1U97+QoXkTBJsU5O6ZZ3O/W95M+L22cGLXkd4X+XxsjCBuM+59c2K1OURasGFqnARVww/gydrsAg6ycxIb8zTsHDG9g6SWEs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=JIiXfb1A; 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="JIiXfb1A" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20E7CC19425; Mon, 20 Apr 2026 16:04:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776701046; bh=SfVrtRfkFPP7Ft8CkDEohLASef10k2fFJjc/Y/WAdDA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JIiXfb1AKiZ0BKJAIBaoYzZ4/rMeJpHbRUSiZHXttwVIO7dVDOEas7o13dZsaIIaj XbRG4i9AEELz/1akeUa7Rlm1tGpnW6RV+TxP1H56h9NzAUBJ7dny8HhVpdUQqq/9u7 nSWVCTIzIarkq0YYgEUmdUzNSAd/vfw3km4rtUcc= 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 , Sergey Senozhatsky , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, security@kernel.org, Stefan Metzmacher , Namjae Jeon , "Paulo Alcantara (Red Hat)" , Steve French Subject: [PATCH 6.18 143/198] smb: server: avoid double-free in smb_direct_free_sendmsg after smb_direct_flush_send_list() Date: Mon, 20 Apr 2026 17:42:02 +0200 Message-ID: <20260420153940.758013934@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260420153935.605963767@linuxfoundation.org> References: <20260420153935.605963767@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 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stefan Metzmacher commit 84ff995ae826aa6bbcc6c7b9ea569ff67c021d72 upstream. smb_direct_flush_send_list() already calls smb_direct_free_sendmsg(), so we should not call it again after post_sendmsg() 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: 34abd408c8ba ("smb: server: make use of smbdirect_socket.send_io.bcredits") Cc: stable@kernel.org Cc: Steve French Cc: Tom Talpey Cc: Ruikai Peng Cc: Sergey Senozhatsky Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Cc: security@kernel.org Signed-off-by: Stefan Metzmacher Acked-by: Namjae Jeon Acked-by: Paulo Alcantara (Red Hat) Tested-by: Ruikai Peng Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/smb/server/transport_rdma.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/fs/smb/server/transport_rdma.c +++ b/fs/smb/server/transport_rdma.c @@ -1473,15 +1473,21 @@ static int smb_direct_post_send_data(str if (ret) goto err; + /* + * From here msg is moved to send_ctx + * and we should not free it explicitly. + */ + if (send_ctx == &_send_ctx) { ret = smb_direct_flush_send_list(sc, send_ctx, true); if (ret) - goto err; + goto flush_failed; } return 0; err: smb_direct_free_sendmsg(sc, msg); +flush_failed: header_failed: atomic_inc(&sc->send_io.credits.count); credit_failed: