-
-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
init: optionally load the system SELinux policy #400
base: master
Are you sure you want to change the base?
Changes from all commits
489dac8
4112da9
2a4eeb9
1dd6dbf
177ca37
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Dinit SELinux Awareness | ||
|
||
Dinit has support for basic SELinux awareness. This document is intended to | ||
outline the extent and inner workings of Dinit's SELinux awareness. The reader | ||
is assumed to be knowledgeable about the basics of [SELinux](https://github.com/SELinuxProject/selinux-notebook) | ||
and Dinit. | ||
|
||
Dinit needs to be built with SELinux support (see [BUILD](/BUILD)) to enable the features that are | ||
mentioned in this document. | ||
|
||
## Loading the system SELinux policy | ||
When booted as the system init system, dinit by default will attempt to load the | ||
system's SELinux policy and transition itself to a context specified by that policy | ||
if not already done so in earlier boot (e.g. by an initramfs). This behaviour may be | ||
disabled by passing dinit the `--disable-selinux-policy` flag. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "flag" -> command-line argument. |
||
|
||
If not already mounted in earlier boot (e.g. by an initramfs), dinit will mount `/sys`, | ||
and selinuxfs (typically `/sys/fs/selinux`). This occurs before any services are started, | ||
as loading the SELinux policy is the first thing dinit does. | ||
Comment on lines
+17
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See comments elsewhere about assigning responsibility for these actions. It seems odd to mention this here but not also mention the temporary mounting of |
||
|
||
The following flowchart provides an overview of the process of loading the policy: | ||
```mermaid | ||
flowchart TD | ||
A[Start] --> B{"Is dinit running as the system manager?"} | ||
B -->|Yes| C{Have we been requested to not load the SELinux policy?} | ||
C -->|No| D[Continue rest of dinit initialization] | ||
C -->|Yes| E[Is the SELinux policy already loaded?] | ||
E -->|Yes| D | ||
E --> |No| G[Attempt to mount /proc] | ||
G --> J[Attempt to load the SELinux policy] | ||
J --> K{Did the SELinux policy load succeed?} | ||
K -->|Yes| L[Attempt to calculate our new context and transition] | ||
K -->|No| M{Was enforcing mode requested?} | ||
M -->|Yes| I[Error exit early] | ||
M -->|No| D | ||
L --> N{Did we successfully transition?} | ||
N -->|Yes| P{Did we mount /proc?} | ||
N -->|No| O[Log an error] | ||
O --> P | ||
P -->|Yes| Q[Unmount /proc] | ||
P -->|No| D | ||
Q --> D | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,6 +113,10 @@ If service description settings contain relative cgroup paths, they will be reso | |
this path. | ||
This option is only available if \fBdinit\fR is built with cgroups support. | ||
.TP | ||
\fB\-\-disable\-selinux\-policy\fR | ||
Disable loading of the system SELinux policy. | ||
This option is only available if \fBdinit\fR is built with SELinux support. | ||
.TP | ||
\fB\-\-help\fR | ||
Display brief help text and then exit. | ||
.TP | ||
|
@@ -298,6 +302,16 @@ There are several ways to work around this. | |
Service names following the \fB\-\-container\fR (\fB\-o\fR) or \fB\-\-system\-mgr\fR (\fB\-m\fR) options are not ignored. | ||
Also, the \fB\-\-service\fR (\fB\-t\fR) option can be used to force a service name to be recognised regardless of operating mode. | ||
.\" | ||
.SH SELINUX SUPPORT | ||
.LP | ||
When running as PID 1 on a SELinux enabled machine, \fBdinit\fR will by default load the system's SELinux policy. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I look at the code, it looks to me like the SELinux policy will be loaded if dinit is running as system manager and system init, but this says "when running as PID 1"? (I already pointed out a similar issue in the previous review; you should address all cases). Isn't it the case that this happens only if Dinit has been built with SELinux support enabled? What happens in case of various failures? Eg failure to load the policy. |
||
This behaviour can be disabled by passing the \fB\-\-disable\-selinux\-policy\fR option to dinit. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't really need to mention this, that option is already documented (also "dinit" lacks formatting). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Referring to line 308) |
||
.LP | ||
When loading the SELinux policy, dinit will automatically mount a few special filesystems needed to successfully load the policy. | ||
\fBsysfs\fR will be mounted at \fB/sys\fR, and \fBselinuxfs\fR will be mounted at \fB/sys/fs/selinux\fR. | ||
\fBdinit\fR will not unmount either. | ||
\fBprocfs\fR will also be mounted at \fB/proc\fR, but \fBdinit\fR will unmount it after loading the SELinux policy. | ||
Comment on lines
+310
to
+313
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find this whole section problematic. First, other than If you're going to mention |
||
.\" | ||
.SH FILES | ||
.\" | ||
.TP | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"system init system" sounds weird. Say "system init" just as we do elsewhere.