__ip_options_compile() updates Record Route and Timestamp options in place. ipv4_send_dest_unreach() can receive skbs whose data is shared with clones (for example TC-mirred copies), and pskb_network_may_pull() does not unshare an already linear IPv4 header. Concurrent link-failure processing of such clones can therefore change an option pointer after it has been checked. For example, a Record Route pointer can advance during fib_compute_spec_dst() (called from spec_dst_fill()), causing the following write to overwrite the next option's length. __ip_options_echo() then trusts that length when building the ICMP reply, which can overflow both the stack reply-option buffer and the cork-option allocation. Make the header private before recompiling options, as ip_rcv_options() already does. If the copy fails, do not send the ICMP error. Fixes: ed0de45a1008 ("ipv4: recompile ip options in ipv4_link_failure") Reported-by: Kyle Zeng Signed-off-by: Eric Dumazet --- The issue was found by an AI code review agent. It was not reproduced, and the fix was only build-tested. net/ipv4/route.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 3a90c8d28b940bf615c165d9b30ac634943586e1..4d8fcc95c2f460585437b1f6fea4e4fd11d3a2f6 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); -- 2.53.0