From: netdev-bot+sashiko@kernel.org
To: rmustafin@cloudlinux.com
Cc: steffen.klassert@secunet.com, herbert@gondor.apana.org.au,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, netdev@vger.kernel.org,
ipsec@lists.linux.dev, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH ipsec v2] xfrm: use the frame's own socket in the too big checks
Date: Tue, 24 Nov 2026 10:45:26 +0000 [thread overview]
Message-ID: <179551712630.3135.52212996809224784@kernel.org> (raw)
In-Reply-To: <20261123104236.4179425-1-rmustafin@cloudlinux.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 (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 misses one of the too-big checks.
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but it is a kernel
heap info leak on the same path.
--
xfrm: use the frame's own socket in the too big checks
This patch makes __xfrm6_output() test skb_to_full_sk(skb) instead of its
sk argument in both the IPV6_DONTFRAG check and the local error check. It
fixes a NULL pointer dereference in xfrm_local_error(). The dereference
happens when vxlan, geneve or another udp_tunnel6_xmit_skb() user forwards
a frame that has no skb->sk over an IPv6 tunnel mode xfrm bundle, and the
frame exceeds the MTU.
> diff --git a/net/ipv6/xfrm6_output.c b/net/ipv6/xfrm6_output.c
> index 44b221a09a0c8..d383116459089 100644
> --- a/net/ipv6/xfrm6_output.c
> +++ b/net/ipv6/xfrm6_output.c
> @@ -88,14 +88,14 @@ static int __xfrm6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
>
> toobig = skb->len > mtu && !skb_is_gso(skb);
>
> - if (toobig && xfrm6_local_dontfrag(sk)) {
> + if (toobig && xfrm6_local_dontfrag(skb_to_full_sk(skb))) {
> xfrm6_local_rxpmtu(skb, mtu);
> kfree_skb(skb);
> return -EMSGSIZE;
> } else if (toobig && xfrm6_noneed_fragment(skb)) {
> skb->ignore_df = 1;
> goto skip_frag;
> - } else if (!skb->ignore_df && toobig && sk) {
> + } else if (!skb->ignore_df && toobig && skb_to_full_sk(skb)) {
[Severity: High]
Does iptfs_is_too_big() in net/xfrm/xfrm_iptfs.c still have the same
mismatch? It tests the sk passed to dst_output(), not the frame's own
socket:
net/xfrm/xfrm_iptfs.c:iptfs_is_too_big() {
...
if (sk)
xfrm_local_error(skb, pmtu);
else if (ip_hdr(skb)->version == 4)
icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(pmtu));
...
}
IP-TFS states replace dst->output in xfrm_bundle_create():
dst1->output = xfrm[i]->mode_cbs->output;
As a result, __xfrm6_output() never runs for these frames, and the check
changed here does not cover them.
Take a frame forwarded into vxlan or geneve on an IPv6 underlay, routed
over an IP-TFS SA with dont_frag set:
udp_tunnel6_xmit_skb()
ip6tunnel_xmit(sock6->sk, ...)
ip6_local_out(net, sk, skb)
dst_output()
iptfs_output_collect(net, sk, skb)
iptfs_is_too_big(sk, skb, pmtu)
xfrm_local_error(skb, pmtu)
Here sk is the tunnel socket and skb->sk is NULL. Wouldn't
xfrm_local_error() then hit the same skb->sk->sk_family NULL dereference
shown in the trace in the commit message?
For IPv4, udp_tunnel_xmit_skb()->iptunnel_xmit()->ip_local_out() ends up
in xfrm4_local_error(). That function returns early because
skb_to_full_sk() is NULL. Since sk is non-NULL, the icmp_send() fallback
is skipped, so the frame seems to be dropped without a Frag Needed being
sent.
The subject says "use the frame's own socket in the too big checks", but
the commit message never mentions the IP-TFS site. It appears only in the
notes below the --- line, which won't go into git, even though two earlier
reviews pointed it out:
https://lore.kernel.org/all/20260908224856.1591189-1-kuba@kernel.org/
https://lore.kernel.org/all/179369310739.488856.16665150928122536725@kernel.org/
Could iptfs_is_too_big() get the same one line change to test
skb_to_full_sk(skb), either in this patch or in a companion patch?
[Severity: High]
This isn't a bug introduced by this patch, but this branch leads into
xfrm6_local_error(), which looks like it can leak kernel heap memory:
net/ipv6/xfrm6_output.c:xfrm6_local_error() {
...
hdr = skb->encapsulation ? inner_ipv6_hdr(skb) : ipv6_hdr(skb);
fl6.fl6_dport = inet_sk(sk)->inet_dport;
fl6.daddr = hdr->daddr;
...
}
Nothing checks that the inner packet is IPv6. The only family check is the
socket check in xfrm_local_error():
else if (skb->protocol == htons(ETH_P_IPV6) &&
skb->sk->sk_family == AF_INET6)
An AF_INET6 UDP socket connected to a v4-mapped address passes this check
while it sends IPv4 packets.
Suppose such a socket has IPV6_RECVERR set and sends through a vxlan
device whose IPv6 underlay is routed over an IPv6 tunnel mode ESP bundle.
vxlan advertises NETIF_F_SG | NETIF_F_HW_CSUM. With MSG_SPLICE_PAGES or
MSG_ZEROCOPY, __ip_append_data() takes the paged path. The linear head
then holds only the 20 byte IPv4 header and the 8 byte UDP header, with
CHECKSUM_PARTIAL.
Along the way:
- skb_scrub_packet() in the same netns keeps skb->sk and clears ignore_df.
- iptunnel_handle_offloads() keeps encapsulation set for CHECKSUM_PARTIAL,
and inner_network_header points at the inner IPv4 header.
- skb_tunnel_check_pmtu() returns 0 for local, non-bridged traffic.
Next, __xfrm6_output()->xfrm_local_error()->xfrm6_local_error() reads
hdr->daddr from offsets 24..39 of the inner IPv4 header. Bytes 24..27 are
the UDP length and checksum. Bytes 28..39 are past the skb tail, in
uninitialized tailroom of the head buffer.
ipv6_local_error() copies these bytes into the error skb. ip6_recv_error()
then returns them to userspace in sin6_addr when serr->port is non-zero,
which it is for a connected socket.
Can this expose up to 12 bytes of uninitialized slab memory per error to
an unprivileged user? It could be repeated, for example with
IP_PMTUDISC_PROBE so that every send exceeds the xfrm MTU.
Even without the paged path, isn't the reported address wrong, since an
IPv4 packet is being read as an ipv6hdr?
Before this patch, the local vxlan path already reached this code because
sk was the non-NULL tunnel socket. This patch keeps that path reachable;
it neither opens nor closes it.
> xfrm_local_error(skb, mtu);
> kfree_skb(skb);
> return -EMSGSIZE;
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123104236.4179425-1-rmustafin%40cloudlinux.com
prev parent reply other threads:[~2026-11-24 10:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 10:42 [PATCH ipsec v2] xfrm: use the frame's own socket in the too big checks Rustam Mustafin
2026-11-24 10:45 ` netdev-bot+sashiko [this message]
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=179551712630.3135.52212996809224784@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=ipsec@lists.linux.dev \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rmustafin@cloudlinux.com \
--cc=stable@vger.kernel.org \
--cc=steffen.klassert@secunet.com \
/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