From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AED63C0015E for ; Tue, 1 Aug 2023 06:29:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230034AbjHAG3D (ORCPT ); Tue, 1 Aug 2023 02:29:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229818AbjHAG3B (ORCPT ); Tue, 1 Aug 2023 02:29:01 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E269F19AA; Mon, 31 Jul 2023 23:28:32 -0700 (PDT) Received: from canpemm500007.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RFQ9r2JMzzVjrq; Tue, 1 Aug 2023 14:26:40 +0800 (CST) Received: from [10.174.179.215] (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; Tue, 1 Aug 2023 14:28:22 +0800 Subject: Re: [PATCH v2] ip6mr: Fix skb_under_panic in ip6mr_cache_report() To: Jakub Kicinski CC: , , , , , , , References: <20230728121703.29572-1-yuehaibing@huawei.com> <20230731200959.2019cb9c@kernel.org> From: YueHaibing Message-ID: Date: Tue, 1 Aug 2023 14:28:21 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <20230731200959.2019cb9c@kernel.org> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.179.215] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500007.china.huawei.com (7.192.104.62) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. >