Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1304631pxp; Thu, 17 Mar 2022 07:01:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaeBkTA7aBGZxb4o2vfJ1CF2b3fHOZljUcd7P1eAtoggn7io92ebEPBP11tEvFjPIlnaBW X-Received: by 2002:a17:902:ce02:b0:151:a86d:dc2b with SMTP id k2-20020a170902ce0200b00151a86ddc2bmr5344379plg.57.1647525680120; Thu, 17 Mar 2022 07:01:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647525680; cv=none; d=google.com; s=arc-20160816; b=OcIoPuzhcbltR/G0RRF7odAT5d6h5gDBoOq5f4GpbKG3QOu0p4k854r4MZawJZZ3c0 X1602zF24M6V5erTM6+t1gyweiet3ohVOTWeSVgEYG7/ovMlFRlIiTeJUxLgcfiT2aSf FqMe1tZU9crk+uOqZFfgyG3gQGhw6qnUh+ZEP7QU491UjSOACwLR+QM+y9lhjxAC4ts+ XkvwYLaR9sXVKmrcqnD+Wl1CP0LrfeCMzG7XWMVWEO0rLGRK8QPcPkwq+cO/Dqm7Q9i5 LfUe1KRWr6rjtrYTiMB5FlvY8XqhbOZft3GGlQB48UZEgvEC4EkcoFYtZFgLxRkmQNCh zyOw== 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=sot3hbTJo/GvgBGWlV7OnsbDnCQ7Fgk0l0kAk2qH8rM=; b=iBGwPDg31vLTGgFrJgKELfMAeNEg7hilBHFUlWhHvUYlD/2F3cQpeOFSZ18e0XllS2 ST8RH2G18pm2j2s1E+orL4Bg2EYZRpVcWhcWZ25VoCJ4iiyeaal9oXKRU2Ju3m5gQIhq rshIc77++RVdDAeKx3/UYNQI1glWENUoTfeemZirImjX+HdoqEWeZj/O3e9ff72tSxyc Gehqkd6+2t1O3zwQAbPBpMZsMF+pP98BFtbm0Rw0B/mnDN3uEaVxhmSjkhMgeLW4yVd8 fjFuUdjUTu2l4qy5wnrWOwjOIH9pLahv5pB8RdTqvnXUIHBXADQJmSK0Le6u0Xox9doD sQwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GCWssIRf; 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 r23-20020a17090aa09700b001bf085cf895si8313863pjp.39.2022.03.17.07.01.03; Thu, 17 Mar 2022 07:01:20 -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=GCWssIRf; 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 S234747AbiCQM6E (ORCPT + 99 others); Thu, 17 Mar 2022 08:58:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235016AbiCQMyX (ORCPT ); Thu, 17 Mar 2022 08:54:23 -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 B94FB1EC6D; Thu, 17 Mar 2022 05:53: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 dfw.source.kernel.org (Postfix) with ESMTPS id 57B1E61578; Thu, 17 Mar 2022 12:53:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34AE9C340E9; Thu, 17 Mar 2022 12:53:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647521586; bh=yv24BEIQB2Wa9G21wq5trSJnLc3FQVzB/HOeXIspnWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GCWssIRfFt7sPSBBx3n8wRbQtkSr84RgCLDw1ijymaxg6AxsVAurp9TYLoczn29bS DhAwupciTm+SxqJp3yK9llc5pvSM61TFNkS80HLyUGg2BhANZV5DwrB1tg7LevIOeu itNTrQLjOfDSItVkL3buf/D4bc1Xng3ijuuRH8js= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Florian Westphal , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.16 18/28] netfilter: egress: silence egress hook lockdep splats Date: Thu, 17 Mar 2022 13:46:09 +0100 Message-Id: <20220317124527.285482124@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220317124526.768423926@linuxfoundation.org> References: <20220317124526.768423926@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.6 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: Florian Westphal [ Upstream commit 17a8f31bba7bac8cce4bd12bab50697da96e7710 ] Netfilter assumes its called with rcu_read_lock held, but in egress hook case it may be called with BH readlock. This triggers lockdep splat. In order to avoid to change all rcu_dereference() to rcu_dereference_check(..., rcu_read_lock_bh_held()), wrap nf_hook_slow with read lock/unlock pair. Reported-by: Eric Dumazet Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- include/linux/netfilter_netdev.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/netfilter_netdev.h b/include/linux/netfilter_netdev.h index b4dd96e4dc8d..e6487a691136 100644 --- a/include/linux/netfilter_netdev.h +++ b/include/linux/netfilter_netdev.h @@ -101,7 +101,11 @@ static inline struct sk_buff *nf_hook_egress(struct sk_buff *skb, int *rc, nf_hook_state_init(&state, NF_NETDEV_EGRESS, NFPROTO_NETDEV, dev, NULL, NULL, dev_net(dev), NULL); + + /* nf assumes rcu_read_lock, not just read_lock_bh */ + rcu_read_lock(); ret = nf_hook_slow(skb, &state, e, 0); + rcu_read_unlock(); if (ret == 1) { return skb; -- 2.34.1