Yocto Project Discussions
 help / color / mirror / Atom feed
From: "Yi Zhao" <yi.zhao@windriver.com>
To: Yair Itzhaki <Yair.Itzhaki@docusign.com>,
	"yocto@yoctoproject.org" <yocto@yoctoproject.org>
Subject: Re: [yocto] busybox + SELinux (warrior) - reboot issue
Date: Fri, 22 Nov 2019 13:50:40 +0800	[thread overview]
Message-ID: <f66862da-0037-595f-2dbb-68bda650cded@windriver.com> (raw)
In-Reply-To: <MN2PR04MB54874D8403DA4845FB08BF26FA760@MN2PR04MB5487.namprd04.prod.outlook.com>


[-- Attachment #1.1: Type: text/plain, Size: 1589 bytes --]

Hi Yair,


On 11/14/19 2:06 AM, Yair Itzhaki wrote:
>
> Hi ,
>
> I'm using Poky (Warrior), with busybox (aiming at a lightweight system).
>
> Recently, added SELinux to my project (by adding 
> "packagegroup-core-selinux" to my local.conf, with mls policy).
>
> Booted with "selinux=1 enforing=0".
>
> The auto-relabeling reported an error, since the root is mounted RO.
>
> So, patched slelinux-autorelabel script to mount "/" RW before relabeling.
>
> Booted again.
>
> This time, selinux-init had the same issue ( / mounted RO).
>
> Patched this one as well, but the system keeps rebooting:
>
> It seems that the init process keeps it's kernel_t context, which 
> forces re-labeling, reboot and so on…. (per the selinux-init script)
>
> Q1: Is SELinux+busybox a valid combination, or should I switch to systemd?
>
SElinux+busybox should work. But there are some security label issues 
with busybox.

I attached a fix. You can try it.


> Q2: Which context should the init process end up as?
>
This is because /sbin/init.sysvinit doesn't set the correct label. 
Please also see the attachment. I will send the formal patch later.


> BTW – the build of "core-image-selinux" fails, with the following error
>
> Copying files into the device: set_inode_xattr: No data available 
> while reading attribute "security.selinux" of "network"
>
I didn't encountered this issue. Please make sure the setting 
DISTRO_FEATURES_append = " acl xattr pam selinux" is in your conf/local.conf


//Yi


> Any idea?
>
> Thanks,
>
> Yair
>
>

[-- Attachment #1.2: Type: text/html, Size: 7154 bytes --]

[-- Attachment #2: fix.patch --]
[-- Type: text/x-patch, Size: 1552 bytes --]

diff --git a/config/file_contexts.subs_dist b/config/file_contexts.subs_dist
index 04fca3c..c720871 100644
--- a/config/file_contexts.subs_dist
+++ b/config/file_contexts.subs_dist
@@ -44,7 +44,7 @@
 
 # busybox aliases
 # quickly match up the busybox built-in tree to the base filesystem tree
-/usr/lib/busybox/bin /bin
-/usr/lib/busybox/sbin /sbin
+/usr/lib/busybox/bin /usr/bin
+/usr/lib/busybox/sbin /usr/sbin
 /usr/lib/busybox/usr /usr
 
diff --git a/policy/modules/system/getty.fc b/policy/modules/system/getty.fc
index 116ea64..d688249 100644
--- a/policy/modules/system/getty.fc
+++ b/policy/modules/system/getty.fc
@@ -4,6 +4,7 @@
 /run/agetty\.reload	--	gen_context(system_u:object_r:getty_runtime_t,s0)
 
 /usr/bin/.*getty	--	gen_context(system_u:object_r:getty_exec_t,s0)
+/usr/bin/start_getty   --  gen_context(system_u:object_r:bin_t,s0)
 
 /usr/sbin/.*getty	--	gen_context(system_u:object_r:getty_exec_t,s0)
 
diff --git a/policy/modules/system/init.fc b/policy/modules/system/init.fc
index 11a6ce9..3c063b1 100644
--- a/policy/modules/system/init.fc
+++ b/policy/modules/system/init.fc
@@ -40,6 +40,7 @@ ifdef(`distro_gentoo',`
 /usr/libexec/dcc/stop-.* --	gen_context(system_u:object_r:initrc_exec_t,s0)
 
 /usr/sbin/init(ng)?	--	gen_context(system_u:object_r:init_exec_t,s0)
+/usr/sbin/init\.sysvinit	--	gen_context(system_u:object_r:init_exec_t,s0)
 /usr/sbin/open_init_pty	--	gen_context(system_u:object_r:initrc_exec_t,s0)
 /usr/sbin/upstart	--	gen_context(system_u:object_r:init_exec_t,s0)
 

  reply	other threads:[~2019-11-22  5:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-13 18:06 busybox + SELinux (warrior) - reboot issue Yair Itzhaki
2019-11-22  5:50 ` Yi Zhao [this message]
2019-11-22 18:27   ` Ayoub Zaki

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=f66862da-0037-595f-2dbb-68bda650cded@windriver.com \
    --to=yi.zhao@windriver.com \
    --cc=Yair.Itzhaki@docusign.com \
    --cc=yocto@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox