Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2025393rwe; Fri, 2 Sep 2022 07:31:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Ehb3VoSJMVfNEy/F5/iioaatJJrhXK2XiMeSHxmLsP2tIdPLN3KJthPWZ44kmRNIRM3bi X-Received: by 2002:a05:6402:42c5:b0:448:913e:f16 with SMTP id i5-20020a05640242c500b00448913e0f16mr18917689edc.22.1662129063152; Fri, 02 Sep 2022 07:31:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662129063; cv=none; d=google.com; s=arc-20160816; b=otpdv6HtnBhNQMxWqbETKt75s84304dwZn41c/sBtsx5z1flGA1vb1IoPE5mQxDc4c V6r5PftfKUQUSq7gjKgkGIBGq7lzNiSSgqx2kbjbDSzbjd/cVlkWVZldZ0Uj93l3Suoo rG/R0oPlEKTMfaflKUkrzU0xmzsynyyeCyaX1S3jwmSpKHF6bKQK3O3ZCDZb7CELaJp9 QwgcUFgOZyL8f5q//t20q8JX+ikNKotnzds1UZWomk1yrGEX2uAoHARMOZjf/zz6rrnX VqUNEIKEn0UZ/7jEGF9FGZN71ktcuZb9irCnICKvMs7NziwVuX9ccIcB3yeu/QNEkRgf JAXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ht//7sQlS7jV3IyYr86H3W5qomJQG7Z1CCHIdCJ5s0k=; b=b22WB6GbFMkrN8I7uURg30Zm57TMn2l8EX/6gFmYgmpCLjn7ox0EO9M1hSjGmhFEbE 4LGsPJ9HyljEjapG1d9YeaHi7pCudVjTQLbcLE9fCaBfDKo9Ro4PV8jAeKLUBhju62az eilZnIsH9rJFqBfiZZmOtvWizJ7SUe5Blq3WHGFwv384njkXteChbi01bPqLd/QKXzoR +qi0WSBgnzm2YV56VAWPtX3BYP/tNjTFA75VgHlp4uUEBAsvfwwUI6t/ptuktPHZE+fA KUveYN5Ny/2NoM4DqpZbH9dzDi7YnMzjal8RcAJ1ohmnxcrr4HnzY0DW7j88yVQOmi4a jLhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1NS7oPuu; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dr4-20020a170907720400b00730aa3e3843si2107651ejc.131.2022.09.02.07.30.33; Fri, 02 Sep 2022 07:31:03 -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=@linuxfoundation.org header.s=korg header.b=1NS7oPuu; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236646AbiIBMbf (ORCPT + 99 others); Fri, 2 Sep 2022 08:31:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236287AbiIBMaz (ORCPT ); Fri, 2 Sep 2022 08:30:55 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB5A6DFB4F; Fri, 2 Sep 2022 05:26:07 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A5F94B82A93; Fri, 2 Sep 2022 12:23:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED5B1C433D7; Fri, 2 Sep 2022 12:23:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662121436; bh=2UKLF3KgzUGUMQjH0LyH0mhDriRRyZ5EqXbokM/8s8g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1NS7oPuu3dIHe0gBiTzepqMhlhq2DbUmxDkPLCJS1XiEcdOkL0dDdlo/dFfhVEWec xxlwZcRJN/AYhoZSD6mLwbqrW13Hyf4vIdih06o9pbOGYOdtbZLnqklNEBDMWVB/J6 7VRSxognrSKAqUjHqqfGgp4ylo9EMuzLKIPVslno= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Denis V. Lunev" , Yang Yingliang , Nikolay Aleksandrov , "David S. Miller" Subject: [PATCH 4.14 42/42] net: neigh: dont call kfree_skb() under spin_lock_irqsave() Date: Fri, 2 Sep 2022 14:19:06 +0200 Message-Id: <20220902121400.202901677@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220902121358.773776406@linuxfoundation.org> References: <20220902121358.773776406@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Yang Yingliang commit d5485d9dd24e1d04e5509916515260186eb1455c upstream. It is not allowed to call kfree_skb() from hardware interrupt context or with interrupts being disabled. So add all skb to a tmp list, then free them after spin_unlock_irqrestore() at once. Fixes: 66ba215cb513 ("neigh: fix possible DoS due to net iface start/stop loop") Suggested-by: Denis V. Lunev Signed-off-by: Yang Yingliang Reviewed-by: Nikolay Aleksandrov Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/core/neighbour.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -224,21 +224,27 @@ static int neigh_del_timer(struct neighb static void pneigh_queue_purge(struct sk_buff_head *list, struct net *net) { + struct sk_buff_head tmp; unsigned long flags; struct sk_buff *skb; + skb_queue_head_init(&tmp); spin_lock_irqsave(&list->lock, flags); skb = skb_peek(list); while (skb != NULL) { struct sk_buff *skb_next = skb_peek_next(skb, list); if (net == NULL || net_eq(dev_net(skb->dev), net)) { __skb_unlink(skb, list); - dev_put(skb->dev); - kfree_skb(skb); + __skb_queue_tail(&tmp, skb); } skb = skb_next; } spin_unlock_irqrestore(&list->lock, flags); + + while ((skb = __skb_dequeue(&tmp))) { + dev_put(skb->dev); + kfree_skb(skb); + } } static void neigh_flush_dev(struct neigh_table *tbl, struct net_device *dev)