Received: from goalie.tycho.ncsc.mil (goalie [144.51.242.250]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id u7UH3rqH020639 for ; Tue, 30 Aug 2016 13:03:53 -0400 Received: from hellfire (unknown [10.255.0.11]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (Client did not present a certificate) by tbhext01.m0noc.net (Postfix) with ESMTPSA id 3sNvxL0rtCz2ZYPs for ; Tue, 30 Aug 2016 18:03:50 +0100 (BST) From: "Paul Bolton" To: Subject: SELinux MLS Policies Date: Tue, 30 Aug 2016 18:03:49 +0100 Message-ID: <01e601d202e0$7aaf62d0$700e2870$@a.bolton@m0noc.net> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_01E7_01D202E8.DC73CAD0" List-Id: "Security-Enhanced Linux \(SELinux\) mailing list" List-Post: List-Help: This is a multi-part message in MIME format. ------=_NextPart_000_01E7_01D202E8.DC73CAD0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit First, apologies if this is the wrong SELinux list to post such questions; as you can guess I'm new to SELinux development. I'm looking at getting a base MLS policy running on a fully patched CentOS 7.2 build which I will then customise; currently as a learning exercise. Unfortunately I'm having a few problems (usually it works out-of-the-box on distros I've used, but not in this case), so I hope someone on the list can give me a push in the right direction. Bottom line is that if I try to use the vendor supplied version the system is unusable if set to enforcing (I've used MLS before, so I do mean unusable in this case). I've now downloaded the latest reference policy, compiled it for mls and systemd including updating the broken labelling due to /bin and /sbin being symlinks. Things look better but there are still many errors. One group in particular puzzles me (hopefully due to some misunderstanding on my part). I get AVC's for a number of critical files relating to systemd sockets and /dev/log, for example. e.g. -- snip -- type=AVC msg=audit(1472476843.913:1124): avc: denied { sendto } for pid=11015 comm="sshd" path="/dev/log" scontext=system_u:system_r:sshd_t:s0-s15:c0.c1023 tcontext=system_u:system_r:kernel_t:s15:c0.c1023 tclass=unix_dgram_socket Was caused by: #Constraint rule: mlsconstrain unix_dgram_socket { sendto } ((l1 eq l2 -Fail-) or (t1=sshd_t eq TYPE_ENTRY -Fail-) { POLICY_SOURCE: mlsnetwriteranged } and (l1 dom l2 -Fail-) and (l1 domby h2 -Pass-) or (t1=sshd_t eq TYPE_ENTRY -Fail-) { POLICY_SOURCE: mlsnetwritetoclr } and (h1 dom L2 -Pass-) and (l1 domby l2 -Pass-) or (t1=sshd_t eq TYPE_ENTRY -Fail-) { POLICY_SOURCE: mlsnetwrite } or (t2=kernel_t eq TYPE_ENTRY -Fail-) { POLICY_SOURCE: mlstrustedobject } ); Constraint DENIED # Possible cause is the source level (s0-s15:c0.c1023) and target level (s15:c0.c1023) are different. -- snip -- Now, given that /dev/log is labelled as a devlog_t: # ls -lZ /dev/log srw-rw-rw-. root root system_u:object_r:devlog_t:s15:c0.c1023 /dev/log And according to logging.te, this is a trusted object: mls_trusted_object(devlog_t) Why is the target context for evaluation kernel_t and not devlog_t? Surely it should be devlog_t and therefore pass the constraint rule as a trusted object? Paul ---- http://blog.m0noc.com/ | https://keybase.io/m0noc 4329 E4C5 71F3 58B2 2246 D04D 25DA 39C2 3876 FE3D ------=_NextPart_000_01E7_01D202E8.DC73CAD0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

First, = apologies if this is the wrong SELinux list to post such questions; as = you can guess I’m new to SELinux development.

 

I’m = looking at getting a base MLS policy running on a fully patched CentOS = 7.2 build which I will then customise; currently as a learning = exercise.

 

Unfortunately I’m having a few problems (usually = it works out-of-the-box on distros I’ve used, but not in this = case), so I hope someone on the list can give me a push in the right = direction.

 

Bottom line is that if I try to use the vendor = supplied version the system is unusable if set to enforcing (I’ve = used MLS before, so I do mean unusable in this case).

 

I’ve = now downloaded the latest reference policy, compiled it for mls and = systemd including updating the broken labelling due to /bin and /sbin = being symlinks. Things look better but there are still many = errors.

 

One group in particular puzzles me (hopefully due to = some misunderstanding on my part).

 

I get = AVC’s for a number of critical files relating to systemd sockets = and /dev/log, for example. e.g.

 

-- snip = --

type=3DAVC = msg=3Daudit(1472476843.913:1124): avc:  denied  { sendto } = for  pid=3D11015 comm=3D"sshd" = path=3D"/dev/log" = scontext=3Dsystem_u:system_r:sshd_t:s0-s15:c0.c1023 = tcontext=3Dsystem_u:system_r:kernel_t:s15:c0.c1023 = tclass=3Dunix_dgram_socket

 

        Was caused = by:

 

#Constraint rule:

 

        = mlsconstrain unix_dgram_socket { sendto } ((l1 eq l2 -Fail-)  or = (t1=3Dsshd_t  eq TYPE_ENTRY -Fail-) { POLICY_SOURCE: = mlsnetwriteranged }  and (l1 dom l2 -Fail-)  and (l1 domby h2 = -Pass-)  or (t1=3Dsshd_t  eq TYPE_ENTRY -Fail-) { = POLICY_SOURCE: mlsnetwritetoclr }  and (h1 dom L2 -Pass-)  and = (l1 domby l2 -Pass-)  or (t1=3Dsshd_t  eq TYPE_ENTRY -Fail-) { = POLICY_SOURCE: mlsnetwrite }  or (t2=3Dkernel_t  eq TYPE_ENTRY = -Fail-) { POLICY_SOURCE: mlstrustedobject } ); Constraint = DENIED

 

#       Possible cause = is the source level (s0-s15:c0.c1023) and target level (s15:c0.c1023) = are different.

-- snip = --

 

Now, given that /dev/log is labelled as a = devlog_t:

 

# ls -lZ /dev/log

srw-rw-rw-. root root = system_u:object_r:devlog_t:s15:c0.c1023 /dev/log

 

And = according to logging.te, this is a trusted object:

 

mls_trusted_object(devlog_t)

 

Why is the = target context for evaluation kernel_t and not devlog_t? Surely it = should be devlog_t and therefore pass the constraint rule as a trusted = object?

 

 

Paul

----

http://blog.m0noc.com/ | = https://keybase.io/m0noc

4329 E4C5 71F3 58B2 = 2246  D04D 25DA 39C2 3876 FE3D

 

------=_NextPart_000_01E7_01D202E8.DC73CAD0--