From: Maria Matejka Date: Tue, 10 Dec 2024 09:52:52 +0000 (+0100) Subject: Nest: fixed a race-condition between import and export X-Git-Tag: v3.0.0~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc15f0b9c704dcac85ac471d96509e866dc5b09b;p=thirdparty%2Fbird.git Nest: fixed a race-condition between import and export There was a leaking stack pointer to the global memory. Fixed by making that temporary structure thread local static. --- diff --git a/nest/rt-table.c b/nest/rt-table.c index e24973112..cd37d9478 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -1964,10 +1964,8 @@ rte_recalculate(struct rtable_private *table, struct rt_import_hook *c, struct n } /* We need to add a spinlock sentinel to the beginning */ - struct rte_storage local_sentinel = { - .flags = REF_OBSOLETE, - .next = old_best_stored, - }; + _Thread_local static struct rte_storage local_sentinel = { .flags = REF_OBSOLETE, }; + atomic_store_explicit(&local_sentinel.next, old_best_stored, memory_order_release); atomic_store_explicit(&net->routes, &local_sentinel, memory_order_release); /* Mark also the old route as obsolete. */