Re: [PATCH net v4 2/2] net: cap advertised IP tunnel headroom

Ido Schimmel <[email protected]>
Newsgroups gmane.linux.network
Message-ID <20260817064319.GB196908@shredder>
On Thu, Aug 13, 2026 at 12:22:35AM +0800, Zhiling Zou wrote:
> IP tunnel devices derive their advertised needed_headroom from lower
> output devices. A stack of user-created devices can make the derived
> value larger than the 16-bit skb header offsets can represent. Once IP
> output reserves it, skb head expansion can wrap those offsets.
> 
> The runtime transmit path already caps a growing needed_headroom at 512.
> Apply the same cap when tunnel configuration publishes needed_headroom
> derived from a lower output device.
> 
> Capping the advertised value is safe: IP tunnel transmit still expands
> the skb when a packet needs more headroom. A nonsensical stacked
> configuration can therefore incur an extra reallocation, but it cannot
> publish an unbounded reservation to upper layers.
> 
> Fixes: 1a37e412a022 ("net: Use 16bits for *_headers fields of struct skbuff")
> Cc: [email protected]
> Reported-by: Vega <[email protected]>
> Signed-off-by: Zhiling Zou <[email protected]>

Reviewed-by: Ido Schimmel <[email protected]>

[...]

> diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
> index 70c1710910203..200d0ba1a40e7 100644
> --- a/net/ipv6/ip6_gre.c
> +++ b/net/ipv6/ip6_gre.c
> @@ -1137,8 +1137,11 @@ static void ip6gre_tnl_link_config_route(struct ip6_tnl *t, int set_mtu,
>  			return;
>  
>  		if (rt->dst.dev) {
> -			dev->needed_headroom = rt->dst.dev->hard_header_len +
> -					       t_hlen;
> +			unsigned int headroom;
> +
> +			headroom = rt->dst.dev->hard_header_len + t_hlen;
> +			headroom = ip_tunnel_limit_headroom(headroom);
> +			dev->needed_headroom = headroom;

"
Can this clamp in ip6gre_tnl_link_config_route() ever fire?

[...]

So rt->dst.dev->hard_header_len + t_hlen stays in the tens of bytes and
never reaches 512, which would make the new call here dead code.
"

In patch #1 we fixed a bug where hard_header_len was summed across
multiple devices. If this bug ever reappears, ip_tunnel_limit_headroom()
will cap the headroom and it costs us nothing to include it here.

"
This isn't a bug introduced by this patch, the missing needed_headroom term
in ip6gre_tnl_link_config_route() predates it, but the patch adds a clamp on
top of it and makes the four sites look uniform while they compute different
quantities. Would it be clearer to either leave the ip6gre site alone or
mention in the changelog that ip6gre derives a different value?
"

See above.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.