selinux: get netif_wildcard policycap from policy instead of cache
authorChristian Göttsche <cgzones@googlemail.com>
Wed, 12 Mar 2025 08:00:48 +0000 (09:00 +0100)
committerPaul Moore <paul@paul-moore.com>
Mon, 17 Mar 2025 20:22:04 +0000 (16:22 -0400)
Retrieve the netif_wildcard policy capability in security_netif_sid()
from the locked active policy instead of the cached value in
selinux_state.

Fixes: 8af43b61c17e ("selinux: support wildcard network interface names")
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
[PM: /netlabel/netif/ due to a typo in the description]
Signed-off-by: Paul Moore <paul@paul-moore.com>
security/selinux/ss/services.c

index 1b11648d9b8584a3320455a74707f969c3e52578..e431772c6168909769496312299e01ed488588d5 100644 (file)
@@ -2587,14 +2587,13 @@ int security_netif_sid(const char *name, u32 *if_sid)
                return 0;
        }
 
-       wildcard_support = selinux_policycap_netif_wildcard();
-
 retry:
        rc = 0;
        rcu_read_lock();
        policy = rcu_dereference(selinux_state.policy);
        policydb = &policy->policydb;
        sidtab = policy->sidtab;
+       wildcard_support = ebitmap_get_bit(&policydb->policycaps, POLICYDB_CAP_NETIF_WILDCARD);
 
        c = policydb->ocontexts[OCON_NETIF];
        while (c) {