From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id FBovMgoLsGDkSAAAWB0awg (envelope-from ) for ; Thu, 27 May 2021 17:11:38 -0400 Received: by simark.ca (Postfix, from userid 112) id C1FCF1E783; Thu, 27 May 2021 17:11:38 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.lttng.org (lists.lttng.org [167.114.26.123]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 1B8551E783 for ; Thu, 27 May 2021 17:11:38 -0400 (EDT) Received: from lists-lttng01.efficios.com (localhost [IPv6:::1]) by lists.lttng.org (Postfix) with ESMTP id 4FrgVK3R6mz3PD; Thu, 27 May 2021 17:11:37 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.lttng.org; s=default; t=1622149897; bh=NcVusCFNj+R1ErTaBUrZVBkpmHUJF8smcYIMbQ20HE8=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=QVRRIXX47Sm7P3duldeR3SZYKYnQR4XYX4xLSlkMLvuviM4y878kDruf4HtGLrF82 eU0Iqoz5WZhgv6uvVIag0/c0JwTbEReZXxpybOOhUhqnG7DiDKBwhGE0p3GNjBAvpx fbf6aRTOnDfPOjZbzFj+ma/GkVN66aN/SS07wxgZMpISgcRp1CNZz/9Om62L/WbuK3 A1ibgPNsPJETpNrMlbVRD4uSBC4pRrmj+3qhLes2lYgk3lChUufZ0F0QE3c2ng5ISN aEtgD2VCxm8ymmLCSLjlTpMpehEhWyvjIJSumhPZOb7p0NaSv1myH3O7fpPij46IQE g575qiMGMgvbw== Received: from mail.efficios.com (mail.efficios.com [167.114.26.124]) by lists.lttng.org (Postfix) with ESMTPS id 4FrgVH3wV1z3PC for ; Thu, 27 May 2021 17:11:35 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 92BE47A67; Thu, 27 May 2021 17:11:29 -0400 (EDT) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id JxW41TNhvq3L; Thu, 27 May 2021 17:11:28 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 9A6B47A66; Thu, 27 May 2021 17:11:28 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 9A6B47A66 X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id yOezSq1hu7DQ; Thu, 27 May 2021 17:11:28 -0400 (EDT) Received: from localhost.localdomain (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) by mail.efficios.com (Postfix) with ESMTPSA id 6B11C7E13; Thu, 27 May 2021 17:11:28 -0400 (EDT) To: jgalar@efficios.com Date: Thu, 27 May 2021 17:11:22 -0400 Message-Id: <20210527211122.2462-1-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.17.1 Subject: [lttng-dev] [PATCH lttng-tools stable-2.12] Fix: list_lttng_agent_events: unbalanced RCU read-side lock on error X-BeenThere: lttng-dev@lists.lttng.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: LTTng development list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Mathieu Desnoyers via lttng-dev Reply-To: Mathieu Desnoyers Cc: lttng-dev@lists.lttng.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: lttng-dev-bounces@lists.lttng.org Sender: "lttng-dev" The error label jumps to the end label which releases the RCU read-side lock. There are many error paths in this function which goto error without holding the RCU read-side lock, thus causing unbalanced RCU read-side lock. There is no point in keeping so short RCU read-side critical sections, so cover the entire function with a single read-side critical section. [ Applies to stable-2.12 and possibly prior versions. Does _not_ apply to stable-2.13+. ] Signed-off-by: Mathieu Desnoyers Change-Id: I5b20c229a5df22d22ecfdc64dbbb87ee118649d2 --- src/bin/lttng-sessiond/cmd.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index b608df1e1..eb5da1b76 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -510,7 +510,6 @@ static int list_lttng_agent_events(struct agent *agt, rcu_read_lock(); nb_event = lttng_ht_get_count(agt->events); - rcu_read_unlock(); if (nb_event == 0) { ret = nb_event; *total_size = 0; @@ -524,7 +523,6 @@ static int list_lttng_agent_events(struct agent *agt, * This is only valid because the commands which add events are * processed in the same thread as the listing. */ - rcu_read_lock(); cds_lfht_for_each_entry(agt->events->ht, &iter.iter, event, node.node) { ret = increment_extended_len(event->filter_expression, NULL, NULL, &extended_len); @@ -534,7 +532,6 @@ static int list_lttng_agent_events(struct agent *agt, goto error; } } - rcu_read_unlock(); *total_size = nb_event * sizeof(*tmp_events) + extended_len; tmp_events = zmalloc(*total_size); @@ -547,7 +544,6 @@ static int list_lttng_agent_events(struct agent *agt, extended_at = ((uint8_t *) tmp_events) + nb_event * sizeof(struct lttng_event); - rcu_read_lock(); cds_lfht_for_each_entry(agt->events->ht, &iter.iter, event, node.node) { strncpy(tmp_events[i].name, event->name, sizeof(tmp_events[i].name)); tmp_events[i].name[sizeof(tmp_events[i].name) - 1] = '\0'; -- 2.17.1 _______________________________________________ lttng-dev mailing list lttng-dev@lists.lttng.org https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev