Skip to content
This repository has been archived by the owner on Sep 18, 2020. It is now read-only.

Update selinux support #804

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

glevand
Copy link
Contributor

@glevand glevand commented Mar 29, 2018

Depends on coreos/portage-stable#654 (Update selinux support) and coreos/coreos-overlay#3155 (Update selinux support).

@glevand glevand force-pushed the for-merge-selinux branch from 4bb0149 to 5e58f97 Compare April 20, 2018 18:53
@glevand
Copy link
Contributor Author

glevand commented Apr 20, 2018

Rebased to latest.

@dm0- dm0- mentioned this pull request Apr 20, 2018
setup_qemu_static "${root_fs_dir}"
sudo chroot "${root_fs_dir}" /bin/bash -x << 'EOF'
(cd /usr/share/selinux/mcs && semodule -s mcs -i *.pp)
setfiles -F /usr/lib/selinux/mcs/contexts/files/file_contexts /usr/lib/modules
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is special about the kernel modules that require relabeling?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We build up the board's rootfs '${root_fs_dir}' from the SDK host, so the rootfs files don't have any selinux labels. The kernel module loader (modprobe, etc.) checks for proper labels, so without the relabeling here module loading will fail when selinux is enforcing. I didn't look into why module loading worked with the old selinux policy/tools.

setup_board Outdated
@@ -265,6 +265,9 @@ PORTAGE_BINHOST="${BOARD_BINHOST}"
# You can use --select to override this.
EMERGE_DEFAULT_OPTS="--oneshot"

# SELinux installed policies.
POLICY_TYPES="mcs"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to keep POLICY_TYPES in the base profile set to targeted mcs mls? Maybe we should make this change there instead. Or, if we don't want it in the base policy, maybe we can set this value in profiles/coreos/targets/generic/make.defaults so that there is only one file with this change when using multiple boards.

Copy link
Contributor Author

@glevand glevand Apr 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed that entry in the base profile. I think profiles/coreos/base/make.defaults is the right place to set it since we are only building the mcs policy, and that is the same for all boards. I'll move this change there.

@glevand glevand force-pushed the for-merge-selinux branch 2 times, most recently from 63be2b3 to a40114f Compare April 25, 2018 23:03
@glevand
Copy link
Contributor Author

glevand commented Apr 25, 2018

Moved POLICY_TYPES change to base policy in coreos/coreos-overlay#3155.

Copy link
Contributor

@dm0- dm0- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If no labels are applied, maybe we should be relabeling the entire /usr partition here, but LGTM if this is the minimal requirement.

@glevand
Copy link
Contributor Author

glevand commented May 4, 2018

@dm0- I sort of mentioned this on Slack before. We should be labeling everything created ( I have a patch for it Add SEL labels to all files in https://github.com/glevand/coreos--scripts/commits/master), but there are still some things in the policy that need to be fixed up for Container Linux's startup. As of now if we set all labels we get some SELinux avc: denied messages at early startup. It's something I planned to look into. My current set of SELinux PRs will give slightly better SELinux support than what Container Linux has now. I have a rebased set of patches ready. I'll push out once testing finishes.

@glevand glevand force-pushed the for-merge-selinux branch from a40114f to 9a5b9c2 Compare May 8, 2018 00:17
@glevand
Copy link
Contributor Author

glevand commented May 8, 2018

Rebased to latest.

@glevand glevand force-pushed the for-merge-selinux branch from 9a5b9c2 to 5fcc513 Compare May 11, 2018 22:09
@glevand
Copy link
Contributor Author

glevand commented May 11, 2018

Rebased to latest.

dm0- and others added 2 commits May 18, 2018 12:26
Move the selinux policy build to before 'write_contents' and 'zero
free space' are done so that the selinux modules are included in
those operations.  Also apply the selinux file lables as needed.

Signed-off-by: Geoff Levand <[email protected]>
@glevand glevand force-pushed the for-merge-selinux branch from 5fcc513 to 91c7555 Compare May 23, 2018 16:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants