From: Dominick Grift <dominick.grift@defensec.nl>
To: selinux@vger.kernel.org
Subject: Re: [SELinux-notebook PATCH v8] objects.md: some clarifications
Date: Tue, 21 Jul 2020 22:14:16 +0200 [thread overview]
Message-ID: <ypjl365kzkvb.fsf@defensec.nl> (raw)
In-Reply-To: <20200721200230.1976501-1-dominick.grift@defensec.nl> (Dominick Grift's message of "Tue, 21 Jul 2020 22:02:30 +0200")
Dominick Grift <dominick.grift@defensec.nl> writes:
> Elaborate on labeling. Touch on the significance of the default statement, on various av permissions related to labeling using the libselinux API, and on how the kernel and unlabeled initial security identifiers are used to address labeling challenges in special cases such as initialization and failover respectively.
>
> Signed-off-by: Dominick Grift <dominick.grift@defensec.nl>
> ---
>
> v2: fixes patch description
> v3: adding patch description, s/policies/policy's/, split unlabeled and kernel descriptions for clarity
> v4: fixes another typo in description and emphasize system initialization a bit
> v5: emphasize kernel threads with kernel isid description
> v6: forgot to mention defaultuser, can only associate one label with isids
> v7: copied and pasted feedback from Stephen Smalley
> v8: missed a s/access vectors/permissions/ instance
>
> src/objects.md | 47 +++++++++++++++++++++++++++++++++++++++++++----
> 1 file changed, 43 insertions(+), 4 deletions(-)
>
> diff --git a/src/objects.md b/src/objects.md
> index 58664ef..1907316 100644
> --- a/src/objects.md
> +++ b/src/objects.md
> @@ -110,14 +110,20 @@ objects is managed by the system and generally unseen by the users
> (until labeling goes wrong !!). As processes and objects are created and
> destroyed, they either:
>
> -1. Inherit their labels from the parent process or object.
> +1. Inherit their labels from the parent process or object. The policy
> + default user, type, role and range statements can be used to
> + change the behavior as discussed in the [**Default Rules**](default_rules.md#default-object-rules)
> + section.
> 2. The policy type, role and range transition statements allow a
> different label to be assigned as discussed in the
> [**Domain and Object Transitions**](domain_object_transitions.md#domain-and-object-transitions)
> section.
> -3. SELinux-aware applications can enforce a new label (with the
> - policies approval of course) using the **libselinux** API
> - functions.
> +3. SELinux-aware applications can assign a new label (with the
> + policy's approval of course) using the **libselinux** API
> + functions. The `process setfscreate` permission can be used to
> + allow subjects to create files with a new label programmatically
> + using the ***setfscreatecon**(3)* function, overriding default
> + rules and transition statements.
> 4. An object manager (OM) can enforce a default label that can either
> be built into the OM or obtained via a configuration file (such as
> those used by
> @@ -269,6 +275,39 @@ and manage their transition:
>
> `type_transition`, `role_transition` and `range_transition`
>
> +SELinux-aware applications can assign a new label (with the policy's
> +approval of course) using the **libselinux** API functions. The
> +`process setexec`, `process setkeycreate` and `process setsockcreate`
> +permissions can be used to allow subjects to label processes,
> +kernel keyrings, and sockets programmatically using the
> +***setexec**(3)*, ***setkeycreatecon**(3)* and
> +***setsockcreatecon**(3)* functions respectively, overriding
> +transition statements.
> +
> +The `kernel` **initial security identifier** is used to associate
> +a specified label with kernel objects, including kernel threads
> +(both those that are created during initialization but also kernel
> +threads created later), kernel-private sockets, synthetic objects
> +representing kernel resources (e.g. the "system" class).
> +
> +It is true that processes created prior to initial policy load will
> +also be in the kernel SID until/unless there is a policy loaded and
> +either a policy-defined transition or an explicit setcon or
> +setexeccon+execve, but that's just the typical default inheritance
> +from creating task behavior for processes.
> +
> +The `unlabeled` **initial security identifier** is used
> +to associate a specified label with subjects that had their label
> +invalidated due to policy changes at runtime.
> +
> +It is also assigned as the initial state for various objects e.g.
> +inodes, superblocks, etc until they reach a point where a more
> +specific label can be determined e.g. from an xattr or from policy.
> +The context associated with the unlabeled SID is used as the fallback
> +context for both subjects and objects when their label is invalidated
> +by a policy reload (their SID is unchanged but the SID is
> +transparently remapped to the unlabeled context).
I will note here that I suspect there is currently something broken
with libselinux / unlabeled sids
libselinux consumers still use *invalidated* contexts associated with
inodes to compute access vectors.
for example rpm will not consistently work until the filesystems are
relabeled after a new policy is loaded that invalidates contexts
currently associated with /bin/sh (entrypoint for setfscreatecon to
"rpm_script_t")
systemd will not consistently work until the filesystems are relabeled
after a new policy loaded that invalidates contexts currently associated
with (i suspect) parent directories for socket activated sock files
(maybe setfscreatecon?)
> +
> ### Object Reuse
>
> As GNU / Linux runs it creates instances of objects and manages the
--
gpg --locate-keys dominick.grift@defensec.nl
Key fingerprint = FCD2 3660 5D6B 9D27 7FC6 E0FF DA7E 521F 10F6 4098
https://sks-keyservers.net/pks/lookup?op=get&search=0xDA7E521F10F64098
Dominick Grift
next prev parent reply other threads:[~2020-07-21 20:14 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-10 7:09 [SELinux-notebook PATCH] onjects.md: some clarifications Dominick Grift
2020-07-10 7:14 ` [SELinux-notebook PATCH v2] objects.md: " Dominick Grift
2020-07-13 10:45 ` Richard Haines
2020-07-15 2:15 ` Paul Moore
2020-07-15 7:56 ` Dominick Grift
2020-07-16 11:18 ` [SELinux-notebook PATCH v3] " Dominick Grift
2020-07-16 12:17 ` [SELinux-notebook PATCH v4] " Dominick Grift
2020-07-17 1:36 ` Paul Moore
2020-07-17 6:41 ` Dominick Grift
2020-07-18 6:40 ` [SELinux-notebook PATCH v5] " Dominick Grift
2020-07-19 9:44 ` [SELinux-notebook PATCH v6] " Dominick Grift
2020-07-21 17:44 ` Stephen Smalley
2020-07-21 19:51 ` [SELinux-notebook PATCH v7] " Dominick Grift
2020-07-21 20:02 ` [SELinux-notebook PATCH v8] " Dominick Grift
2020-07-21 20:14 ` Dominick Grift [this message]
2020-07-22 16:48 ` Stephen Smalley
2020-07-22 16:57 ` Dominick Grift
2020-07-22 17:32 ` Stephen Smalley
2020-07-23 8:13 ` Dominick Grift
2020-07-23 12:22 ` Stephen Smalley
2020-07-23 13:04 ` Dominick Grift
2020-07-23 13:24 ` Stephen Smalley
2020-07-23 13:37 ` Dominick Grift
2020-07-24 7:54 ` Dominick Grift
2020-07-24 12:23 ` Stephen Smalley
2020-07-24 12:29 ` Dominick Grift
2020-07-24 12:56 ` Stephen Smalley
2020-07-24 13:06 ` Dominick Grift
2020-07-24 13:26 ` Stephen Smalley
2020-07-24 13:30 ` Dominick Grift
2020-07-22 17:29 ` Dominick Grift
2020-07-22 15:11 ` Stephen Smalley
2020-07-23 7:50 ` [SELinux-notebook PATCH v9] " Dominick Grift
2020-07-23 12:00 ` Stephen Smalley
2020-07-27 13:43 ` Stephen Smalley
2020-07-28 2:17 ` Paul Moore
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=ypjl365kzkvb.fsf@defensec.nl \
--to=dominick.grift@defensec.nl \
--cc=selinux@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.