From patchwork Sat Mar 26 02:43:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng He X-Patchwork-Id: 1609638 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=20210112 header.b=M83SGJWH; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KQNYm64RKz9sG1 for ; Sat, 26 Mar 2022 13:43:24 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 9989E408C6; Sat, 26 Mar 2022 02:43:21 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WACGNcErQHA0; Sat, 26 Mar 2022 02:43:20 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id DF4C040324; Sat, 26 Mar 2022 02:43:19 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 52E71C002C; Sat, 26 Mar 2022 02:43:19 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id AF543C0012 for ; Sat, 26 Mar 2022 02:43:18 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 9F2D9841C9 for ; Sat, 26 Mar 2022 02:43:18 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cZdjB46ll5di for ; Sat, 26 Mar 2022 02:43:18 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by smtp1.osuosl.org (Postfix) with ESMTPS id 2C4258417D for ; Sat, 26 Mar 2022 02:43:14 +0000 (UTC) Received: by mail-pl1-x62a.google.com with SMTP id k6so10050370plg.12 for ; Fri, 25 Mar 2022 19:43:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FdnsHBGRU1X/IcepnYFSbg7O2Ee+8OU6r/pwBVGV9YI=; b=M83SGJWHDo4Mm4DDEVfbmnmNuWmYmEni9uhQvfvPb9UFEc+MPwz+ahh8T4VG/kDQz3 aAo+rW6FVUrcp48bf5QtEq44Qh/3DoCbS3a3/20Dtk8lnNqDOVbwz9TGJwEH65xh0NaX qNvKoNXjp2qBw9rdq+TeDTBKUyHNCv1FC+S1xpuPzaM+cKgiXcnfu9FzLUcdAI1SmAMu okjEPQouixNrEqe9i9drHh1LOayQ3MJZsEJda/jDDobFMIYkVlrfqrpZlIaxVi9pCjwY /NKoLDzIgydMqYfL0p5CoRNl0DqpzbUW61oCqp+zymZbEgYb/wtENQrV+Vvtkan5EPv3 HT6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FdnsHBGRU1X/IcepnYFSbg7O2Ee+8OU6r/pwBVGV9YI=; b=vCNW7V+dck+j9smTKRUmHo1b7KKNtgPj7jX2B12bDPch42Ka/4D+uUzd4fFj9cu5sX 6MtOzCyF0AFhhqaVD/0j5tyHg5VsziIYXTFT//IO8uUZcmCilyhw2nSXgDDJ1tPNEqRf 2nZGlyUi4ofGeg/wViRIh84rkmifTB/ROacdT/lyffdQ/b1C1kW29cnUFeRQu06xB4Kw apqkEj5gmaSlhKcxkCf9iXXCwDEv/wpFgRMYbEa5BWUb2Q6mRumQr/TwB6H2XR7S72eV eg/n2z4pEXsHCTg+0C5F5XZMw7IsAgfxHl60xb/9bvac50iK7CgTz+CgU0uE5nin4RuF 5Wrg== X-Gm-Message-State: AOAM532HpZuNLHuu4v0pqalcDKwPg2wQp2QMr3tP8Qr/kKLAnpNpo2ji x+qmPKkAWfkyzjuocqE18GrjpyRIGZdIIQ== X-Google-Smtp-Source: ABdhPJwO9QUIAjDtyNbe11efJDblTa2jrtLM92dIALTjqq/nL7GMRML0q9ebH5AHQONnGYbISxpzww== X-Received: by 2002:a17:90b:1b03:b0:1c7:778b:d4ce with SMTP id nu3-20020a17090b1b0300b001c7778bd4cemr23654707pjb.128.1648262593519; Fri, 25 Mar 2022 19:43:13 -0700 (PDT) Received: from localhost ([139.177.225.252]) by smtp.gmail.com with ESMTPSA id y41-20020a056a001ca900b004fb000ccd92sm4724401pfw.96.2022.03.25.19.43.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 19:43:13 -0700 (PDT) From: Peng He X-Google-Original-From: Peng He To: dev@openvswitch.org Date: Sat, 26 Mar 2022 02:43:06 +0000 Message-Id: <20220326024306.27661-2-hepeng.0320@bytedance.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326024306.27661-1-hepeng.0320@bytedance.com> References: <20220307222754.2396907-1-i.maximets@ovn.org> <20220326024306.27661-1-hepeng.0320@bytedance.com> MIME-Version: 1.0 Cc: david.marchand@redhat.com, i.maximets@ovn.org Subject: [ovs-dev] [ovs-dev v1 2/2] ofproto-dpif: fix meter use-after-free 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: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" add a rcu_barrier before close_dpif_backer to ensure that all meters has been freed before id_pool_destory meter's id-pool. Signed-off-by: Peng He --- ofproto/ofproto-dpif.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index a4c44052d..1739544e5 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -1797,6 +1797,16 @@ add_internal_flows(struct ofproto_dpif *ofproto) return error; } +static void +ofproto_rcu_barrier(void) +{ + struct seq *seq = seq_create(); + while(!ovsrcu_barrier(seq, 1000)) { + /* do nothing */ + } + seq_destroy(seq); +} + static void destruct(struct ofproto *ofproto_, bool del) { @@ -1848,6 +1858,9 @@ destruct(struct ofproto *ofproto_, bool del) seq_destroy(ofproto->ams_seq); + /* wait for all the meter destroy work finished + */ + ofproto_rcu_barrier(); close_dpif_backer(ofproto->backer, del); }