Gentoo Archives: gentoo-hardened

From: Paolo Barile <f.p.barile@×××××.com>
To: gentoo-hardened@l.g.o
Subject: Re: [gentoo-hardened] Can't get fully functional (kde) desktop with SELinux
Date: Sun, 26 Aug 2012 12:02:47
Message-Id: 5039F31A.8030508@gmail.com
In Reply to: Re: [gentoo-hardened] Can't get fully functional (kde) desktop with SELinux by Sven Vermeulen
1 Hello Sven, first of all, all the denials I wrote here are from
2 enforcing mode.
3
4 On 25/08/2012 19:24, Sven Vermeulen wrote:
5 > On Sat, Aug 25, 2012 at 07:00:09PM +0200, Paolo Barile wrote:
6 >> Hi Sven, thank you for rev4, but it didn't conclusively solve my
7 >> problems. Sone denial has gone, but many of them remain.
8 >>
9 >> So let's see again all the step by step denial, I'll avoid redundancies.
10 >>
11 >> As I boot (whithout starting xdm) I obtain:
12 >>
13 >> Aug 25 18:06:05 dell-studio kernel: [ 8.028595] type=1400
14 >> audit(1345917944.027:3): avc: denied { search } for pid=1433
15 >> comm="alsactl" name="root" dev="sda5" ino=1308163
16 >> scontext=system_u:system_r:alsa_t tcontext=system_u:object_r:default_t
17 >> tclass=dir
18 > This sais /root is default_t again. Mine sais:
19 >
20 > ~ # matchpathcon /root
21 > /root root:object_r:user_home_dir_t
22 >
23 > ~ # grep '/root' /etc/selinux/strict/contexts/files/file_contexts* | grep user_home_dir_t
24 > /etc/selinux/strict/contexts/files/file_contexts.homedirs:/root -d root:object_r:user_home_dir_t
25
26 The same gives me nothing.
27
28 >
29 > It is because /root is marked as a home directory of a user that a hole set
30 > of contexts is generated for it. Perhaps for a targeted system this is
31 > different, but I don't think so.
32 >
33 > Whenever you hit a denial with file_t or default_t in it, it means there is
34 > something awry with the contexts on the system.
35 >
36 > You might be able to fix it by running genhomedircon (without options). It
37 > should regenerate the file context as mentioned in my grep result above.
38 genhomedircon doesn't change anything.
39
40 >
41 >> Aug 25 18:06:05 dell-studio kernel: [ 8.707035] type=1400
42 >> audit(1345917944.706:7): avc: denied { read } for pid=1431
43 >> comm="alsactl" name="urandom" dev="tmpfs" ino=3356
44 >> scontext=system_u:system_r:alsa_t
45 >> tcontext=system_u:object_r:urandom_device_t tclass=chr_file
46 > Did you enable global_ssp (or are you not running a hardened system, just
47 > SELinux)? By enabling the global_ssp boolean, all domains get access to the
48 > urandom_device_t chr_file:
49 >
50 > ~ # sesearch -s alsa_t -t urandom_device_t -A -C
51 > Found 2 semantic av rules:
52 > DT allow nsswitch_domain urandom_device_t : chr_file { ioctl read getattr lock open } ; [ authlogin_nsswitch_use_ldap ]
53 > ET allow domain urandom_device_t : chr_file { ioctl read getattr lock open } ; [ global_ssp ]
54 No, it isn't. I did not enabled it because I'm still not in hardened
55 because I'd want let selinux comletely work before the conversion.
56
57 >
58 >> Aug 25 18:06:05 dell-studio kernel: [ 8.707053] type=1400
59 >> audit(1345917944.706:9): avc: denied { read } for pid=1431
60 >> comm="alsactl" name="random" dev="tmpfs" ino=1642
61 >> scontext=system_u:system_r:alsa_t
62 >> tcontext=system_u:object_r:random_device_t tclass=chr_file
63 > This one is new for me. If it is prohibiting alsa to work, we'll need to
64 > allow this, but I think you're booting in permissive mode, so we can't know
65 > for sure if the denial is cosmetic or not.
66 As I wrote, everything is already in enforcing moe.
67 >
68 >> Aug 25 18:06:05 dell-studio kernel: [ 8.707089] type=1400
69 >> audit(1345917944.706:11): avc: denied { getattr } for pid=1431
70 >> comm="alsactl" name="/" dev="tmpfs" ino=2970
71 >> scontext=system_u:system_r:alsa_t tcontext=system_u:object_r:tmpfs_t
72 >> tclass=filesystem
73 > Which file system is it trying to get attributes from here?
74 >
75 >> Aug 25 18:06:05 dell-studio kernel: [ 16.930444] type=1400
76 >> audit(1345910753.814:32): avc: denied { module_request } for pid=1517
77 >> comm="cryptsetup" kmod="cbc(aes)" scontext=system_u:system_r:lvm_t
78 >> tcontext=system_u:system_r:kernel_t tclass=system
79 >> Aug 25 18:06:05 dell-studio kernel: [ 16.930452] type=1400
80 >> audit(1345910753.814:33): avc: denied { module_request } for pid=1517
81 >> comm="cryptsetup" kmod="cbc(aes)-all" scontext=system_u:system_r:lvm_t
82 >> tcontext=system_u:system_r:kernel_t tclass=system
83 >> Aug 25 18:06:05 dell-studio kernel: [ 16.930505] type=1400
84 >> audit(1345910753.814:34): avc: denied { module_request } for pid=1517
85 >> comm="cryptsetup" kmod="cbc(aes-asm)" scontext=system_u:system_r:lvm_t
86 >> tcontext=system_u:system_r:kernel_t tclass=system
87 >> Aug 25 18:06:05 dell-studio kernel: [ 16.930512] type=1400
88 >> audit(1345910753.814:35): avc: denied { module_request } for pid=1517
89 >> comm="cryptsetup" kmod="cbc(aes-asm)-all"
90 >> scontext=system_u:system_r:lvm_t tcontext=system_u:system_r:kernel_t
91 >> tclass=system
92 >> Aug 25 18:06:05 dell-studio kernel: [ 16.936081] type=1400
93 >> audit(1345910753.820:36): avc: denied { getattr } for pid=1517
94 >> comm="cryptsetup" name="/" dev="tmpfs" ino=2970
95 >> scontext=system_u:system_r:lvm_t tcontext=system_u:object_r:tmpfs_t
96 >> tclass=filesystem
97 >> Aug 25 18:06:05 dell-studio kernel: [ 17.138342] type=1400
98 >> audit(1345910754.022:38): avc: denied { read } for pid=1538
99 >> comm="cryptsetup" name="queue.bin" dev="tmpfs" ino=4265
100 >> scontext=system_u:system_r:lvm_t
101 >> tcontext=system_u:object_r:udev_var_run_t tclass=file
102 >> Aug 25 18:06:05 dell-studio kernel: [ 27.701565] type=1400
103 > The cryptsetup stuff might need some more updates, I only use cryptsetup for
104 > a small encrypted partition (and not a system partition) and I have most of
105 > the stuff in-kernel anyway, so no module requests here...
106 >
107 > We'll need to look at this when you boot in enforcing mode, since I need the
108 > error message(s) as well in order to update the policy.
109 >
110 > Same is true for most of the remaining denials btw. Some of them definitely
111 > need to be looked at in advance, like the next set, but most of them will
112 > need to be reproduced with enforcing mode...
113 >
114 >> audit(1345910765.120:46): avc: denied { getattr } for pid=1998
115 >> comm="console-kit-dae" path="/run/ConsoleKit" dev="tmpfs" ino=5251
116 >> scontext=system_u:system_r:consolekit_t
117 >> tcontext=system_u:object_r:initrc_var_run_t tclass=dir
118 > Need to add in this run directory, haven't done that yet.
119 >
120 >> Aug 25 18:06:05 dell-studio kernel: [ 28.632129] type=1400
121 >> audit(1345910765.516:48): avc: denied { execute } for pid=2089
122 >> comm="dbus-daemon-lau" name="polkitd" dev="sda5" ino=922900
123 >> scontext=system_u:system_r:system_dbusd_t
124 >> tcontext=system_u:object_r:policykit_exec_t tclass=file
125 > Probably needs to be made a dbus domain.
126 >
127 >> Aug 25 18:06:06 dell-studio kernel: [ 29.168487] type=1400
128 >> audit(1345910766.052:52): avc: denied { write } for pid=2222
129 >> comm="mii-tool" path="/run/lock/lmt-req.lock" dev="tmpfs" ino=5314
130 >> scontext=system_u:system_r:ifconfig_t
131 >> tcontext=system_u:object_r:var_lock_t tclass=file
132 >> Aug 25 18:06:06 dell-studio kernel: [ 29.168499] type=1400
133 >> audit(1345910766.052:53): avc: denied { write } for pid=2222
134 >> comm="mii-tool" path="/run/lock/lmt-invoc.lock" dev="tmpfs" ino=4776
135 >> scontext=system_u:system_r:ifconfig_t
136 >> tcontext=system_u:object_r:var_lock_t tclass=file
137 > Probably legit, but I'm not sure if I need to create an ifconfig_lock_t type
138 > for this, or just grant in var_lock_t access. Probably the former.
139 >
140 >> After logging in, apart all the same mentioned above that repeat
141 >> themselves, I get a lot of:
142 >> Aug 25 18:10:25 dell-studio kernel: [ 289.004361] type=1400
143 >> audit(1345911025.905:163): avc: denied { search } for pid=1968
144 >> comm="dbus-daemon" name="console" dev="tmpfs" ino=5945
145 >> scontext=system_u:system_r:system_dbusd_t
146 >> tcontext=system_u:object_r:consolekit_var_run_t tclass=dir
147 > What does the console dir contain? It's probably in /var/run/ConsoleKit
148 > (although from your earlier denials I get the impression /var/run/ConsoleKit
149 > is not correctly labeled, whereas in this denial it is - did you relabel the
150 > system or some parts of it in between?).
151
152 The console dir is outside ConsoleKit:
153
154 drwxr-xr-x. 2 root root system_u:object_r:initrc_var_run_t 80
155 26 ago 11.32 ConsoleKit
156 drwxr-xr-x. 2 root root system_u:object_r:consolekit_var_run_t 60
157 26 ago 11.32 console
158
159 It contains... nothing!
160
161 Anyway a restorecon -R /run changed contexts inside it:
162
163 drwxr-xr-x. 2 root root system_u:object_r:consolekit_var_run_t 80
164 26 ago 11.32 ConsoleKit
165 drwxr-xr-x. 2 root root system_u:object_r:pam_var_console_t 60
166 26 ago 11.32 console
167
168 Of course after the policies upgrade I relabeld all the system
169 (twice!)... But since the /run is a tmpfs dir, and since its contexts
170 are wrong, should I use the initramfs approach (restorecon before
171 switching to enforcing)?
172
173
174 >
175 > I recommend to first work on the default_t and file_t stuff. That shouldn't
176 > be broken. Then in the denials, look at any denials for "execute", they
177 > almost always need to be fixed (whereas getattr/read's can often be ignored,
178 > especially in the beginning).
179 >
180 > Then, when booted and logged in, clear the denial log and switch to
181 > enforcing mode and see what stuff breaks. Then look in the denial log for
182 > the denials, and give the error messages for the broken applications.
183 It's exactly what I did in the previous email, after every step I
184 cleared the log file
185 >
186 > When we fixed that, we should then look at the cryptsetup stuff, since you
187 > need that in order to boot succesfully I guess. Only then can we try to boot
188 > in enforcing mode (once, until it boots fully).
189 >
190 > Wkr,
191 > Sven Vermeulen
192 >
193 Thank you again Sven. Paolo.

Replies