From: Maria Matejka Date: Wed, 19 Jun 2024 10:02:34 +0000 (+0200) Subject: Fixed a race condition in rcu-domain blocking X-Git-Tag: v3.0.0~126 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9be90c0f84e8ffce6bbd89222843e9da3d634f68;p=thirdparty%2Fbird.git Fixed a race condition in rcu-domain blocking --- diff --git a/sysdep/unix/domain.c b/sysdep/unix/domain.c index 2817455fd..4e6d8a61c 100644 --- a/sysdep/unix/domain.c +++ b/sysdep/unix/domain.c @@ -137,6 +137,9 @@ void do_lock(struct domain_generic *dg, struct domain_generic **lsp) void do_unlock(struct domain_generic *dg, struct domain_generic **lsp) { + if (dg->forbidden_when_reading_rcu) + ASSERT_DIE(rcu_blocked--); + if ((char *) lsp - (char *) &locking_stack != dg->order) bug("Trying to unlock on bad position: order=%u, lsp=%p, base=%p", dg->order, lsp, &locking_stack); @@ -150,6 +153,5 @@ void do_unlock(struct domain_generic *dg, struct domain_generic **lsp) dg->prev = NULL; pthread_mutex_unlock(&dg->mutex); - if (dg->forbidden_when_reading_rcu) - ASSERT_DIE(rcu_blocked--); + /* From here on, the dg pointer is invalid! */ }