From patchwork Thu Apr 16 18:57:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 1272833 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.133; helo=hemlock.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=comv+33c; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 494jzv1W30z9sPF for ; Sun, 19 Apr 2020 18:44:11 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 969A48790D; Sun, 19 Apr 2020 08:44:09 +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 39OPIM6ss7+C; Sun, 19 Apr 2020 08:44:08 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id D40D68788E; Sun, 19 Apr 2020 08:44:08 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id B6EBFC07FF; Sun, 19 Apr 2020 08:44:08 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1FA53C0177 for ; Sun, 19 Apr 2020 08:44:07 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 037C686457 for ; Sun, 19 Apr 2020 08:44:07 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pek+waYM2WYm for ; Sun, 19 Apr 2020 08:44:06 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by whitealder.osuosl.org (Postfix) with ESMTPS id 5BD1C86418 for ; Sun, 19 Apr 2020 08:44:06 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id x3so3409745pfp.7 for ; Sun, 19 Apr 2020 01:44:06 -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=HDuwLvARoJkJSZwVdQdf+z8zoIZqWqA2KSZFSJiI1jU=; b=comv+33cklPlMXpi4bCNur7Oo3aADIMts7dmwACmm3ub+sdNLPXwxZDyNAhfSitd/F bKAhwHPvtlZegevxRat3R0koR84Ihtz6tYRBbvA+Sg62uKlmIOK66q+20w0E7Oyr1lv8 LdBkELb7B1nxAWDz+dCvXmy3CMLGXZj+lx+80Dx4w3VJBjt1ZH8prbw459J7LQnIxrM5 E5ipyumMQjbAgWTPbLUkN/foJuGo7pOK2Hynz5aazW6SnVtMdmf3JY6Wc2NwSPiU5xfS 2842X8uPrBGcJpK2rF+Gzj5I+ZwGUBgxlXOFwfSh1cuonSwdvHlzXDO2QPA2SKc+ZAy0 tHbw== 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=HDuwLvARoJkJSZwVdQdf+z8zoIZqWqA2KSZFSJiI1jU=; b=sE6ppljuBDq/iBv/YrKNqisKAw8hlEOKwBIjVw9cw5y1lKDEu/SqHPZvg8JGYE0488 LsGmLpkU2s/Fk1YMqEtAohWhFJDBlOGOMwwZREO1B8i216zQudOYcu8GKjNOvaHrArXv UbQaZ8hDrMeimbBivZ5y40Enjp8kHamRqL6NzZv1qzgmf1FNm6TmyZH/ueXdCP8MTAtP bk4S6cYq0wgXZ8Xa24VRY1O5zmeVFR3xBqWngA86a+DPhSEzBRFoVaem2gehVk4lPKE1 7CeR14wKvRZJs3F6xmY57fydI0ldMHAT1aYXsToqAKdDHqRTGkX2M+adMW4kVz5M8X32 qF8g== X-Gm-Message-State: AGi0PuZRptv0k+x51fWHleHwbuAIxu67h5QlbfjgO3hdTBPZssCYAWe6 DRv8gvqxecKK0UWeVAtHXGA= X-Google-Smtp-Source: APiQypLTNkL0FlLdpu8plOA88EM9HEHBSDUeucwsX5RV0Meaau9rUDuMqf3YVXorjSpV58yyasilow== X-Received: by 2002:a63:5d5c:: with SMTP id o28mr11522235pgm.322.1587285845663; Sun, 19 Apr 2020 01:44:05 -0700 (PDT) Received: from local.opencloud.tech.localdomain ([219.143.130.26]) by smtp.gmail.com with ESMTPSA id t5sm6846533pjo.19.2020.04.19.01.44.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 Apr 2020 01:44:05 -0700 (PDT) From: xiangxia.m.yue@gmail.com To: syzbot+7ef50afd3a211f879112@syzkaller.appspotmail.com Date: Fri, 17 Apr 2020 02:57:31 +0800 Message-Id: <1587063451-54027-1-git-send-email-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <000000000000e642a905a0cbee6e@google.com> References: <000000000000e642a905a0cbee6e@google.com> Cc: dev@openvswitch.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com, linux-kernel@vger.kernel.org, kuba@kernel.org, davem@davemloft.net Subject: [ovs-dev] [PATCH] net: openvswitch: 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 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 --- net/openvswitch/conntrack.c | 3 ++- net/openvswitch/datapath.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c index e726159cfcfa..4340f25fe390 100644 --- a/net/openvswitch/conntrack.c +++ b/net/openvswitch/conntrack.c @@ -1895,7 +1895,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/net/openvswitch/datapath.c b/net/openvswitch/datapath.c index d8ae541d22a8..94b024534987 100644 --- a/net/openvswitch/datapath.c +++ b/net/openvswitch/datapath.c @@ -2466,8 +2466,10 @@ static void __net_exit ovs_exit_net(struct net *dnet) struct net *net; LIST_HEAD(head); - 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);