From: "Jérémie Galarneau via lttng-dev" <lttng-dev@lists.lttng.org>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: lttng-dev <lttng-dev@lists.lttng.org>
Subject: Re: [lttng-dev] [PATCH lttng-tools stable-2.12] Fix: list_lttng_agent_events: unbalanced RCU read-side lock on error
Date: Fri, 28 May 2021 11:27:41 -0400 (EDT) [thread overview]
Message-ID: <1859733749.1984.1622215661297.JavaMail.zimbra@efficios.com> (raw)
In-Reply-To: <20210527211122.2462-1-mathieu.desnoyers@efficios.com>
Merged in stable-2.12 and stable-2.11.
Thanks!
Jérémie
----- Original Message -----
> From: "Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>
> To: jgalar@efficios.com
> Cc: "lttng-dev" <lttng-dev@lists.lttng.org>, "Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>
> Sent: Thursday, May 27, 2021 5:11:22 PM
> Subject: [PATCH lttng-tools stable-2.12] Fix: list_lttng_agent_events: unbalanced RCU read-side lock on error
> 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 <mathieu.desnoyers@efficios.com>
> 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
prev parent reply other threads:[~2021-05-28 15:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-27 21:11 [lttng-dev] [PATCH lttng-tools stable-2.12] Fix: list_lttng_agent_events: unbalanced RCU read-side lock on error Mathieu Desnoyers via lttng-dev
2021-05-28 15:27 ` Jérémie Galarneau via lttng-dev [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1859733749.1984.1622215661297.JavaMail.zimbra@efficios.com \
--to=lttng-dev@lists.lttng.org \
--cc=jeremie.galarneau@efficios.com \
--cc=mathieu.desnoyers@efficios.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).