From: sashiko-bot@kernel.org
Cc: linux-security-module@vger.kernel.org
Subject: Re: [PATCH net 1/2] ipv4: unshare headers before recompiling IP options in ipv4_send_dest_unreach()
Date: Sat, 07 Nov 2026 23:43:37 +0000 [thread overview]
Message-ID: <sashiko-outbox-203398@kernel.org> (raw)
In-Reply-To: <20261106234313.2537882-2-edumazet@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] ipv4: dangling header pointers in ip_tunnel_xmit() after
skb_unclone()
--
commit b978ee14726a511c1195a618445671504ee53c90
Author: Eric Dumazet <edumazet@kernel.org>
ipv4: unshare headers before recompiling IP options in ipv4_send_dest_unreach()
This commit calls skb_unclone() in ipv4_send_dest_unreach() before
recompiling IPv4 options so that in-place option updates do not race on
shared packet headers.
> diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> index 3a90c8d28b940..4d8fcc95c2f46 100644
> --- a/net/ipv4/route.c
> +++ b/net/ipv4/route.c
> @@ -1269,7 +1269,8 @@ static void ipv4_send_dest_unreach(struct sk_buff *skb)
>
> memset(&parm, 0, sizeof(parm));
> if (ip_hdr(skb)->ihl > 5) {
> - if (!pskb_network_may_pull(skb, ip_hdr(skb)->ihl * 4))
> + if (!pskb_network_may_pull(skb, ip_hdr(skb)->ihl * 4) ||
> + skb_unclone(skb, GFP_ATOMIC))
> return;
> parm.opt.optlen = ip_hdr(skb)->ihl * 4 - sizeof(struct iphdr);
[Severity: High]
Can calling skb_unclone() here leave dangling header pointers in callers of
dst_link_failure()?
ip_tunnel_xmit() caches inner_iph into skb->head before calling
dst_link_failure() -> ipv4_link_failure() -> ipv4_send_dest_unreach(), and
only calls skb_cow_head() afterwards:
net/ipv4/ip_tunnel.c:ip_tunnel_xmit() {
inner_iph = (const struct iphdr *)skb_inner_network_header(skb);
...
dst_link_failure(skb);
} else {
WRITE_ONCE(tunnel->err_count, 0);
}
}
tos = ip_tunnel_ecn_encap(tos, inner_iph, skb);
ttl = tnl_params->ttl;
if (ttl == 0) {
if (payload_protocol == htons(ETH_P_IP))
ttl = inner_iph->ttl;
}
When a cloned linear skb with IPv4 options (such as a TCP packet or a
TC-mirred clone transmitted over IPIP, SIT, or NBMA GRE while
tunnel->err_count > 0) hits dst_link_failure(), skb_unclone() reallocates
skb->head via pskb_expand_head() and drops the reference to the old buffer.
After dst_link_failure() returns, ip_tunnel_xmit() dereferences the stale
inner_iph (and tnl_params from ipgre_xmit()), causing a use-after-free read
if the other clone was freed. A similar pattern exists in
ipip6_tunnel_xmit() with iph6 when skb_unclone() clears skb_cloned(skb) and
causes the skb_realloc_headroom() branch to be skipped.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261106234313.2537882-1-edumazet@kernel.org?part=1
next prev parent reply other threads:[~2026-11-07 23:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 23:43 [PATCH net 0/2] ipv4: unclone skbs before recompiling IP options Eric Dumazet
2026-11-06 23:43 ` [PATCH net 1/2] ipv4: unshare headers before recompiling IP options in ipv4_send_dest_unreach() Eric Dumazet
2026-11-07 23:43 ` sashiko-bot [this message]
2026-11-08 0:12 ` netdev-bot+sashiko
2026-11-09 13:09 ` Eric Dumazet
2026-11-06 23:43 ` [PATCH net 2/2] cipso: unshare headers before recompiling IP options in cipso_v4_error() Eric Dumazet
2026-11-07 23:43 ` sashiko-bot
2026-11-09 21:41 ` Paul Moore
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=sashiko-outbox-203398@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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