Skip to contentSkip to conversation

Need information on building embedded systems.

DISCUSSION Don Hoefer 2 participants 2 messages Oct 24, 2013 – Oct 25, 2013 SELinux security module

lore
Share & tools
lore

Don Hoefer

author
#0 lore raw

We are using kernel 3.8.13, busybox 1.20.2. init says that it is version 2.88, along with that we have the typical Sys-V init with /etc/rc?.d startup scripts.

Thank you for the links, we'll digest the Android stuff.

Don Hoefer

On 10/24/13, Stephen Smalley<[email protected]> wrote:

Quoted 16 lines · Don Hoefer

We are building an embedded system where the customer requires SELinux. It is our own hardware so we build our own kernel and drivers and use the ext2, jfs and tempfs file systems. This is not new for us, but incorporating SELinux is.

Does anyone know of a good knowledge resource for building embedded systems with SELinux?

We are currently plowing through a frustrating step ahead/step back process. We are either unable to build a policy, or a minimal policy we build often causes the development system to fail to boot. Any policy we get onto the embedded system appears to fail to load properly. We think that some pieces may be missing but we are unable to debug due to lack of knowledge.

I suspect that our boot process with SELinux is incomplete and that we are missing some libraries, for example:

root@generic-powerpc:~#semanage
Traceback (most recent call last):
File "/usr/sbin/semanage", line 24, in <module>
import seobject
File "/usr/lib/python2.7/site-packages/seobject.py", line 24,in <module> import pwd, grp, string, selinux, tempfile, os, re, sys,stat
ImportError: No module named selinux

Quoted 3 lines

Also, the selinux fs is not mounted and policies are not loaded during boot. We can do this with init scripts but isn't it too late by then?

Any help would be welcome.

I'd suggest you have a look at what we did in porting SELinux to Android, both regard to our approach and possible reuse of some of our minimalist port of libselinux and other components. See:
http://selinuxproject.org/page/SEAndroid

There is a published technical paper linked from that page that describes the approach in detail, along with several presentations describing it and of course how to obtain the code itself.

You really don't need much of the SELinux userspace for an embedded system. Aside from our minimalist port of libselinux and a reimplementation of specific utilities as part of the Android init built-in commands and toolbox, we left the rest of the SELinux userspace either completely unused or only used on the build host itself, not on the device. We certainly didn't bother porting semanage or any other python components.

We also wrote a policy from scratch tailored to Android and to a very well-defined set of security goals, as described in the paper and presentations. We did not use the SELinux reference policy nor did we use anything generated by mdp as a starting point.

It would help to know your kernel (version) and what userspace you are using as your baseline (e.g. are you using busybox? what is providing your init program?).

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#1 lore raw
Quoted 1 line · Don Hoefer

We are using kernel 3.8.13, busybox 1.20.2. init says that it is version 2.88, along with that we have the typical Sys-V init with /etc/rc?.d startup scripts.

So did you enable the SELinux support in your init and busybox when you built it?

We didn't develop the busybox SELinux support ourselves; that was done by others in the SELinux community, but it has been in upstream busybox for a while. I'm not sure what state it is in currently.

sysvinit was extended by Red Hat with SELinux support long ago and that was upstreamed as well. init typically performs the initial policy load.

What CONFIG_SECURITY_* options did you enable in your kernel configuration? A sample set enabled in one of our Android kernel trees is:
+CONFIG_AUDIT=y
+CONFIG_SECURITY=y
+CONFIG_LSM_MMAP_MIN_ADDR=4096
+CONFIG_SECURITY_NETWORK=y
+CONFIG_SECURITY_SELINUX=y
+CONFIG_DEFAULT_SECURITY_SELINUX=y
+CONFIG_NETWORK_SECMARK=y
+CONFIG_NF_CONNTRACK_SECMARK=y +CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=y +CONFIG_NETFILTER_XT_TARGET_SECMARK=y +CONFIG_NETFILTER_ADVANCED=y
+CONFIG_IP_NF_SECURITY=y

You also need the CONFIG_*_FS_XATTR and CONFIG_*_FS_SECURITY options enabled for each filesystem that you use that supports per-file security attributes, e.g.

Kernel 3.8.13 supports up through policy.28, so as long as your checkpolicy generates a policy file in version 28 or older you are fine.
The -c option to checkpolicy can be used to force it to an older
version; we use that for Android to ensure compatibility with the Android 3.4 kernels.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.