]> git.feebdaed.xyz Git - 0xmirror/ovs.git/commitdiff
ipf: Fix potential deadlock with the clean thread on exit.
authorIlya Maximets <i.maximets@ovn.org>
Fri, 24 Oct 2025 16:59:06 +0000 (18:59 +0200)
committerIlya Maximets <i.maximets@ovn.org>
Mon, 27 Oct 2025 16:53:20 +0000 (17:53 +0100)
There is a potential deadlock between the thread destroying the ipf
and the clean thread as they are using the latch and the ipf lock in
the opposite order.  The latch itself is thread-safe, so we should
not be holding the lock while setting it and waiting for the clean
thread that may be waiting for the lock.

Fixes: 4ea96698f667 ("Userspace datapath: Add fragmentation handling.")
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
lib/ipf.c

index b16797312ae899bcc6ad4f9f25e19e53486dde92..a81d6728aa20618e916422e322cef98227978a4d 100644 (file)
--- a/lib/ipf.c
+++ b/lib/ipf.c
@@ -1374,11 +1374,12 @@ ipf_init(void)
 void
 ipf_destroy(struct ipf *ipf)
 {
-    ovs_mutex_lock(&ipf->ipf_lock);
     latch_set(&ipf->ipf_clean_thread_exit);
     pthread_join(ipf->ipf_clean_thread, NULL);
     latch_destroy(&ipf->ipf_clean_thread_exit);
 
+    ovs_mutex_lock(&ipf->ipf_lock);
+
     struct ipf_list *ipf_list;
     HMAP_FOR_EACH_POP (ipf_list, node, &ipf->frag_lists) {
         while (ipf_list->last_sent_idx < ipf_list->last_inuse_idx) {