Re: [PATCH v2] ip6mr: Fix skb_under_panic in ip6mr_cache_report()

From: Jakub Kicinski
Date: Mon Jul 31 2023 - 23:10:06 EST


On Fri, 28 Jul 2023 20:17:03 +0800 Yue Haibing wrote:
> #ifdef CONFIG_IPV6_PIMSM_V2
> + int nhoff = skb_network_offset(pkt);
> if (assert == MRT6MSG_WHOLEPKT || assert == MRT6MSG_WRMIFWHOLE)
> - skb = skb_realloc_headroom(pkt, -skb_network_offset(pkt)
> - +sizeof(*msg));
> + skb = skb_realloc_headroom(pkt, -nhoff + sizeof(*msg));

These changes look unnecessary. You can leave this code be (as ugly as
it is)...

> else
> #endif
> skb = alloc_skb(sizeof(struct ipv6hdr) + sizeof(*msg), GFP_ATOMIC);
> @@ -1073,7 +1073,7 @@ static int ip6mr_cache_report(const struct mr_table *mrt, struct sk_buff *pkt,
> And all this only to mangle msg->im6_msgtype and
> to set msg->im6_mbz to "mbz" :-)
> */
> - skb_push(skb, -skb_network_offset(pkt));
> + __skb_pull(skb, nhoff);

.. and just replace the push here with:

__skb_pull(skb, skb_network_offset(pkt));
--
pw-bot: cr