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

From: YueHaibing
Date: Tue Aug 01 2023 - 02:29:04 EST


On 2023/8/1 11:09, Jakub Kicinski wrote:
> 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));

Thanks, will do this in v3.
>