Article View: linux.kernel.netdev
Article #16114Re: [PATCH net 07/15] ipvs: ftp: add seqadj extension before linking the expectation
From: netdev-bot+sashiko
Date: Sat, 14 Nov 2026 02:15
Date: Sat, 14 Nov 2026 02:15
131 lines
12732 bytes
12732 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 ยท High: 1 ยท Medium: 0 ยท Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] The fix is incomplete.
--
ipvs: ftp: add seqadj extension before linking the expectation
This patch adds the seqadj extension to an unconfirmed conntrack in
ip_vs_ftp_out() before the payload is mangled and before the expectation
is linked. The goal is to keep ip_vs_update_conntrack() from reallocating
ct->ext while the helper's expectation list still points into it.
> diff --git a/net/netfilter/ipvs/ip_vs_ftp.c b/net/netfilter/ipvs/ip_vs_ftp.c
> index 44de99f4d187f..81c3a2fd27b39 100644
> --- a/net/netfilter/ipvs/ip_vs_ftp.c
> +++ b/net/netfilter/ipvs/ip_vs_ftp.c
[ ... ]
> @@ -384,19 +385,25 @@ static int ip_vs_ftp_out(struct ip_vs_app *app, struct ip_vs_conn *cp,
>
> ct = nf_ct_get(skb, &ctinfo);
> if (ct && !nf_ct_is_template(ct)) {
> - bool mangled;
> + bool mangled = false;
>
> /* If mangling fails this function will return 0
> * which will cause the packet to be dropped.
> * Mangling can only fail under memory pressure,
> * hopefully it will succeed on the retransmitted
> * packet.
> + *
> + * Add the seqadj extension before the expectation is
> + * linked into the helper extension: adding it later
> + * reallocates ct->ext under the expectation list.
> */
> - mangled = nf_nat_mangle_tcp_packet(skb, ct, ctinfo,
> - ipvsh->len,
> - start - data,
> - end - start,
> - buf, buf_len);
> + if (nf_ct_is_confirmed(ct) || nfct_seqadj(ct) ||
> + nfct_seqadj_ext_add(ct))
> + mangled = nf_nat_mangle_tcp_packet(skb, ct, ctinfo,
> + ipvsh->len,
> + start - data,
> + end - start,
> + buf, buf_len);
> if (mangled) {
> ip_vs_nfct_expect_related(skb, ct, n_cp,
> ipvsh->protocol, 0, 0);
[Severity: High]
Does this fully close the use-after-free? The expectation is still linked
into nfct_help(ct)->expectations while ct is unconfirmed, and that list
head lives inside ct->ext. Pre-adding seqadj only stops one later
extension add from moving ct->ext.
nf_ct_expect_insert() does:
hlist_add_head_rcu(&exp->lnode, &master_help->expectations);
so exp->lnode.pprev now points into the current ct->ext block.
Later hooks on the same packet can still grow ct->ext. One example is a
MASQUERADE rule in POSTROUTING, which runs for this IP_CT_NEW conntrack
after the IPVS out hook:
nf_nat_inet_fn()
nf_nat_masquerade_ipv4()
nf_ct_nat_ext_add()
nf_ct_ext_add(ct, NF_CT_EXT_NAT, GFP_ATOMIC)
krealloc(ct->ext, alloc, gfp)
Here is one layout where this moves the block. With
CONFIG_NF_CONNTRACK_TIMESTAMP=y and an ecache extension present
(nf_conntrack_events=1), the extensions are header 16, ecache 32, help
56 and seqadj 24. That adds up to exactly 128 bytes, which is the
NF_CT_EXT_PREALLOC object size. Adding NAT gives a newlen of 132-136.
__do_krealloc() then goes to alloc_new and the old block is freed.
nf_conntrack_acct=1 gives the same arithmetic.
After that, ext->help.expectations.first in the new block points to
exp->lnode. But exp->lnode.pprev still points into the freed block. When
the expectation or conntrack is removed, nf_ct_unlink_expect_report()
calls:
hlist_del_rcu(&exp->lnode);
This writes through the stale pprev, which looks like the same KASAN
report quoted in the commit message. In this layout the seqadj add would
not have moved the block even before the patch, so the patch does not
help in this case.
Other extension adds on an unconfirmed ct are also reachable later in
the same traversal:
nft_ct_set_eval() with NFT_CT_EVENTMASK -> nf_ct_ecache_ext_add()
nft_ct_timeout_obj_eval() -> nf_ct_timeout_ext_add()
The commit message says this is reachable with CAP_NET_ADMIN in a user
namespace. That context can configure MASQUERADE, nft ct rules, the acct
sysctl and ctnetlink listeners.
Would it be better to not link the expectation while the conntrack's ext
can still grow? Two options are deferring the link until confirmation,
or making ct->ext stable first. Pre-adding one more extension does not
seem to cover these other paths.
None of the later patches in the series appear to touch ip_vs_ftp.c,
ip_vs_nfct.c, nf_conntrack_extend.c, nf_nat_core.c, nf_nat_masquerade.c
or nf_conntrack_expect.c.
> if (skb->ip_summed == CHECKSUM_COMPLETE)
> skb->ip_summed = CHECKSUM_UNNECESSARY;
[ ... ]
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113011447.2357709-2-pablo%40netfilter.org
Technical Details
Message-ID:
<179462254370.2199510.3740508632458892922@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363035-linux-kernel-netdev=dewy.ruReferences:
<20261113011447.2357709-8-pablo@netfilter.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363035-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net 07/15] ipvs: ftp: add seqadj extension before linking the expectation Date: Sat, 14 Nov 2026 02:15:43 +0000 Organization: Usenet Network Message-ID: <179462254370.2199510.3740508632458892922@kernel.org> References: <20261113011447.2357709-8-pablo@netfilter.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1489973"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:w77ylq8NMo93ifclQfDthb0AiLU= sha256:DiPY+xqweHKXCZcahklUEt8uiYtl/2mOiOMlw/jg7Ng= sha1:dITPrVYJ+Q59PxByKd6igzsnn7A= sha256:cwdW4vRL16gmiUTyhi+nus0EUsXQ5PpFbXl6mKK6xCI= 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 11472114738; Sat, 14 Nov 2026 05:16:19 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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=kernel.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 hJjLAqas19zv; Sat, 14 Nov 2026 05:16:15 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-363035-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 3802E114733; Sat, 14 Nov 2026 05:16:07 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 8334763F8E; Sat, 14 Nov 2026 02:15:56 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794622545; b=GpBOYl+UIirmDE54Aky8UUtDgxHe0mdfirY+1k9eep9KRwh5o7hc2uz8l0OuwT4W32s5 QyLX9mUzlwssH0gPkxVPrIiuxqvDXVAvzsT8EwkBD4mOJXoHyrThvGUi52DSiP7uOTBb4 dSknp6v362wP17rBMm9W6RbQpXSNzAbCSfZF4kEFwTZlYRrjJ9nUcf42lvBRyd2gHmdus ItbVoIoyDteeZETIOc1ejA/m8pYZY5JPgjWozc+m422V/6G3a04eAKvBEb8gcOrV71ubd vOxEViSixqimflZM/OntfWZzI/BKEN3s3UxgV4REjL+fiFk0qHsBVIzWcqF86AEPSeg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794622545; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=q32++NpuSBVXrZq1yEkuGL5U2LuT40oHUIbLOJp8kTQ=; b=FaIctaindM95sAcnOTWGqLOoJXBi2p4l4JM5nMHexkINqiDagrd8mk+hXnRnSt9RZqGd iI2gc6QrrGX4iUh2Nww+h8K/2F3D+acXY5Lyk3mFaAyWcPNAf3WpR2FWpBsS6FST1EdRi e+sCdmx/UHUe20NuMTF4Okb3gz0cbwPnb4Bf357ZNTfj/RChhVOQjMD8yFQm7+F4nKWLA 9DJt3bTP5Ym1ToZDh+zLBowZZbcrTfTvCQPhPUmZTb4lJFLqbJ+xNWiI3IR7/sXJgJEEH i2taWnEOnzgk9oanZYHBpID+1GPveEELlF3zmpCuhWFuM6fQUwlmIzStFq9lZqspyCA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=b5HuSM05; arc=pass header.oldest-pass=0 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 B1060606A883; Sat, 14 Nov 2026 02:15:45 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=b5HuSM05 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794622544; b=OAY6oz2u/+otcom3hH7op5UcuEZOZX2yoSXpOFFOM0Lo7AQ6ZtlmYlIJFslSccVyyQtw WGScQzcYRoLlmXSjMqWhqxyTpbAk/+RSz5JDkhmGvVjQk/Az4ZMECkx1hzvFZlQ7eh2FJ S19KyllpjJYQH+KxrL83Q6XrTf27Y0RTx4deGszSqu7jPAe05wPaRyUuD/KzxrPkR5CPM ouqQffceJERLxpJneQ1OxEM65zMowHdb4+tAcRhnolS8sB7eyBtbIYn9BuushawNSJF8Q fD/U0vsTnA38OPiUgLicCV/ehNJyFjK0DzUX4kdW6JIqWYBBw+t22shGf2+bwjLR/gA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794622544; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=q32++NpuSBVXrZq1yEkuGL5U2LuT40oHUIbLOJp8kTQ=; b=oe/2gbQsn4T9dBlb/+te6poMPyx3Tx9w3yiz+KxN/yvmMGTiuiQX8xXRMFu/kvFmgjEQ OLOljG5EW5vo9O2FGJJBH8fbm3YThUQTWvE66/8XgNjoTu71UtX2FmXNLFTrdRordbZr7 SiLFYqu+w0kSqD5fa3l6m8De3fAsuOl/L9Ms5Kb+JMuH7H2RKKb3SGCIzqrH7Gz71FuCV IBRrZzqArcq7UUBXfQn9LRGtaACIyqwutm603afUm8fvgBHs6qJS9yqvxLsCSLSdObPYc Ul9NKQkQIgtmFgfXz8gc8UiMj2r1FDbULTcd2o/cn/MJTJvPHv154DdEybRORtWdXwQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=b5HuSM05; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (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 ESMTPS id D03ED606A89E; Sat, 14 Nov 2026 02:15:44 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D3251F000C4; Sat, 14 Nov 2026 02:15:44 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794622544; bh=q32++NpuSBVXrZq1yEkuGL5U2LuT40oHUIbLOJp8kTQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=b5HuSM05eHq/yPW/eax2d8ltu4SvwSaM24GXEzsPhAbjEzpCQ4nXLFXDdjUV2Jg5s /hcN1XZBrdyFJFQU2/u10oQfcj/wDDLH5mCmwJ5njt9QCx8vxjV1MUPNAQjESeOEm3 FggVW66uIPtQpuuUbDZQ8UnD9V7jxxz2wI8KUqebXtFYTsQCT7uHw61voBKR9jSJPw yanMxbdBELg5QbWzoTCM1fxJgsuxq+kWFNmKQrtl1TdeAmEYLLYVMb9AsiHSP2Nyju qPNRafGl7GCyL1HE0hlcetFazz54mXEH0GowSqGox+OLMc1AF7n6a0eY9VhnwS5n// jbrCKXnm/uFtg== X-Cc: netfilter-devel@vger.kernel.org, davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com, edumazet@kernel.org, horms@kernel.org, fw@strlen.de, ja@ssi.bg X-In-Reply-To: <20261113011447.2357709-8-pablo@netfilter.org> X-sashiko-severity: High 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