Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1013453rwb; Fri, 28 Jul 2023 03:29:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlFFgHxbEUEUkAnhUdpVGlIWEDqHPtdi23GzbOeykOFUTfsJiA0jN5TeI2PfiqM9vqwj/kgk X-Received: by 2002:a17:902:82c8:b0:1b8:5aa1:4d10 with SMTP id u8-20020a17090282c800b001b85aa14d10mr1327031plz.54.1690540168975; Fri, 28 Jul 2023 03:29:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690540168; cv=none; d=google.com; s=arc-20160816; b=axOrdmLmTZHVG+R4yVUYdXDUI/eo0tsATuI5cht+6TrE43PHXK52q2GU89ugn4ilIz 7c3GvNiwaJTaepc6jeQDJnYCvvBpc0uGm4p7nwbcqVfR/i9fr+ZP5MuHpdyTcb7SmgWX c0IiMxPBG+/13+diHRdldTxXuE73TrtWvEfTSs5bV5xTS0lxOu8nxYiR1E7GeuwDsotM 2vJGzN2H3LTKr1KLZRWwxVrWCS4yjh7II4AVPzyQf1lQRmcDPKJqO81ylZuWyS6tHets HLf9QS5DrIALkZXi60SdZl12u2POCDs+ZxjxPeIMF4qKvhb4jJXn1YXk2IO4DpthnKyT RrJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=rtfkKPZAoag77n/xiLwX0AQkNPmTix3SlLwK0vO4h1I=; fh=JeXy3A7IZl/quCImKorQJ0+UjOEGHzScLCgKSNLV84M=; b=tCFvVXeGces3x9U7lXZ4vPJQL7iW6JVmPwg64EK8S8EJQkCe6hs73cFqlnQxN4st9J aLHJZPujUxJYDO3aiT9yAUn4abYFpp+G3hkej6EdyHqpe3WbIdf8PuRoiVXbwUR96lj9 GDCp30FV/493bpQ3ifyPg3FDWh4/9D0xYgkQQaSs//DG5KKA+Oml5Q/NwtkU7zNMFfxj OwYlunfNAwL+Po9coSJcuIMOr6FnMQYvWR217YJqwJmFBlVlfh9DnPaV+sduuh2ueTp4 tzkAjYK14rtV+cOBo9sBtkaNvwOPlJTd+0YXjmnR1fh+IelwSAWa2eDRGHia4RcY8ouP q+vQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l18-20020a170902d35200b001b9fef6bf58si2815565plk.294.2023.07.28.03.29.16; Fri, 28 Jul 2023 03:29:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235316AbjG1KCw (ORCPT + 99 others); Fri, 28 Jul 2023 06:02:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235627AbjG1KC3 (ORCPT ); Fri, 28 Jul 2023 06:02:29 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3BA446A2; Fri, 28 Jul 2023 03:01:55 -0700 (PDT) Received: from canpemm500007.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RC3683prdzVjn4; Fri, 28 Jul 2023 18:00:16 +0800 (CST) Received: from localhost (10.174.179.215) by canpemm500007.china.huawei.com (7.192.104.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 28 Jul 2023 18:01:53 +0800 From: Yue Haibing To: , , , , , CC: , , Yue Haibing Subject: [PATCH] ip6mr: Fix skb_under_panic in ip6mr_cache_report() Date: Fri, 28 Jul 2023 18:00:35 +0800 Message-ID: <20230728100035.32092-1-yuehaibing@huawei.com> X-Mailer: git-send-email 2.10.2.windows.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.179.215] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500007.china.huawei.com (7.192.104.62) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org skbuff: skb_under_panic: text:ffffffff88771f69 len:56 put:-4 head:ffff88805f86a800 data:ffff887f5f86a850 tail:0x88 end:0x2c0 dev:pim6reg ------------[ cut here ]------------ kernel BUG at net/core/skbuff.c:192! invalid opcode: 0000 [#1] PREEMPT SMP KASAN CPU: 2 PID: 22968 Comm: kworker/2:11 Not tainted 6.5.0-rc3-00044-g0a8db05b571a #236 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014 Workqueue: ipv6_addrconf addrconf_dad_work RIP: 0010:skb_panic+0x152/0x1d0 Call Trace: skb_push+0xc4/0xe0 ip6mr_cache_report+0xd69/0x19b0 reg_vif_xmit+0x406/0x690 dev_hard_start_xmit+0x17e/0x6e0 __dev_queue_xmit+0x2d6a/0x3d20 vlan_dev_hard_start_xmit+0x3ab/0x5c0 dev_hard_start_xmit+0x17e/0x6e0 __dev_queue_xmit+0x2d6a/0x3d20 neigh_connected_output+0x3ed/0x570 ip6_finish_output2+0x5b5/0x1950 ip6_finish_output+0x693/0x11c0 ip6_output+0x24b/0x880 NF_HOOK.constprop.0+0xfd/0x530 ndisc_send_skb+0x9db/0x1400 ndisc_send_rs+0x12a/0x6c0 addrconf_dad_completed+0x3c9/0xea0 addrconf_dad_work+0x849/0x1420 process_one_work+0xa22/0x16e0 worker_thread+0x679/0x10c0 ret_from_fork+0x28/0x60 ret_from_fork_asm+0x11/0x20 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 declar as this: void *skb_push(struct sk_buff *skb, unsigned int len); skb->data -= len; //0xffff888f5f86a84c - 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 --- net/ipv6/ip6mr.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index cc3d5ad17257..ee9c2ff8b0e4 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -1051,9 +1051,9 @@ static int ip6mr_cache_report(const struct mr_table *mrt, struct sk_buff *pkt, int ret; #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)); else #endif skb = alloc_skb(sizeof(struct ipv6hdr) + sizeof(*msg), GFP_ATOMIC); @@ -1073,7 +1073,8 @@ 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->data += nhoff; + skb->len -= nhoff; skb_push(skb, sizeof(*msg)); skb_reset_transport_header(skb); -- 2.34.1