Skip to contentSkip to conversation

Fix: unbalanced RCU read-side lock in enable event command

PATCH New Mathieu Desnoyers 2 participants 3 messages Sep 7, 2015 – Sep 8, 2015 2 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 2/2 Fix: unbalanced RCU read-side lock in enable event command

The event validation fails, an unpaired RCU unlock is performed, thus underflowing the RCU nesting counter.

---
 src/bin/lttng-sessiond/cmd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/bin/lttng-sessiond/cmd.c +2 -2
index 6237d67..ac5b8ec 100644
@@ -1535,13 +1535,13 @@ static int _cmd_enable_event(struct ltt_session *session,
 
 	DBG("Enable event command for event \'%s\'", event->name);
 
+	rcu_read_lock();
+
 	ret = validate_event_name(event->name);
 	if (ret) {
 		goto error;
 	}
 
-	rcu_read_lock();
-
 	switch (domain->type) {
 	case LTTNG_DOMAIN_KERNEL:
 	{
Signature · 1 line
2.1.4
#2 lore raw

Re: [PATCH lttng-tools 1/2] Add rcu_read_ongoing() assertions around process_client_msg

In reply to a message not in the archive

Merged, thanks!

Jérémie

Quoted 34 lines · Mathieu Desnoyers

process_client_msg ensures that RCU read-side lock should not be held when calling it. Validate this using rcu_read_ongoing() at the entry and exit points of this function. This allows us to catch unbalanced RCU read-side lock within commands quickly.

---
 src/bin/lttng-sessiond/main.c | 3 +++
 1 file changed, 3 insertions(+)
src/bin/lttng-sessiond/main.c +3 -1
index 7c48e4d..0e7de6e 100644
@@ -2972,6 +2972,8 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int sock,
 
        DBG("Processing client command %d", cmd_ctx->lsm->cmd_type);
 
+       assert(!rcu_read_ongoing());
+
        *sock_error = 0;
 
        switch (cmd_ctx->lsm->cmd_type) {
@@ -4059,6 +4061,7 @@ setup_error:
                session_unlock_list();
        }
 init_setup_error:
+       assert(!rcu_read_ongoing());
        return ret;
 }
 
--

2.1.4

Signature · 8 lines
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

Good catch, thanks!

Jérémie

Quoted 31 lines · Mathieu Desnoyers

The event validation fails, an unpaired RCU unlock is performed, thus underflowing the RCU nesting counter.

---
 src/bin/lttng-sessiond/cmd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/bin/lttng-sessiond/cmd.c +2 -3
index 6237d67..ac5b8ec 100644
@@ -1535,13 +1535,13 @@ static int _cmd_enable_event(struct ltt_session *session,
 
        DBG("Enable event command for event \'%s\'", event->name);
 
+       rcu_read_lock();
+
        ret = validate_event_name(event->name);
        if (ret) {
                goto error;
        }
 
-       rcu_read_lock();
-
        switch (domain->type) {
        case LTTNG_DOMAIN_KERNEL:
        {
--

2.1.4

Signature · 8 lines
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev