Message ID | 20240222140321.14080-1-fw@strlen.de (mailing list archive) |
---|---|
State | Accepted |
Commit | 025f8ad20f2e3264d11683aa9cbbf0083eefbdcd |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net,v2] net: mpls: error out if inner headers are not set | expand |
On Thu, 22 Feb 2024 15:03:10 +0100 Florian Westphal wrote:
> Fixes: 219eee9c0d16 ("net: skbuff: add overflow debug check to pull/push helpers")
This is for net-next, right?
Jakub Kicinski <kuba@kernel.org> wrote: > On Thu, 22 Feb 2024 15:03:10 +0100 Florian Westphal wrote: > > Fixes: 219eee9c0d16 ("net: skbuff: add overflow debug check to pull/push helpers") > > This is for net-next, right? Yes, indeed, this is better suited for net-next.
Hello: This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <kuba@kernel.org>: On Thu, 22 Feb 2024 15:03:10 +0100 you wrote: > mpls_gso_segment() assumes skb_inner_network_header() returns > a valid result: > > mpls_hlen = skb_inner_network_header(skb) - skb_network_header(skb); > if (unlikely(!mpls_hlen || mpls_hlen % MPLS_HLEN)) > goto out; > if (unlikely(!pskb_may_pull(skb, mpls_hlen))) > > [...] Here is the summary with links: - [net,v2] net: mpls: error out if inner headers are not set https://git.kernel.org/netdev/net-next/c/025f8ad20f2e You are awesome, thank you!
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 28c7cb7ce251..1470b74fb6d2 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -2894,6 +2894,11 @@ static inline void skb_set_inner_network_header(struct sk_buff *skb, skb->inner_network_header += offset; } +static inline bool skb_inner_network_header_was_set(const struct sk_buff *skb) +{ + return skb->inner_network_header > 0; +} + static inline unsigned char *skb_inner_mac_header(const struct sk_buff *skb) { return skb->head + skb->inner_mac_header; diff --git a/net/mpls/mpls_gso.c b/net/mpls/mpls_gso.c index 533d082f0701..45d1e6a157fc 100644 --- a/net/mpls/mpls_gso.c +++ b/net/mpls/mpls_gso.c @@ -27,6 +27,9 @@ static struct sk_buff *mpls_gso_segment(struct sk_buff *skb, __be16 mpls_protocol; unsigned int mpls_hlen; + if (!skb_inner_network_header_was_set(skb)) + goto out; + skb_reset_network_header(skb); mpls_hlen = skb_inner_network_header(skb) - skb_network_header(skb); if (unlikely(!mpls_hlen || mpls_hlen % MPLS_HLEN))