From patchwork Wed Oct 21 16:49:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Rose X-Patchwork-Id: 1385649 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=shamt+NS; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CGc13389Lz9sPB for ; Thu, 22 Oct 2020 03:49:59 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id CC0D7864CD; Wed, 21 Oct 2020 16:49:57 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0ct0SFcPWRH9; Wed, 21 Oct 2020 16:49:54 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id E4DAE8651C; Wed, 21 Oct 2020 16:49:54 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id CA37EC08A1; Wed, 21 Oct 2020 16:49:54 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7C20FC0052 for ; Wed, 21 Oct 2020 16:49:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 4A9A787460 for ; Wed, 21 Oct 2020 16:49:52 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uu8LdRZn4Zh5 for ; Wed, 21 Oct 2020 16:49:51 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by hemlock.osuosl.org (Postfix) with ESMTPS id 412E287456 for ; Wed, 21 Oct 2020 16:49:51 +0000 (UTC) Received: by mail-pl1-f195.google.com with SMTP id t22so1492961plr.9 for ; Wed, 21 Oct 2020 09:49:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=k/TSKH3HUn5+yq/1QQEg3/OvwzEXy0jSWD4IGIoM4bI=; b=shamt+NSkXJngjieMzN73VaAoKmZDKLaFdjR5UdaFzQ+u7SKCNBrBJpOCG258WmPTK Ho+5mCkKKXugB3n8SqB94dK5DUu+CFznHifqGrgQahh56OpTLElQM40k1lW4vMBN6NKN QcTZSbTsX2racWcW4ZrOoVSCYWd+jkQEpNSmZiSZYOmkp5HlNORKBAjjFm2oKatdmaV2 JqxoC1tJQa6aE+hb9OVWdKujeO5SD1gcCUXpk6DUKWicUd/Qx03s9RG1mBGN02t6E7y7 37o/mg9d5k7POV35Gd7E3QzQZo/vf1btYczqkASXCHaXf61DJcTKvdHckCx5YjquoEkR iV5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=k/TSKH3HUn5+yq/1QQEg3/OvwzEXy0jSWD4IGIoM4bI=; b=rjpm1384kMQAFBpaf9Q5/W9q59RLijXx5V6K3t2t8PGBAli9stknchQ8jyku8dVoyS H64JSEf0qwNWNuYVA8i2/duNRCDEDjDElXHUwg1a6mebPk6KwdmRLyO5g5n2S1HfUR+n ifWUWTNqSU2tT3Q/0DmVCUmoI/qvKf1ieF8t7G76cabwXMWoFPFAlZHJbOfZ04QxWhAY v549hIPROJU+MZFLo7qvM6xwh6asHnbaxEQi5c0sAoJwbpy7YxOnSrfXqg9Zs7YvSlRl jrFRIDzYW/7+AfqsjHFSIg+uv8JJsEHaMQIkPxeVnvNeH0CWLj+NBvy/mcAl5b+oKQBB 7Kfg== X-Gm-Message-State: AOAM532RjYfIVWfKVcNlQwN9p+tuqTkf8g0OWI8zsZJjmZADNsCWDa07 j/6rokdMCTv6xDT1I06F5VBDBlFlO8s= X-Google-Smtp-Source: ABdhPJyC233Xm+P72xHfpHvv4hxaYzV8TgupoJWwY5QQOQpd2kDoVcuUqIWJdHOsqaN848c5kU8Xag== X-Received: by 2002:a17:902:ee0b:b029:d3:c8dc:6db8 with SMTP id z11-20020a170902ee0bb02900d3c8dc6db8mr4737643plb.55.1603298990593; Wed, 21 Oct 2020 09:49:50 -0700 (PDT) Received: from VMware-box.domain (97-115-80-55.ptld.qwest.net. [97.115.80.55]) by smtp.googlemail.com with ESMTPSA id j5sm2702297pjb.56.2020.10.21.09.49.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 09:49:50 -0700 (PDT) From: Greg Rose To: dev@openvswitch.org Date: Wed, 21 Oct 2020 09:49:40 -0700 Message-Id: <20201021164940.19894-3-gvrose8192@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201021164940.19894-1-gvrose8192@gmail.com> References: <20201021164940.19894-1-gvrose8192@gmail.com> Subject: [ovs-dev] [PATCH 2/2] datapath: ovs_ct_exit to be done under ovs_lock X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Tonghao Zhang Upstream commit: commit 27de77cec985233bdf6546437b9761853265c505 Author: Tonghao Zhang Date: Fri Apr 17 02:57:31 2020 +0800 net: openvswitch: ovs_ct_exit to be done under ovs_lock syzbot wrote: | ============================= | WARNING: suspicious RCU usage | 5.7.0-rc1+ #45 Not tainted | ----------------------------- | net/openvswitch/conntrack.c:1898 RCU-list traversed in non-reader section!! | | other info that might help us debug this: | rcu_scheduler_active = 2, debug_locks = 1 | ... | | stack backtrace: | Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.0-0-ga698c8995f-prebuilt.qemu.org 04/01/2014 | Workqueue: netns cleanup_net | Call Trace: | ... | ovs_ct_exit | ovs_exit_net | ops_exit_list.isra.7 | cleanup_net | process_one_work | worker_thread To avoid that warning, invoke the ovs_ct_exit under ovs_lock and add lockdep_ovsl_is_held as optional lockdep expression. Link: https://lore.kernel.org/lkml/000000000000e642a905a0cbee6e@google.com Fixes: 11efd5cb04a1 ("openvswitch: Support conntrack zone limit") Cc: Pravin B Shelar Cc: Yi-Hung Wei Reported-by: syzbot+7ef50afd3a211f879112@syzkaller.appspotmail.com Signed-off-by: Tonghao Zhang Acked-by: Pravin B Shelar Signed-off-by: David S. Miller Cc: Tonghao Zhang Fixes: cb2a5486a3a3 ("datapath: conntrack: Support conntrack zone limit") Signed-off-by: Greg Rose Acked-by: Tonghao Zhang --- datapath/conntrack.c | 3 ++- datapath/datapath.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/datapath/conntrack.c b/datapath/conntrack.c index c7a318baf..50b4d7bd6 100644 --- a/datapath/conntrack.c +++ b/datapath/conntrack.c @@ -1984,7 +1984,8 @@ static void ovs_ct_limit_exit(struct net *net, struct ovs_net *ovs_net) struct hlist_head *head = &info->limits[i]; struct ovs_ct_limit *ct_limit; - hlist_for_each_entry_rcu(ct_limit, head, hlist_node) + hlist_for_each_entry_rcu(ct_limit, head, hlist_node, + lockdep_ovsl_is_held()) kfree_rcu(ct_limit, rcu); } kfree(ovs_net->ct_limit_info->limits); diff --git a/datapath/datapath.c b/datapath/datapath.c index 52a59f135..97ba5fb72 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -2576,8 +2576,10 @@ static void __net_exit ovs_exit_net(struct net *dnet) ovs_netns_frags6_exit(dnet); ovs_netns_frags_exit(dnet); - ovs_ct_exit(dnet); ovs_lock(); + + ovs_ct_exit(dnet); + list_for_each_entry_safe(dp, dp_next, &ovs_net->dps, list_node) __dp_destroy(dp);