Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1213432rwb; Fri, 28 Jul 2023 06:28:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlHWetlGlcdCcDVmp57dya+mvCx5Na6LGc+Q6r0EH5tI+iAtWjOTgoTNppVgK7PtyGlgrGjW X-Received: by 2002:a05:6a20:8423:b0:12f:acc9:286 with SMTP id c35-20020a056a20842300b0012facc90286mr2513330pzd.17.1690550925875; Fri, 28 Jul 2023 06:28:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690550925; cv=none; d=google.com; s=arc-20160816; b=Odzq43QWhR+JytRZHii8/OWRHL8GaCLLvdRJH76eHgSrm+sXw0dm1Bjh9udOuGE+bZ JbisjwpY8pRpnJTj6jfsWutWLQvT88jxNXh9yOcxyPxUAdOdSotI7ZJHJ5UtwwKmg9rA TQ70kuSznPMWapVPuXUMWZrm46/Xb3KK0/NIiykY29aVCY49HNIi/jzF3z3Tdc2j0w4K CVhGOmcieZH/Iem/fGzUSlyvgjhDEHKdTsZXVx4i3afPCq2B1Y8vkGmNcOwtFT+k+yMh pAffYW5C8RQ2z8xZnLJS0wADXeazHYcjyR+nrQUlt/V04ifs1MWWvFOgicrDDFaVxiqC 5yxQ== 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=gf7FHe3/9PxXOnq63BQuvMqFCHQV2PhjL/63x2jZiWw=; fh=5H+D1F5PWhZJ9I3cHmKgb9Pe0NqVof9fpkQDUXhpMOU=; b=ZMuhkK97g2rNCRTRz3gbtrV6/YO1UKlPSsxwUL+2ZghwmeD9Cn7q4BaATUc70ePo2g I9ze6fSVJ2AFl2cqn2HPnXxr6MbhQ8o7/e0YNr6TDUcUDQuGUqP+iN2Bke0C9sqnxPAT c/jIlJYkMH5Lmo41z6JWkGuenECIMVYk6OlwV0A16vaOIzCBGtO5Slb3SUC/VlOxK4TS ckreVhqj/JBNkV7tb0U+GDBX0ut1xh5K0TvtV4WVlat1YbI6u2SS+vRVfBgn08omK9bD ntt6JhE/VbnGEaFO+Af2ccY6sw0mUS06EkVNcK8pg18o+pyURpRkd3PWs5rlm7zPkp+m 9JpQ== 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 fj13-20020a056a003a0d00b0068257d11af3si3175995pfb.365.2023.07.28.06.28.33; Fri, 28 Jul 2023 06:28:45 -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 S236362AbjG1Mgo (ORCPT + 99 others); Fri, 28 Jul 2023 08:36:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232155AbjG1Mgn (ORCPT ); Fri, 28 Jul 2023 08:36:43 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79E2C2688; Fri, 28 Jul 2023 05:36:41 -0700 (PDT) Received: from canpemm500007.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RC66R6LsbzVjgR; Fri, 28 Jul 2023 20:15:43 +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 20:17:20 +0800 From: Yue Haibing To: , , , , , CC: , , , Yue Haibing Subject: [PATCH v2] ip6mr: Fix skb_under_panic in ip6mr_cache_report() Date: Fri, 28 Jul 2023 20:17:03 +0800 Message-ID: <20230728121703.29572-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: dggems704-chm.china.huawei.com (10.3.19.181) 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 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 --- v2: Use __skb_pull() and fix commit log. --- net/ipv6/ip6mr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index cc3d5ad17257..1a55d41feaa6 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,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); skb_push(skb, sizeof(*msg)); skb_reset_transport_header(skb); -- 2.34.1