From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.216.245.30 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796313535; b=e+sbC6LM15Kk6oWl+hmbiSvZGHBMR5SGYuC3qnTxkal57nuKICR2Ql9xAhyEtzMhAhsP ShNs+9b61kwlKXJdwncpeIMxxr5XUHkCEUoDT7dSLjYr+2ZIFUYSeyp6a5lnkg/tC5KQT kGurdXpdPg4n+yYw93Tbi24thjaDuANxdOOKAmWEvi2sUndvyxcD+mfJrzE6kHDT5jW2z h08t92c+7wd9NhFgZKNunk4zHg9bkcFDtUc6F0yDRbKqYib0mJikmYMQyHnF8jtJC464t hOGYcGpglBwTBkNoEXUjS98xRdUnvkIfGnQYMqeXFiqmBVD3oMBJw/Pt3pvtz/efzDw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796313535; h=DMARC-Filter:Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=OOfc+LfJ/+e8nFPvaXn7IilCFz2IveroyHHi3Aruud0=; b=xGs81acnKcQgRldqxZ6cl0678f+ms4PYVNt1JyXkWnWj2DIvcZEn2GC5hXdQkcRyS1lz 3qkh9fwRc1rOFH1HMT99/5GDQJgNGvEO1pwSRy0/IJKmBDx8xkkgoa/CSA9g/N7NK1tCR vaRlCdJpmqHvaCru6TlD5YQtuDh46/V8IRHnW1BSfQlHz39Y+DLdx6IxPWUecsWJ+inCV elpAUtFRWDmhlwRtNWHEKjDrsvtzquogWJqmy0nHihypriulN3QluSBezxlmuoUcSWVz4 ptjS4tra8Zdn/VNO0Y+ANeGW8rz77ETHbYZlpfux0M/O09KyzL3uc1MfSGvgJk17mRg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=strlen.de; spf=pass smtp.mailfrom=Chamillionaire.breakpoint.cc; arc=none smtp.remote-ip=91.216.245.30 Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [91.216.245.30]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3D90606A32D; Thu, 3 Dec 2026 15:58:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E3D90606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strlen.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=Chamillionaire.breakpoint.cc Received: by Chamillionaire.breakpoint.cc (Postfix, from userid 1003) id 5C82160538; Thu, 03 Dec 2026 16:58:53 +0100 (CET) From: Florian Westphal To: Cc: Florian Westphal , stable@vger.kernel.org Subject: [PATCH nf-next v4 7/9] netfilter: conntrack: confirm ct when helper validation fails Date: Thu, 3 Dec 2026 16:58:10 +0100 Message-ID: <20261203155812.8873-8-fw@strlen.de> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261203155812.8873-1-fw@strlen.de> References: <20261203155812.8873-1-fw@strlen.de> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit nf_confirm_cthelper() is called via nf_conntrack_update() when a packet that was queued to a userspace conntrack helper is reinjected with an ACCEPT verdict. When the l4 header can't be located -- the packet is a fragment, or the header chain is malformed, or userspace rewrote the packet such that it no longer matches the conntrack tuple -- the function returns NF_ACCEPT without confirming the conntrack entry. This is wrong for packets that were queued from the confirm hook itself, which is the expected case: the userspace helper queues the packet from within nf_confirm(), i.e. before the conntrack entry was added to the hash table. On reinject there is no later hook that could confirm the entry, so the skb leaves the host with an unconfirmed conntrack entry attached. The entry is never inserted into the conntrack hash table, so later packets of the same flow create new (unconfirmed) entries and nat, helper and expectation state is lost. Skip helper and seqadj processing as before, but fall through to nf_conntrack_confirm(). Problem located during an LLM-assisted review of the helper hardening series; verified by inspection. No reproducer: it needs a userspace conntrack helper whose verdict rewrites the reinjected packet into a state that fails header validation. As this isn't supposed to be possible anymore, this patch should not have an observable effect. Fixes: ee04805ff54a ("netfilter: conntrack: make conntrack userspace helpers work again") Cc: stable@vger.kernel.org Signed-off-by: Florian Westphal --- net/netfilter/nf_conntrack_core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index 2ceb198c70ac..03c800f29ad5 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -2234,8 +2234,13 @@ static int nf_confirm_cthelper(struct sk_buff *skb, struct nf_conn *ct, return NF_ACCEPT; if (!nf_confirm_get_protoff(skb, nf_ct_net(ct), ct, ctinfo, &protoff, - &pnum)) - return NF_ACCEPT; + &pnum)) { + /* Helper and seqadj are skipped, but the ct must still be + * committed: the packet was queued from nf_confirm(), no + * later hook will confirm it. + */ + return nf_conntrack_confirm(skb); + } if (test_bit(IPS_SEQ_ADJUST_BIT, &ct->status) && !nf_is_loopback_packet(skb)) { -- 2.56.1