Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: axel.mierczuk@1password.com
Cc: ja@ssi.bg, horms@verge.net.au, pablo@netfilter.org, fw@strlen.de,
	phil@nwl.cc, dsahern@kernel.org, idosch@nvidia.com,
	edumazet@google.com, netfilter-devel@vger.kernel.org,
	lvs-devel@vger.kernel.org, coreteam@netfilter.org,
	netdev@vger.kernel.org, w@1wt.eu, keith.hoodlet@1password.com,
	kuba@kernel.org
Subject: Re: [PATCH nf 1/2] ipvs: avoid out-of-bounds write in ip_vs_nat_icmp_v6
Date: Tue, 29 Sep 2026 15:57:06 +0000	[thread overview]
Message-ID: <179069742680.434549.10138453724847288168@kernel.org> (raw)
In-Reply-To: <20260925141155.17603-2-axel.mierczuk@1password.com>

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] Three problems with the comment and commit message; the code
  change itself is correct.

--

ipvs: avoid out-of-bounds write in ip_vs_nat_icmp_v6

When ipv6_find_hdr() stops at a non-first fragment and leaves len equal
to off, this patch adds sizeof(struct ipv6hdr) to ciph.len in both
ip_vs_out_icmp_v6() and ip_vs_in_icmp_v6(). With that, the
skb_ensure_writable() calls in the ICMPv6 NAT paths cover the embedded
addresses that ip_vs_nat_icmp_v6() rewrites.

> diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
> index fd503f0efb578..cfd193196a5bc 100644
> --- a/net/netfilter/ipvs/ip_vs_core.c
> +++ b/net/netfilter/ipvs/ip_vs_core.c
> @@ -1206,6 +1206,13 @@ static int ip_vs_out_icmp_v6(struct netns_ipvs *ipvs, struct sk_buff *skb,
>  				     true, &ciph))
>  		return NF_ACCEPT; /* The packet looks wrong, ignore */
>  
> +	/* ipv6_find_hdr() does not include the embedded header for
> +	 * non-first fragments, add it so that ESP can pass and the
> +	 * NAT writable checks cover the rewritten addresses
> +	 */

[Severity: Low]
The code change looks correct. Is the "so that ESP can pass" part of
this comment accurate, though?

I couldn't find anything that blocks an embedded IPv6 ESP fragment based
on ciph.len:

  - Neither ip_vs_out_icmp_v6() nor ip_vs_in_icmp_v6() compares ciph.len
    with ciph.off.
  - The only such check is the "ciph->len - ciph->off" ihl check, and it
    exists only on the IPv4 path.
  - The ESP lookup reads only the addresses:

net/netfilter/ipvs/ip_vs_proto_ah_esp.c:ah_esp_conn_fill_param_proto() {
	if (likely(!ip_vs_iph_inverse(iph)))
		ip_vs_conn_fill_param(ipvs, af, IPPROTO_UDP,
				      &iph->saddr, htons(PORT_ISAKMP),
				      &iph->daddr, htons(PORT_ISAKMP), p);
	...
}

So non-first ESP fragments already reached connection lookup and NAT
before this patch. That is how the out-of-bounds write happened.

The new value seems to be used only as ctoff in handle_response_icmp()
and as wlen in ip_vs_icmp_xmit_v6():

net/netfilter/ipvs/ip_vs_xmit.c:ip_vs_icmp_xmit_v6() {
	...
	wlen = ciph->len;
	...
}

Would the comment be clearer if it said that len must cover the embedded
IPv6 header that ip_vs_nat_icmp_v6() rewrites? The same comment appears
again in ip_vs_in_icmp_v6().

The commit message also says:

    This fix does not depend on patch 2.

Once this is applied, "patch 2" has no meaning in the git history. Could
the message name the companion commit instead: "ipv6: update *offset for
non-first fragments in ipv6_find_hdr()"?

That companion commit makes ipv6_find_hdr() set
*offset = start + sizeof(struct frag_hdr) on the non-first-fragment
early return. After it lands, can ciph.len == ciph.off still be true in
either function?

If not, the new branch can never be reached in mainline. The comment's
premise, "ipv6_find_hdr() does not include the embedded header for
non-first fragments", would then be false. Should the comment say it
applies only to kernels where ipv6_find_hdr() leaves *offset unchanged?

> +	if (ciph.len == ciph.off)
> +		ciph.len += sizeof(struct ipv6hdr);
> +
>  	pp = ip_vs_proto_get(ciph.protocol);
>  	if (!pp)
>  		return NF_ACCEPT;

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260925141155.17603-1-axel.mierczuk%401password.com

  reply	other threads:[~2026-09-29 15:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-25 14:11 [PATCH nf 0/2] ipvs: fix OOB write when NATing ICMPv6 errors quoting non-first fragments Axel Mierczuk
2026-09-25 14:11 ` [PATCH nf 1/2] ipvs: avoid out-of-bounds write in ip_vs_nat_icmp_v6 Axel Mierczuk
2026-09-29 15:57   ` netdev-bot+sashiko [this message]
2026-09-25 14:11 ` [PATCH nf 2/2] ipv6: update *offset for non-first fragments in ipv6_find_hdr() Axel Mierczuk
2026-09-29 15:57   ` netdev-bot+sashiko
2026-09-25 17:50 ` [PATCH nf 0/2] ipvs: fix OOB write when NATing ICMPv6 errors quoting non-first fragments Julian Anastasov
2026-09-28 11:15   ` Ido Schimmel
2026-09-30 17:34     ` Julian Anastasov
2026-10-01 16:10       ` Ido Schimmel

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=179069742680.434549.10138453724847288168@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=axel.mierczuk@1password.com \
    --cc=coreteam@netfilter.org \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=fw@strlen.de \
    --cc=horms@verge.net.au \
    --cc=idosch@nvidia.com \
    --cc=ja@ssi.bg \
    --cc=keith.hoodlet@1password.com \
    --cc=kuba@kernel.org \
    --cc=lvs-devel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=phil@nwl.cc \
    --cc=w@1wt.eu \
    /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