All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
To: Richard Purdie <richard.purdie@linuxfoundation.org>
Cc: Yoann Congal <yoann.congal@smile.fr>,
	 yocto-patches@lists.yoctoproject.org,
	Yi Zhao <yi.zhao@windriver.com>,
	 Hiago De Franco <hfranco@baylibre.com>
Subject: Re: [yocto-patches] [meta-selinux][PATCH] Enable SELinux support in native packages
Date: Wed, 18 Mar 2026 12:13:23 +0100	[thread overview]
Message-ID: <abqEzAjosilonVNP@monoceros> (raw)
In-Reply-To: <e5bcfc29f4ab15e0ac21e2273a679821373530c6.camel@linuxfoundation.org>

[-- Attachment #1: Type: text/plain, Size: 5193 bytes --]

On Wed, Mar 18, 2026 at 09:12:52AM +0000, Richard Purdie wrote:
> On Wed, 2026-03-18 at 08:50 +0100, Uwe Kleine-König wrote:
> > On Tue, Mar 17, 2026 at 07:23:35PM +0100, Yoann Congal wrote:
> > > On Tue Mar 17, 2026 at 6:40 PM CET, Hiago De Franco via lists.yoctoproject.org wrote:
> > > > Hi Richard,
> > > > 
> > > > On Mon, Mar 09, 2026 at 02:21:51PM +0000, Richard Purdie wrote:
> > > > > On Mon, 2026-03-09 at 20:23 +0800, Yi Zhao via lists.yoctoproject.org wrote:
> > > > > > 
> > > > > > On 2/13/26 23:42, "Uwe Kleine-König wrote:
> > > > > > > With SELinux enabled for the target it makes sense to have SELinux
> > > > > > > support enabled for the native tools, too.
> > > > > > > 
> > > > > > > Note that for native packages DISTRO_FEATURES is filtered, thus up to now
> > > > > > > it never contained "selinux". Append to DISTRO_FEATURES_FILTER_NATIVE to
> > > > > > > make "selinux" propagate also to DISTRO_FEATURES for native packages.
> > > > > > > ---
> > > > > > > Hello,
> > > > > > > 
> > > > > > > I use this on scarthgap, but the patch applies fine to master, too.
> > > > > > > 
> > > > > > > During a debug session it took me quite a while to find out why
> > > > > > > 
> > > > > > > 	ls -lZ "${IMAGE_ROOTFS}
> > > > > > > 
> > > > > > > at the end of selinux_set_labels() didn't show the labels added by
> > > > > > > setfiles.
> > > > > > > 
> > > > > > > Best regards
> > > > > > > Uwe
> > > > > > > 
> > > > > > >   classes/enable-selinux.bbclass | 2 +-
> > > > > > >   conf/layer.conf                | 4 ++++
> > > > > > >   2 files changed, 5 insertions(+), 1 deletion(-)
> > > > > > > 
> > > > > > > diff --git a/classes/enable-selinux.bbclass b/classes/enable-selinux.bbclass
> > > > > > > index 3dc61d6931ff..0c9f52e74cec 100644
> > > > > > > --- a/classes/enable-selinux.bbclass
> > > > > > > +++ b/classes/enable-selinux.bbclass
> > > > > > > @@ -1,3 +1,3 @@
> > > > > > >   inherit selinux
> > > > > > >   
> > > > > > > -PACKAGECONFIG:append = " ${@target_selinux(d, 'selinux')}"
> > > > > > > +PACKAGECONFIG:append = " ${@bb.utils.filter('DISTRO_FEATURES', 'selinux', d)}"
> > > > > > > diff --git a/conf/layer.conf b/conf/layer.conf
> > > > > > > index 4e04e5cc7e6a..ca981db57019 100644
> > > > > > > --- a/conf/layer.conf
> > > > > > > +++ b/conf/layer.conf
> > > > > > > @@ -25,3 +25,7 @@ LAYERDEPENDS_selinux = " \
> > > > > > >   "
> > > > > > >   
> > > > > > >   PREFERRED_PROVIDER_virtual/refpolicy ??= "refpolicy-targeted"
> > > > > > > +
> > > > > > > +# With target support for SELinux it is very helpful during debug when the
> > > > > > > +# native tools support SELinux, too.
> > > > > > > +DISTRO_FEATURES_FILTER_NATIVE:append = " selinux"
> > > > > > 
> > > > > > Can we add this to the doc (e.g. README) instead of enabling it directly 
> > > > > > in layer.conf? Since we haven't directly enabled DISTRO_FEATURES = 
> > > > > > "selinux" in layer.conf either.
> > > > > 
> > > > > I just wanted to add that putting that directly in layer.conf will mean
> > > > > the layer isn't Yocto Project Compatible too.
> > > > 
> > > > I am going to send a v2 and take over this work, already asked Uwe about
> > > > that.
> > > > 
> > > > But before doing it, I was wondering why changing layer.conf will make
> > > > the layer not compatible with Yocto Project anymore. Can you explain to
> > > > us the reason?
> > > 
> > > I'd guess it is from this criteria of the Yocto Compatible layer[0]:
> > > > Inclusion of any layer in the submission does not change the
> > > > behavior/configuration of the overall system without the user
> > > > explicitly opting into those changes
> > > 
> > > By putting a 'DISTRO_FEATURES += "selinux"' in layer.conf, the
> > > configuration changes globally without explicit opt-in of the user.
> > 
> > Note that the patch didn't change DISTRO_FEATURES, it appended "selinux"
> > to DISTRO_FEATURES_FILTER_NATIVE. If DISTRO_FEATURES doesn't already
> > contain "selinux", this is a noop. So I don't see how this violates the
> > quoted critera.
> > 
> > What am I missing?
> 
> I guess it would depend whether any of the functions/variables in core
> have hard dependencies on that variable. I was assuming that they do
> but that might not be the case, I'm not sure without checking and you
> may be right.

Wouldn't that be a bug if a function changes behaviour depending on
DISTRO_FEATURES_FILTER_NATIVE containing "selinux" or not? (Apart from
having "selinux" for native packages iff the global DISTRO_FEATURES has
"selinux".)

I grepped for DISTRO_FEATURES_FILTER_NATIVE in oe-core, bitbake and
meta-openembedded, there are only matches in the first and these are
about default settings, appending DISTRO_FEATURES_OVERRIDES and
providing a filtered version of the global DISTRO_FEATURES for native
packages.

So unless I missed something, I'd claim setting
DISTRO_FEATURES_FILTER_NATIVE:append in a layer doesn't result in a
relevant change without an explicit opt-in (by adding "selinux" to
DISTRO_FEATURES) and then this (implicit) v1 is better than the v2 that
Hiago sent.

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2026-03-18 11:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-13 15:42 [meta-selinux][PATCH] Enable SELinux support in native packages Uwe Kleine-König
2026-03-09 12:23 ` [yocto-patches] " Yi Zhao
2026-03-09 14:21   ` Richard Purdie
2026-03-17 17:40     ` Hiago De Franco
2026-03-17 18:23       ` Yoann Congal
2026-03-17 20:19         ` Hiago De Franco
2026-03-18  7:50         ` Uwe Kleine-König
2026-03-18  9:12           ` Richard Purdie
2026-03-18 11:13             ` Uwe Kleine-König [this message]
2026-03-18 12:37               ` Richard Purdie
2026-03-18 14:22                 ` Uwe Kleine-König
2026-03-25 12:28                   ` Hiago De Franco
2026-03-27 16:33                     ` Uwe Kleine-König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=abqEzAjosilonVNP@monoceros \
    --to=u.kleine-koenig@baylibre.com \
    --cc=hfranco@baylibre.com \
    --cc=richard.purdie@linuxfoundation.org \
    --cc=yi.zhao@windriver.com \
    --cc=yoann.congal@smile.fr \
    --cc=yocto-patches@lists.yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.