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

From: Eric Dumazet
Date: Tue Aug 01 2023 - 03:51:47 EST


On Tue, Aug 1, 2023 at 8:45 AM Yue Haibing <yuehaibing@xxxxxxxxxx> wrote:
>
> skbuff: skb_under_panic: text:ffffffff88771f69 len:56 put:-4
> head:ffff88805f86a800 data:ffff887f5f86a850 tail:0x88 end:0x2c0 dev:pim6reg
>

> When setup a vlan device on dev pim6reg, DAD ns packet may sent on reg_vif_xmit().
> reg_vif_xmit()
> ip6mr_cache_report()
> skb_push(skb, -skb_network_offset(pkt));//skb_network_offset(pkt) is 4
> And skb_push declared as:
> void *skb_push(struct sk_buff *skb, unsigned int len);
> skb->data -= len;
> //0xffff88805f86a84c - 0xfffffffc = 0xffff887f5f86a850
> skb->data is set to 0xffff887f5f86a850, which is invalid mem addr, lead to skb_push() fails.
>
> Fixes: 14fb64e1f449 ("[IPV6] MROUTE: Support PIM-SM (SSM).")
> Signed-off-by: Yue Haibing <yuehaibing@xxxxxxxxxx>
> ---
> v3: drop unnecessary nhoff change
> v2: Use __skb_pull() and fix commit log.
> ---
> net/ipv6/ip6mr.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
> index cc3d5ad17257..67a3b8f6e72b 100644
> --- a/net/ipv6/ip6mr.c
> +++ b/net/ipv6/ip6mr.c
> @@ -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, skb_network_offset(pkt));
>
> skb_push(skb, sizeof(*msg));
> skb_reset_transport_header(skb);

Presumably this code has never been tested :/

Reviewed-by: Eric Dumazet <edumazet@xxxxxxxxxx>