🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #17863

Re: [PATCH nf v4] ipvs: ftp: do not link expectations to unconfirmed conntracks

#17863
From: Pablo Neira Ayuso
Date: Tue, 17 Nov 2026 12:54
72 lines
11141 bytes
On Tue, Nov 17, 2026 at 03:39:44PM +0300, Theodor Arsenij Larionov Trichkine wrote:
> ip_vs_ftp_out() can link an expectation to an unconfirmed conntrack. A
> later extension add on the same packet, such as seqadj in
> ip_vs_update_conntrack() or NAT, then reallocates ct->ext and leaves the
> expectation pointing into the freed area:
> 
>   BUG: KASAN: slab-use-after-free in nf_ct_unlink_expect_report+0x490/0x4c0
>   Write of size 8 at addr ffff888004dd4e48 by task syz.2.17/649
> 
> Check the conntrack at the start of ip_vs_ftp_out() and drop the packet
> unless the conntrack is confirmed, is not a template and has the seqadj
> extension that ip_vs_update_conntrack() adds on the first packet.
> 
> Fixes: b25adce16064 ("ipvs: correct usage/allocation of seqadj ext in ipvs")
> Suggested-by: Julian Anastasov <ja@ssi.bg>
> Suggested-by: Pablo Neira Ayuso <pablo@netfilter.org>
> Cc: stable@vger.kernel.org
> Signed-off-by: Theodor Arsenij Larionov Trichkine <theodorlarionov@gmail.com>
> ---
> v4: check the conntrack at the start of ip_vs_ftp_out(), as suggested
> by Julian. A server reply that fails the check is now dropped even when
> it is not a PASV/EPSV response. Without a conntrack, e.g. with a notrack
> rule, only PASV/EPSV replies were dropped before.
> v3: https://lore.kernel.org/netfilter-devel/20261116101506.98853-1-theodorlarionov@gmail.com/
> 
>  net/netfilter/ipvs/ip_vs_ftp.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/net/netfilter/ipvs/ip_vs_ftp.c b/net/netfilter/ipvs/ip_vs_ftp.c
> index 44de99f4d187..216be082162f 100644
> --- a/net/netfilter/ipvs/ip_vs_ftp.c
> +++ b/net/netfilter/ipvs/ip_vs_ftp.c
> @@ -29,6 +29,7 @@
>  #include <linux/netfilter.h>
>  #include <net/netfilter/nf_conntrack.h>
>  #include <net/netfilter/nf_conntrack_expect.h>
> +#include <net/netfilter/nf_conntrack_seqadj.h>
>  #include <net/netfilter/nf_nat.h>
>  #include <net/netfilter/nf_nat_helper.h>
>  #include <linux/gfp.h>
> @@ -283,6 +284,12 @@ static int ip_vs_ftp_out(struct ip_vs_app *app, struct ip_vs_conn *cp,
>  	if (cp->state != IP_VS_TCP_S_ESTABLISHED)
>  		return 1;
>  
> +	ct = nf_ct_get(skb, &ctinfo);
> +	if (!ct || !nf_ct_is_confirmed(ct) || nf_ct_is_template(ct))
> +		return 0;
> +	if (!nfct_seqadj(ct))
> +		return 0;

Given you are fetching the ct earlier, this later re-fetch can go
away?

diff --git a/net/netfilter/ipvs/ip_vs_ftp.c b/net/netfilter/ipvs/ip_vs_ftp.c
index 9e3e005a8263..31c1e4b21b51 100644
--- a/net/netfilter/ipvs/ip_vs_ftp.c
+++ b/net/netfilter/ipvs/ip_vs_ftp.c
@@ -367,7 +367,6 @@ static int ip_vs_ftp_out(struct ip_vs_app *app, struct ip_vs_conn *cp,
        }
        buf_len = strlen(buf);
 
-       ct = nf_ct_get(skb, &ctinfo);
        if (ct) {
                bool mangled;
 
> +
>  	/* Linear packets are much easier to deal with. */
>  	if (skb_ensure_writable(skb, skb->len))
>  		return 0;
> -- 
> 2.34.1 
Technical Details
Message-ID: <avxOaXd5lY8TxRBn@chamomile>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365264-linux-kernel-netdev=dewy.ru
References: <20261117123944.270667-1-theodorlarionov@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365264-linux-kernel-netdev=dewy.ru
From: pablo@netfilter.org (Pablo Neira Ayuso)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH nf v4] ipvs: ftp: do not link expectations to unconfirmed
 conntracks
Date: Tue, 17 Nov 2026 13:54:01 +0100
Organization: Usenet Network
Message-ID: <avxOaXd5lY8TxRBn@chamomile>
References: <20261117123944.270667-1-theodorlarionov@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Injection-Info: usenet.network;
	logging-data="2330950"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:dxT00NatM5tjpIf8GmvYfE67dpk= sha256:fsjH2og4bdAm3/zuawwrqBDmPvzM0SbnSL/gHI/EE5A=
	sha1:a7b6br8fXzgMQNeQX7ev2O3KC/s= sha256:Wkj/q44UBqSd5XEeXaooceaus3PvZiclTMsk30PFtlE=
Content-Disposition: inline
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id E3C76114F63; Tue, 17 Nov 2026 15:54:31 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=netfilter.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id OmOGAjP1K2fm;
	Tue, 17 Nov 2026 15:54:27 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-365264-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=netfilter.org
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 4A093114F4F; Tue, 17 Nov 2026 15:54:18 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id B251928D2C; Tue, 17 Nov 2026 12:54:15 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail;
	t=1794920053;
	b=1j11JvaIG5yjDzsgeaMnvgajK8oQ4r7Jt07Rsm+TRL3ITMzp6x3utaC8dszPI6ZNc97E
	 peW/eJvY39pDwZyLUylAyFOtj1DLJ6LKnmGsgI5AtINSCt9calV5y3c6TEC4dO+Xw6MiT
	 IK9CyEIkV/zMO0g+mnipe4wiJhHYpADeNGUzEimpGe7PB06KhEgbQpBIB8yfu0wBCLmLB
	 NGwgVDB8vPYtrxJspIZ351Ex4t+E9vS/a1VfYHCVw6N3v/CN70VAJf27lN5dMNHv9cDwE
	 07FFOQjI7lkyYc6BHvj5BuL7gKbGHGvHL5YuBSjADspEwbW32FOheBt08v6IFvNpQoQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794920053;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:Date:
	 From:To:Cc:Subject:Message-ID:References:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=eI4v4Pwt8zW5jhRZ+0jVRE7KfXbV0/cmik9BOGR0Yqo=;
	b=Goheqy+36cFMXIn5EV3PGbm0yU/TO7oR9JcXH9tkT8AQEPPeTL7aKpxKM98gJtPEvbN+
	 5YtlkWL7a2hgcRRTPybHFyWfNgmyZwcJe2LnJpnNpQShvv1zU2JiY/NjM4ErOaRa3Ysl7
	 dABlg5VB1CRN55nK26h/TdJyzdKwOb/k+BaBLNBRogoH1TJ8rpCQj0aiikV5EelqkU32s
	 sDtz4tAt0c6JNCbE0r88Wqo9/YF0W5Y6nNo2jOiEjRk+ZhqJhzBeHQR+tmINbwqaiiiTJ
	 TIWd8YaWX8xUH/NqRCh21ezU8k+B2aYK5iHHg11/h4idqyWUdnho6xA3PxmPVpOpBWw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=oaFrGsXW;
	dmarc=none header.from=netfilter.org;
	spf=pass smtp.mailfrom=netfilter.org;
	arc=fail smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 1DDEE606A32C;
	Tue, 17 Nov 2026 12:54:13 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=oaFrGsXW
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.70.190.124
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794920047;
	b=1I2Y/29f7Iw2PvNiyTUFW0zxqhliW15YCNgbSadqkEIwIqeMWxl11F+6k+d7NNh6SWaS
	 xbtncoPbiSLr4YPA1WNLhi3nHUUopUhLEy/4KvN5m5xLcg9wBCYhPoCiT0IvDDSB+z+Ms
	 uAsf2soix4IvrlROxOaOt1QhCdqIwA/qoxR422qyMfWl56hhSnBHERt9bqczoFNzOc5uJ
	 sW924YH/BtQeHDXNfLKDeFHKULj0ahw8Lo9bV0Kqn7V2zrLhKpXACclccvAkOiLfJwWcU
	 474wiygVpgfoaPspdiA4aB+FFc3/0m2KPy1HT3JwhVt4jdX7U3WxN+A4rwUCzJjUP9Q==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794920047;
	h=DMARC-Filter:DKIM-Signature:Received:Date:From:To:Cc:Subject:
	 Message-ID:References:MIME-Version:Content-Type:Content-Disposition:
	 In-Reply-To:X-Spam-Status:X-Spam-Checker-Version;
	bh=eI4v4Pwt8zW5jhRZ+0jVRE7KfXbV0/cmik9BOGR0Yqo=;
	b=FUAwAgaqyNDEx/ipuYxRG5uSpeTJ0eQ8AqOQDLJajZPkRpT7yKkDZoymEexOz/oSJGLm
	 lcU6arKNWTszRXrXOY5pBIA4jtRU1lAqob5M/QeB8wPXlZHowA9Mgm77Kr8YAtm1hdeGT
	 0memGOaREoWn7deBrSoU2ztjOseWLhHFH2zxKcDukH1MFJv+FDq015t3gCduECWuyNNMV
	 UaY4egi8NY2jubBQoy3HyycHrEM8Uun/zFRHcB4LTXNEeDzI14Md4QDV0Zo5NQFpDt2Tg
	 DHRleYxRX8t7j36jO4OdCZYMu5OfQen8jdGG9SxQuB9NYhw0N12ClFJTrQ3/ymZDlVw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=netfilter.org;
	spf=pass smtp.mailfrom=netfilter.org;
	dkim=pass header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=oaFrGsXW;
	arc=none smtp.remote-ip=217.70.190.124
X-Received: from mail.netfilter.org (mail.netfilter.org [217.70.190.124])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with UTF8SMTPS id C0E2A606A323;
	Tue, 17 Nov 2026 12:54:06 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C0E2A606A323
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netfilter.org
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netfilter.org;
	s=2025; t=1794920044;
	bh=eI4v4Pwt8zW5jhRZ+0jVRE7KfXbV0/cmik9BOGR0Yqo=;
	h=Date:From:To:Cc:Subject:References:In-Reply-To:From;
	b=oaFrGsXWIgeyLnLgGbpYxFgKVK83DmGH2NwRb5GwxYqApi830U96EufCWr9FkWpSg
	 rNI6UGzp7Mgf2RbyuyV7FobYqKwOQ0pwCOJog2yh3G8gIXzme7EXkoZ4oDOFv2vJwd
	 52/PuPWt683AThlJe4JKrfBDmDAuQye+zJoKTriUQ0XNtsglURWNteRJXgI4mjCHIG
	 wX0xt3GKDksoBHJQH5vF+TnaZXlCpcf0rvxDhZNiUOAs/G8fWneBwLy0Av50p+jaA6
	 s8tVKAaMx0vHUCmhG6OKT4ZO0Mk/jD8tQTZ/FUT2N4CGVXOQIvUFqXFiNkK6VYXGxY
	 PtnIU5D72rPbA==
X-Received: from netfilter.org (mail-agni [217.70.190.124])
	by mail.netfilter.org (Postfix) with UTF8SMTPSA id 23FD260060;
	Tue, 17 Nov 2026 13:54:04 +0100 (CET)
X-Cc: Julian Anastasov <ja@ssi.bg>, Simon Horman <horms@verge.net.au>,
	Florian Westphal <fw@strlen.de>, Phil Sutter <phil@nwl.cc>,
	lvs-devel@vger.kernel.org, netfilter-devel@vger.kernel.org,
	netdev@vger.kernel.org, coreteam@netfilter.org
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <20261117123944.270667-1-theodorlarionov@gmail.com>