* [PATCH] selinux: get netlabel_wildcard policycap from policy instead of cache
@ 2025-03-12 8:00 Christian Göttsche
2025-03-12 13:04 ` Stephen Smalley
2025-03-17 20:22 ` Paul Moore
0 siblings, 2 replies; 4+ messages in thread
From: Christian Göttsche @ 2025-03-12 8:00 UTC (permalink / raw)
Cc: Christian Göttsche, Paul Moore, Stephen Smalley,
Ondrej Mosnacek, Casey Schaufler, Thiébaud Weksteen,
Mimi Zohar, GUO Zihua, Canfeng Guo, selinux, linux-kernel
From: Christian Göttsche <cgzones@googlemail.com>
Retrieve the netlabel_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>
---
security/selinux/ss/services.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
index 1b11648d9b85..e431772c6168 100644
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -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) {
--
2.47.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] selinux: get netlabel_wildcard policycap from policy instead of cache
2025-03-12 8:00 [PATCH] selinux: get netlabel_wildcard policycap from policy instead of cache Christian Göttsche
@ 2025-03-12 13:04 ` Stephen Smalley
2025-03-14 13:01 ` Christian Göttsche
2025-03-17 20:22 ` Paul Moore
1 sibling, 1 reply; 4+ messages in thread
From: Stephen Smalley @ 2025-03-12 13:04 UTC (permalink / raw)
To: cgzones
Cc: Paul Moore, Ondrej Mosnacek, Casey Schaufler,
Thiébaud Weksteen, Mimi Zohar, GUO Zihua, Canfeng Guo,
selinux, linux-kernel
On Wed, Mar 12, 2025 at 4:01 AM Christian Göttsche
<cgoettsche@seltendoof.de> wrote:
>
> From: Christian Göttsche <cgzones@googlemail.com>
>
> Retrieve the netlabel_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>
Do we have tests for this feature? I didn't see any.
> ---
> security/selinux/ss/services.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
> index 1b11648d9b85..e431772c6168 100644
> --- a/security/selinux/ss/services.c
> +++ b/security/selinux/ss/services.c
> @@ -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) {
> --
> 2.47.2
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] selinux: get netlabel_wildcard policycap from policy instead of cache
2025-03-12 13:04 ` Stephen Smalley
@ 2025-03-14 13:01 ` Christian Göttsche
0 siblings, 0 replies; 4+ messages in thread
From: Christian Göttsche @ 2025-03-14 13:01 UTC (permalink / raw)
To: Stephen Smalley
Cc: Paul Moore, Ondrej Mosnacek, Casey Schaufler,
Thiébaud Weksteen, Mimi Zohar, GUO Zihua, Canfeng Guo,
selinux, linux-kernel
On Wed, 12 Mar 2025 at 14:04, Stephen Smalley
<stephen.smalley.work@gmail.com> wrote:
>
> On Wed, Mar 12, 2025 at 4:01 AM Christian Göttsche
> <cgoettsche@seltendoof.de> wrote:
> >
> > From: Christian Göttsche <cgzones@googlemail.com>
> >
> > Retrieve the netlabel_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>
>
> Do we have tests for this feature? I didn't see any.
No.
Is there a way to retrieve the context of a network interface without
actually sending packets? (Then one could simply use `ip link add
$name_to_test type dummy`).
> > ---
> > security/selinux/ss/services.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
> > index 1b11648d9b85..e431772c6168 100644
> > --- a/security/selinux/ss/services.c
> > +++ b/security/selinux/ss/services.c
> > @@ -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) {
> > --
> > 2.47.2
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] selinux: get netlabel_wildcard policycap from policy instead of cache
2025-03-12 8:00 [PATCH] selinux: get netlabel_wildcard policycap from policy instead of cache Christian Göttsche
2025-03-12 13:04 ` Stephen Smalley
@ 2025-03-17 20:22 ` Paul Moore
1 sibling, 0 replies; 4+ messages in thread
From: Paul Moore @ 2025-03-17 20:22 UTC (permalink / raw)
To: Christian Göttsche
Cc: Christian Göttsche, Stephen Smalley, Ondrej Mosnacek,
Casey Schaufler, Thiébaud Weksteen, Mimi Zohar, GUO Zihua,
Canfeng Guo, selinux, linux-kernel
On Mar 12, 2025 =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgoettsche@seltendoof.de> wrote:
>
> Retrieve the netlabel_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>
> ---
> security/selinux/ss/services.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
As this is a fix for a commit in selinux/dev, I've gone ahead and merged
this into selinux/dev (with a /netlabel/netif/ tweak) to the commit
description.
Thanks everyone.
--
paul-moore.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-03-17 20:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-12 8:00 [PATCH] selinux: get netlabel_wildcard policycap from policy instead of cache Christian Göttsche
2025-03-12 13:04 ` Stephen Smalley
2025-03-14 13:01 ` Christian Göttsche
2025-03-17 20:22 ` Paul Moore
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®