Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1976367rwe; Fri, 2 Sep 2022 06:53:06 -0700 (PDT) X-Google-Smtp-Source: AA6agR5CuJa/9G//uO07/Vh+I5AvVzQBtZPxjr4807xqIl0uYR6iJIFu5iEYNzgd3SKqjL26u89d X-Received: by 2002:a63:4f10:0:b0:426:9c61:5e48 with SMTP id d16-20020a634f10000000b004269c615e48mr30137537pgb.360.1662126785776; Fri, 02 Sep 2022 06:53:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662126785; cv=none; d=google.com; s=arc-20160816; b=U8oxTnzr1PYTCdQHJIADN2bwCRSUQo51wQRD2+MGDKI32SFWBoI3nJspmz+lJ3kt5p RrmEH73H5ycCiQDK3ulhdUWp20qk6X4GgruuEI53X41YalBDfTFxHNYE/xXoAB/aCjFL 1qqdvlkntS7pintGIaJ9vDbX1oPPKZzRJ/3/B9eX/Cao15G7AR55cxY6u3IF2MoLOZmR NE2vEWjijzozo4BBtpyYuqoZG9Cpqux5B6kH30vclpfKfDmRcFmSRnLN/X2UwIA0+L8s xl5rJoAgOhU5PbiYgaYRP/IOaj2rkB00bVYoLCHgb7SaMNVb8OOny8VN+H5/XXA5Zi37 YrCw== 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=2VXZf6umBCCKX7D5mk8CGq4x9+iqc2HRMXWg7o67WNQ=; b=0bjMleW8Nw/J9vqjIsOsSI/KHqzk6Phvjnbn9kOO4AgFaYnf79/9HbrYQN9g3b9geL t75M9rjb7dx44kKh4Ms4cIaxj1G/z8FoZj85a7XZqfGaeDWFDmZtRbdCLpgmvWOGZk/Z KRVirnOCzLbU0ZHwl62QFvmYyCbj5YOsSPSo6Kkrkr4T40t6/fy7sfXsJCzEZivTgoiB rWSgZ9QMRNiLdYJpnV+DBFI6O2vgA1O4xJPASWJ8T1rkSYB6FF3W7QFfmsKg5dKXReE+ pIJhFPIw1I0vhvWXUcihJ4TpSAs5qnCgehtqsGOy/Qkge0uEo/jel16pI9oHrsbGml8W 23bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PHFR4M4X; 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 m16-20020a63ed50000000b0042b50f12acdsi1965248pgk.809.2022.09.02.06.52.54; Fri, 02 Sep 2022 06:53:05 -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=PHFR4M4X; 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 S238113AbiIBM4F (ORCPT + 99 others); Fri, 2 Sep 2022 08:56:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238145AbiIBMx6 (ORCPT ); Fri, 2 Sep 2022 08:53:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AF7AFB283; Fri, 2 Sep 2022 05:38:38 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 467B9621BE; Fri, 2 Sep 2022 12:38:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4085BC433D7; Fri, 2 Sep 2022 12:38:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662122283; bh=00xZHq6U7qCrjG64o3y4phGtvEuiCyaMCM7fk99aINc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PHFR4M4XrYPOrW6MzCOxINd0tA0SWnn7VNzNHcOQu5Oqn1UKZp8Dh+szrMjV2zgKj +HqDZMAsZ2U0bRTltTm3PVdC2gyWhboJXI+T8JdigMkxBWNsWfYPoBTdGKHXwELiyC iwPvTtnbOHDd0gZzrbJdzKAJkKgDsV9X3ylpsVvI= 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 5.19 71/72] net: neigh: dont call kfree_skb() under spin_lock_irqsave() Date: Fri, 2 Sep 2022 14:19:47 +0200 Message-Id: <20220902121407.136095177@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220902121404.772492078@linuxfoundation.org> References: <20220902121404.772492078@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 @@ -309,21 +309,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,