Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: pablo@netfilter.org
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
Subject: Re: [PATCH net 04/15] ipvs: avoid stack overflow from recursive connection expiration
Date: Sat, 14 Nov 2026 02:15:41 +0000	[thread overview]
Message-ID: <179462254139.2199510.10412248743488371357@kernel.org> (raw)
In-Reply-To: <20261113011447.2357709-5-pablo@netfilter.org>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The commit message says the recursive chain walk exhausts the
  kernel stack "during namespace cleanup".

--

ipvs: avoid stack overflow from recursive connection expiration

This commit replaces the recursive controller expiration in
ip_vs_conn_expire() with an iterative walk. It no longer calls
ip_vs_conn_del() on the controller. Instead, the new
ip_vs_conn_del_reference() helper steals the controller's timer
reference, and the function loops back with cp = ct inside a single
rcu_read_lock() section.

> When a controlled IPVS connection expires, its controller may be expired
> synchronously if it has no remaining controlled connections. A chain of
> controlled connections can then recurse through ip_vs_conn_expire() and
> exhaust the kernel stack during namespace cleanup.

[Severity: Low]
This isn't a bug, but is "during namespace cleanup" the only place the
recursion can happen?

ip_vs_conn_del_reference() is the only code that sets cp->timeout = 0,
which arms the drop-controller chain. It is reached from runtime callers
as well as from the netns flush.

ip_vs_random_dropentry() runs from defense_work when drop_entry defense
is active:

net/netfilter/ipvs/ip_vs_conn.c:ip_vs_random_dropentry() {
    ...
drop:
			IP_VS_DBG(4, "drop connection\n");
			ip_vs_conn_del(cp);
    ...
}

ip_vs_expire_nodest_conn_flush() runs when a real server becomes
unavailable and expire_nodest_conn is set:

net/netfilter/ipvs/ip_vs_conn.c:ip_vs_expire_nodest_conn_flush() {
    ...
			ip_vs_conn_del(cp);
			if (cp_c && !atomic_read(&cp_c->n_control)) {
				IP_VS_DBG(4, "del controlling connection\n");
				ip_vs_conn_del(cp_c);
			}
    ...
}

The chain can also run from the timer softirq. If ip_vs_conn_unlink()
fails because refcnt > 1, the expire_later path keeps timeout == 0 when
n_control == 0:

net/netfilter/ipvs/ip_vs_conn.c:ip_vs_conn_expire() {
    ...
  expire_later:
    ...
	if (cp->timeout || atomic_read(&cp->n_control))
		cp->timeout = 60 * HZ;
    ...
	__ip_vs_conn_put_timer(cp);
}

The timer is then re-armed at jiffies + 0. The next callback walks the
controller chain, and before this patch that walk recursed on the
softirq stack.

The loop in ip_vs_conn_expire() covers all of these entry points, so the
code change itself looks fine. Could the commit message also mention the
runtime paths, since stable and CVE triage will rely on the stated
impact?

The commit message also doesn't explain how a deep chain is built. The
ip_vs_conn_expire_now() comment still says chains are at most
DATA->CTL->TPL. Both points are handled by the follow-up patch in the
series, "ipvs: reject FTP control ports as data ports". It rejects
control ports as FTP data ports in ip_vs_ftp_out() and ip_vs_ftp_in(),
which bounds the chain again.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113011447.2357709-2-pablo%40netfilter.org

  reply	other threads:[~2026-11-14  2:15 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13  1:14 [PATCH net 00/15] IPVS fixes for net Pablo Neira Ayuso
2026-11-13  1:14 ` [PATCH net 01/15] ipvs: avoid out-of-bounds write in ip_vs_nat_icmp_v6 Pablo Neira Ayuso
2026-11-13  1:16   ` netdev-bot+sinfo
2026-11-13  3:17     ` Pablo Neira Ayuso
2026-11-14  2:15   ` netdev-bot+sashiko
2026-11-13  1:14 ` [PATCH net 02/15] ipv6: update *offset for non-first fragments in ipv6_find_hdr() Pablo Neira Ayuso
2026-11-14  2:15   ` netdev-bot+sashiko
2026-11-13  1:14 ` [PATCH net 03/15] ipvs: fix problems during connection deletion Pablo Neira Ayuso
2026-11-13  1:14 ` [PATCH net 04/15] ipvs: avoid stack overflow from recursive connection expiration Pablo Neira Ayuso
2026-11-14  2:15   ` netdev-bot+sashiko [this message]
2026-11-13  1:14 ` [PATCH net 05/15] ipvs: reject FTP control ports as data ports Pablo Neira Ayuso
2026-11-14  2:15   ` netdev-bot+sashiko
2026-11-13  1:14 ` [PATCH net 06/15] ipvs: ftp: skip conntrack templates in ip_vs_ftp_out Pablo Neira Ayuso
2026-11-13  1:14 ` [PATCH net 07/15] ipvs: ftp: add seqadj extension before linking the expectation Pablo Neira Ayuso
2026-11-14  2:15   ` netdev-bot+sashiko
2026-11-13  1:14 ` [PATCH net 08/15] ipvs: update flags and seqs in backup server under lock Pablo Neira Ayuso
2026-11-14  2:15   ` netdev-bot+sashiko
2026-11-13  1:14 ` [PATCH net 09/15] ipvs: read flags and seqs in master atomically Pablo Neira Ayuso
2026-11-13  1:14 ` [PATCH net 10/15] ipvs: honor the overload state and do not enter it forever Pablo Neira Ayuso
2026-11-14  2:15   ` netdev-bot+sashiko
2026-11-13  1:14 ` [PATCH net 11/15] ipvs: validate cport in received sync records Pablo Neira Ayuso
2026-11-14  2:15   ` netdev-bot+sashiko
2026-11-13  1:14 ` [PATCH net 12/15] ipvs: skip cport 0 connections in ip_vs_conn_out_get() Pablo Neira Ayuso
2026-11-14  2:15   ` netdev-bot+sashiko
2026-11-13  1:14 ` [PATCH net 13/15] ipvs: do not create conns from packets with port 0 Pablo Neira Ayuso
2026-11-13  1:14 ` [PATCH net 14/15] ipvs: wait grace period before reusing destinations Pablo Neira Ayuso
2026-11-14  2:15   ` netdev-bot+sashiko
2026-11-13  1:14 ` [PATCH net 15/15] ipvs: pass correct sk to update_pmtu and on tunneling Pablo Neira Ayuso
2026-11-14  2:15   ` netdev-bot+sashiko
2026-11-13 22:34 ` [PATCH net 00/15] IPVS fixes for net Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179462254139.2199510.10412248743488371357@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=fw@strlen.de \
    --cc=horms@kernel.org \
    --cc=ja@ssi.bg \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox