[Bug 275001] if_wg: Missing radix unlock can cause deadlock

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 10 Nov 2023 02:52:45 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=275001

            Bug ID: 275001
           Summary: if_wg: Missing radix unlock can cause deadlock
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: aly@aaronly.me

In file 'sys/dev/wg/if_wg.c' function 'wg_aip_add()', the error path of
returning ENOMEM when (node == NULL) is forgetting to unlock the radix tree,
and thus may lead to a deadlock.

Below is the patch, please review.

--- if_wg.c.orig        2023-10-12 09:06:16.983637264 +0800
+++ if_wg.c     2023-10-21 15:29:47.928807521 +0800
@@ -562,7 +562,7 @@
                node = root->rnh_lookup(&aip->a_addr, &aip->a_mask, &root->rh);
        if (!node) {
                free(aip, M_WG);
-               return (ENOMEM);
+               ret = ENOMEM;
        } else if (node != aip->a_nodes) {
                free(aip, M_WG);
                aip = (struct wg_aip *)node;

-- 
You are receiving this mail because:
You are the assignee for the bug.