Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp198974rwb; Thu, 18 Aug 2022 02:06:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR5diPfAtu9WFhBY0YG3G8bziu24lA2WHv+YhYUYrwz/n/2sM6wTggFp4V+XNVuEoNB0m5Vp X-Received: by 2002:a65:4501:0:b0:3fc:4895:283b with SMTP id n1-20020a654501000000b003fc4895283bmr1793878pgq.231.1660813597811; Thu, 18 Aug 2022 02:06:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1660813597; cv=pass; d=google.com; s=arc-20160816; b=NQL9B43QIy0Ruwltk7PAHPrjS3d5R9GYPV3vaaBYi6twFlaVBPsvrpvf8+/MSHsqg2 jKiyxNcWxQCgbloXewPZV4EcSkszgX77opwF6s2K9x1frXXlfnDVTht52lF2AB3zMXdQ I2QeFK3KLlQZLETr+r7CDQP/6q25XNb8UffNHNP/wLe0owk6hv9haDgD6eFwdd4ZNnlr SGVvjXjz4hpqi8GXzB+9O6Mr1ivf8pCv0w6zLDMLOOiTBhakWyieYLmQSxiA4xVxv2w3 ypyDyJ1NwxqYCGqBptuarWf0SKItfWZ6o23rbWpzOpdqcqkD+xFbAYsUTyMYSRlhS8Lf OCYA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=mctnCNvtzl1cn2MrdBNwOZaqRf0nHPHZsIZnbY1ODe8=; b=Rl2fEnNU/3Ui3SEqLo04fbFoCPXdtdNuXwLwKjEiuY80r0m1XLzxYL9LmaPt01RnUE tY8n4+QkNOUdngILNVsvw4s543Uq+D6Nl2UQ/5ZeAJ/RgHzDaVNPuc/77Y3a8WuMVjKO QOrora1nO0NxcSYBp0P6Dmsvd1lO1AvLp0OKQgIo0+a6ZWUB6r2yRI4ScZovAJf4Z+bo o6TiDn0H0k2m1jXEK0tfhq7a3hPcP7fRTIK402DYHWDe0pyOf0ngQthhnFVbBF12Stu2 rRfCXOwXQ+WWQRSabV2m5n49Asu1MAJ6qeag1hDAk1oFDusoyQ0LuGdsJXhWGkqvducn 2i1g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector2 header.b="wa8OG/GA"; arc=pass (i=1 spf=pass spfdomain=virtuozzo.com dkim=pass dkdomain=virtuozzo.com dmarc=pass fromdomain=virtuozzo.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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oa8-20020a17090b1bc800b001f51f0d3737si1122698pjb.132.2022.08.18.02.06.26; Thu, 18 Aug 2022 02:06:37 -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; dkim=pass header.i=@virtuozzo.com header.s=selector2 header.b="wa8OG/GA"; arc=pass (i=1 spf=pass spfdomain=virtuozzo.com dkim=pass dkdomain=virtuozzo.com dmarc=pass fromdomain=virtuozzo.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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241906AbiHRJAU (ORCPT + 99 others); Thu, 18 Aug 2022 05:00:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235263AbiHRJAS (ORCPT ); Thu, 18 Aug 2022 05:00:18 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60106.outbound.protection.outlook.com [40.107.6.106]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 699D7AE9D7; Thu, 18 Aug 2022 02:00:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ViFcmJiR7+bRSVzgMHpZKSTuYhJ/gVUETMyn6+pFININKU1xRFzixJh0vlVVPhKs1Pk2PMCZUYgKvV23NVM/BMFUeTOtG+9HjrZyVTIBaZ1l4WzPSDBf52dWHkTTXIrgyI/HBrgTqQN+DMyutc6j8BalPdecCBcyJcIJn1hhmvPhul06PtCNJxOObrrmKEikF9ef8iWSsADaaiT1U4P/pJ9G2IoZMSRJG0OcU34/5j1OhMflQn+AcNQi/m8Ha3d0eE3Pa7YbrDHPRijWa9RXGwpjNbM3JRv2pF0Yz/3R+oKkCNnWlr6H4cyCPZe7Uppw99eap8hnIu0FoOF9glc2Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mctnCNvtzl1cn2MrdBNwOZaqRf0nHPHZsIZnbY1ODe8=; b=g/RPj3XuVzRyt4KcLZdOHC4lK4TUPbFgFRNJZpdkC+V8/kMYqzMgnNZwocY66kLaaGbDuSz10XCUQdlx3RvfFFZB4YjfluaN8jqpzXrocHiE1qmao1FMgkERWz4Teu0NoE94Nobi58p+a+w/vcYfEC9sprv015ZalWi3aSYMXz42jxjAGoM8JFOhg7r1xQJqEKVbNk/YxXBqEmlhAif2Ueuzd/Zv4jh06RYixUxNza905uXVRKobOXxN1U2eZe1swzCeRjxa3aU8I4cxE2TSgCcDkBbu/pa+0ARWdV9e23H6hNpvtjU12nylyIf5grDp5NAGzgCDKIP+jQVgtcYX5Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mctnCNvtzl1cn2MrdBNwOZaqRf0nHPHZsIZnbY1ODe8=; b=wa8OG/GAC7Sbj0zkbV1e6RijRB3cOhPdGFeaZzWn9Nrx1zbIuueYWOswd+qQnMjXswIoG++oiTW3fS3ggS+SsT7lJJWwQyV0Ah8W9/fdKMwO933Wjh0P5raS6+NmRnm3zYLnptfcHuDqNKDSjTNTS/hIOCQeggb/vjDXGlFLvBx8dJH6Vz1+tZQIiJEb6LL8FaKZada6klHBwL4/vQQfRiGPiT85wYTYQi8ZqqbVFMGDTQckRuOa2YHa/dlzldsu02f1bp/6+hIf/4T3fLGnDMXG/TPJE/+CZdB6PALqoX+fX7DOJuShR1fzqZwGujf57RH06UuWs4RT3aqaG37rcA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from PAXPR08MB6956.eurprd08.prod.outlook.com (2603:10a6:102:1db::9) by DBBPR08MB4917.eurprd08.prod.outlook.com (2603:10a6:10:f1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10; Thu, 18 Aug 2022 09:00:15 +0000 Received: from PAXPR08MB6956.eurprd08.prod.outlook.com ([fe80::813d:902d:17e5:499d]) by PAXPR08MB6956.eurprd08.prod.outlook.com ([fe80::813d:902d:17e5:499d%4]) with mapi id 15.20.5504.028; Thu, 18 Aug 2022 09:00:15 +0000 Message-ID: <79784952-0d15-8a4a-aa8d-590bc243ab5e@virtuozzo.com> Date: Thu, 18 Aug 2022 11:00:13 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH -next] net: neigh: use dev_kfree_skb_irq instead of kfree_skb() Content-Language: en-US To: Yang Yingliang , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org References: <20220818043729.412753-1-yangyingliang@huawei.com> From: "Denis V. Lunev" In-Reply-To: <20220818043729.412753-1-yangyingliang@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: VI1PR09CA0081.eurprd09.prod.outlook.com (2603:10a6:802:29::25) To PAXPR08MB6956.eurprd08.prod.outlook.com (2603:10a6:102:1db::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b1ef3a33-5120-412b-01d6-08da80f810f8 X-MS-TrafficTypeDiagnostic: DBBPR08MB4917:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tg8dD+sHngFzLdl3PG5nWM57auptgrW1FNv7TcyQbwJ+5uqxwUOMsxJha2Jlnroo00mL78Y7aBa0yWhchuje8f1jy+p2prTytz1Cj4wRIKTtk6/BYxmVcOZDVzgaGQ3Bi80ZJGZZ6x8HhuOnHul11MZ1MB9lhjgKgmm6N7aPy8bF6gNniaIcWXVMrJnnyu2I3e8WjE+j77po428By2O+eonWp0Puz1GhzWwxn4jcNJBSu2UlCrTFqWCq8cfavViFGQbjvZx+iuz0UX831BlJi/MKw+h+8a8PwCndlFyk/i+Vzy2Op9LAa4FYLK8Ho8JvWlUOMfJF42MxD2D0LeWcFQC4f/Bmfhkr21bh34LTtcGpDROMlrjTpdKIP3jU/t80Lc7KtpxfTqHyJnKU2AJPIhnT0GNE81OaIceyRdfuBhCObeJGjk5wRlEsBs5yk5Kku5lxw/jjZp4iYCIzh0OO1S/hKYBuX3iT8w2wsCN3XZu3iDOq0MKi7ifA859teALzg8IumFJOgKA+Tf7HXCr3ocYxPFBCKleTNNn6txdOroE3hNB3fUXyzYYxeToZN7MSdmOe/ZzLtAVVlvuMUJVHRXeXkoelEMBIIcaYJpA8Z6xAgK1cIjdKQ5Vg4YiWPi1saljoE2DCdzqQBn9PcRFC+ZCR4wlImv+jSh9f2GfD5s1mSyDKCDZHtEJKb4ztndnvm7WymLGTJ3qwnWOZSG6Lv8v8+JsXjQqRPengDwTxXz2PBpz66eybsdD5yH+LMSIQzpclgJ75mkc8KfMxJbdpCRHuzVMYNEejczcqhgs2DAsnLgDu/8T4Owmb7zp9m6ztuLRwLBRp4Wa2n6aXXYK+Iw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR08MB6956.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(346002)(376002)(39850400004)(366004)(396003)(136003)(4326008)(66556008)(8676002)(66946007)(66476007)(2906002)(26005)(31686004)(31696002)(186003)(6512007)(41300700001)(2616005)(38350700002)(316002)(83380400001)(86362001)(38100700002)(36756003)(6506007)(5660300002)(52116002)(53546011)(8936002)(6486002)(478600001)(45980500001)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?YmtUcE1EUFZoQXNUOWFRL0FYUHQ4NW9CNklGOHEyUkc2VExJN3ljSzRKUVNG?= =?utf-8?B?ZXA4Vi80U1FHWkNHdGJMcC9Rc1hLc0QvMFdGUUJGa2pVNlFHRDAzNmExL1ZY?= =?utf-8?B?RVBZQ2hKa0hhNWF5V2VoYVlFcWtJcXdCWTEvWFFlaC8xaEVNZCtiWTk1bEI1?= =?utf-8?B?K29hNkoxSk8va3FzZ3NmTHo5V2JrMGRoWW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2RVV1BZa2ZXZ2FINXVFVXNkVUpOV25VZ0hBWTdhRkMwZkk1NE4yTitB?= =?utf-8?B?QTlCdE5BWDRBYlNmSExpR0tvdUU3NThqZmQzZ1BPanRVZ2J0dWNiTUJxVnhX?= =?utf-8?Q?xoTC51gui1qBUmS/FW+LTvWaM?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b1ef3a33-5120-412b-01d6-08da80f810f8 X-MS-Exchange-CrossTenant-AuthSource: PAXPR08MB6956.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2022 09:00:15.2217 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HskiSvlzwvj7yyVYhzzEjEgkj8dFA2T8joLxfUVvAiFFES8I6XrrBRJgjLZdLvamik4rRfgKb+wcjMPsLIaOvg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4917 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no 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 On 18.08.2022 06:37, 'Yang Yingliang' via den wrote: > It is not allowed to call kfree_skb() from hardware interrupt > context or with interrupts being disabled. So replace kfree_skb() > with dev_kfree_skb_irq() under spin_lock_irqsave(). > > Fixes: 66ba215cb513 ("neigh: fix possible DoS due to net iface start/stop loop") > Signed-off-by: Yang Yingliang > --- > net/core/neighbour.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/core/neighbour.c b/net/core/neighbour.c > index 5b669eb80270..167826200f3e 100644 > --- a/net/core/neighbour.c > +++ b/net/core/neighbour.c > @@ -328,7 +328,7 @@ static void pneigh_queue_purge(struct sk_buff_head *list, struct net *net) > __skb_unlink(skb, list); > > dev_put(dev); > - kfree_skb(skb); > + dev_kfree_skb_irq(skb); > } > skb = skb_next; > } Technically this is pretty much correct, but would it be better to move all skb to purge into the new list and after that purge them at once? what about something like this? diff --git a/net/core/neighbour.c b/net/core/neighbour.c index aa16a8017c5e..f7e30daa46ae 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -311,6 +311,9 @@ static void pneigh_queue_purge(struct sk_buff_head *list, struct net *net)  {         unsigned long flags;         struct sk_buff *skb; +       struct sk_buff_head tmp; + +       skb_queue_head_init(&tmp);         spin_lock_irqsave(&list->lock, flags);         skb = skb_peek(list); @@ -318,12 +321,16 @@ static void pneigh_queue_purge(struct sk_buff_head *list, struct net *net)                 struct sk_buff *skb_next = skb_peek_next(skb, list);                 if (net == NULL || net == dev_net(skb->dev)) {                         __skb_unlink(skb, list); -                       dev_put(skb->dev); -                       kfree_skb(skb); +                       __skb_queue_tail(&tmp, skb);                 }                 skb = skb_next;         } while (skb != NULL);         spin_unlock_irqrestore(&list->lock, flags); + +       while ((skb = __skb_dequeue(&tmp)) != NULL) { +               dev_put(skb->dev); +               kfree_skb(skb); +       }  } iris ~/src/linux-2.6 $