Skip to contentSkip to conversation

Working to enable SELinux on OpenWrt

DISCUSSION W. Michael Petullo 2 participants 4 messages Aug 18, 2020 – Aug 19, 2020 SELinux security module

lore
Share & tools
lore
#0 lore raw

I am working with Thomas Petazzoni and the OpenWrt community to add SELinux support to OpenWrt. OpenWrt is a Linux distribution tailored for running routers and similar devices.

	https://github.com/openwrt/openwrt/pull/3207
	https://github.com/openwrt/packages/pull/10664

I am interested in enabling KERNEL_SECURITY_SELINUX_DEVELOP, which I believe to be necessary if I am to enable and disable SELinux enforcement at runtime. However, it seems that enabling this option in the kernel causes the system to hang:

[...]

[    1.668419] sd 0:0:0:0: [sda] Attached SCSI disk
[    1.675189] Waiting for root device PARTUUID=4ba37c2a-02...
[    2.100751] tsc: Refined TSC clocksource calibration: 1995.376 MHz
[    2.113719] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x39863c423f0, max_idle_ns: 881590675958 ns
[    2.122334] clocksource: Switched to clocksource tsc

It is not clear to me whether the kernel or the init process is hanging. Things boot fine when KERNEL_SECURITY_SELINUX_DEVELOP=n.

I have tried a number of kernel command line parameters, thinking perhaps SELinux is preventing the use of the console. This has not yet helped.

The OpenWrt init is available at:

https://git.openwrt.org/?p=project/procd.git,

and it now includes a commit from Thomas that calls selinux_init_load_policy().

Does anyone have any idea what might be causing this hang? Is there a user-space requirement to finish the boot process when KERNEL_SECURITY_SELINUX_DEVELOP=y?

I would also very much appreciate any comments on the two GitHub merge requests above. I think OpenWrt would provide a compelling use case for SELinux, and thus I (along with Thomas) have invested a fair amount of time trying to get this accepted by the OpenWrt team.

Signature · 3 lines
Mike

:wq
#1 lore raw
Quoted 32 lines

I am working with Thomas Petazzoni and the OpenWrt community to add SELinux support to OpenWrt. OpenWrt is a Linux distribution tailored for running routers and similar devices.

	https://github.com/openwrt/openwrt/pull/3207
	https://github.com/openwrt/packages/pull/10664

I am interested in enabling KERNEL_SECURITY_SELINUX_DEVELOP, which I believe to be necessary if I am to enable and disable SELinux enforcement at runtime. However, it seems that enabling this option in the kernel causes the system to hang:

[...]

[    1.668419] sd 0:0:0:0: [sda] Attached SCSI disk
[    1.675189] Waiting for root device PARTUUID=4ba37c2a-02...
[    2.100751] tsc: Refined TSC clocksource calibration: 1995.376 MHz
[    2.113719] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x39863c423f0, max_idle_ns: 881590675958 ns
[    2.122334] clocksource: Switched to clocksource tsc

It is not clear to me whether the kernel or the init process is hanging. Things boot fine when KERNEL_SECURITY_SELINUX_DEVELOP=n.

I have tried a number of kernel command line parameters, thinking perhaps SELinux is preventing the use of the console. This has not yet helped.

The OpenWrt init is available at:

https://git.openwrt.org/?p=project/procd.git,

and it now includes a commit from Thomas that calls selinux_init_load_policy().

Quoted 8 lines

Does anyone have any idea what might be causing this hang? Is there a user-space requirement to finish the boot process when KERNEL_SECURITY_SELINUX_DEVELOP=y?

I would also very much appreciate any comments on the two GitHub merge requests above. I think OpenWrt would provide a compelling use case for SELinux, and thus I (along with Thomas) have invested a fair amount of time trying to get this accepted by the OpenWrt team.

Looks like my problem had to do with mangling grub.cfg. Things are working nicely now.

Signature · 3 lines
Mike

:wq
maintainer
#2 lore raw
Quoted 37 lines · W. Michael Petullo
Quoted 37 lines

I am working with Thomas Petazzoni and the OpenWrt community to add SELinux support to OpenWrt. OpenWrt is a Linux distribution tailored for running routers and similar devices.

      https://github.com/openwrt/openwrt/pull/3207
      https://github.com/openwrt/packages/pull/10664

I am interested in enabling KERNEL_SECURITY_SELINUX_DEVELOP, which I believe to be necessary if I am to enable and disable SELinux enforcement at runtime. However, it seems that enabling this option in the kernel causes the system to hang:

[...]

[    1.668419] sd 0:0:0:0: [sda] Attached SCSI disk
[    1.675189] Waiting for root device PARTUUID=4ba37c2a-02...
[    2.100751] tsc: Refined TSC clocksource calibration: 1995.376 MHz
[    2.113719] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x39863c423f0, max_idle_ns: 881590675958 ns
[    2.122334] clocksource: Switched to clocksource tsc

It is not clear to me whether the kernel or the init process is hanging. Things boot fine when KERNEL_SECURITY_SELINUX_DEVELOP=n.

I have tried a number of kernel command line parameters, thinking perhaps SELinux is preventing the use of the console. This has not yet helped.

The OpenWrt init is available at:

https://git.openwrt.org/?p=project/procd.git,

and it now includes a commit from Thomas that calls selinux_init_load_policy().

Does anyone have any idea what might be causing this hang? Is there a user-space requirement to finish the boot process when KERNEL_SECURITY_SELINUX_DEVELOP=y?

Quoted 7 lines
Quoted 4 lines

I would also very much appreciate any comments on the two GitHub merge requests above. I think OpenWrt would provide a compelling use case for SELinux, and thus I (along with Thomas) have invested a fair amount of time trying to get this accepted by the OpenWrt team.

Looks like my problem had to do with mangling grub.cfg. Things are working nicely now.

Great, thanks for working on this. I agree that OpenWrt could be a compelling use case for SELinux. In the case of Android, we started from scratch to create a policy tailored to its userspace and security goals. Have you considered doing the same for OpenWrt or are you just trying to use refpolicy?

#3 lore raw
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

I am working with Thomas Petazzoni and the OpenWrt community to add SELinux support to OpenWrt. OpenWrt is a Linux distribution tailored for running routers and similar devices.

[...]

Quoted 5 lines

Great, thanks for working on this. I agree that OpenWrt could be a compelling use case for SELinux. In the case of Android, we started from scratch to create a policy tailored to its userspace and security goals. Have you considered doing the same for OpenWrt or are you just trying to use refpolicy?

Policy will be the second step. Our initial aim is to package the stock refpolicy, and then I hope to tailor or write policy for common OpenWrt services. We will expand from there. We are working with the monolithic policy right now, but I would like to transition to modular policies once things settle down.

My intuition is that OpenWrt will resemble standard Linux installs more than Android. We'll see!

Signature · 3 lines
Mike

:wq