1 |
commit: 3fdae66e37713cc8633303fdd3f09032b422b095 |
2 |
Author: Nicolas Iooss <nicolas.iooss <AT> m4x <DOT> org> |
3 |
AuthorDate: Mon Jan 11 18:14:55 2016 +0000 |
4 |
Commit: Jason Zaman <perfinion <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Jan 30 17:16:56 2016 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/hardened-refpolicy.git/commit/?id=3fdae66e |
7 |
|
8 |
Allow systemd services to use PrivateNetwork feature |
9 |
|
10 |
systemd creates a new network namespace for services which are using |
11 |
PrivateNetwork=yes. |
12 |
|
13 |
In the implementation, systemd uses a socketpair as a storage buffer for |
14 |
the namespace reference file descriptor (c.f. |
15 |
https://github.com/systemd/systemd/blob/v228/src/core/namespace.c#L660). |
16 |
One end of this socketpair is locked (hence the need of "lock" access to |
17 |
self:unix_dgram_socket for init_t) while systemd opens |
18 |
/proc/self/ns/net, which lives in nsfs. |
19 |
|
20 |
While at it, add filesystem_type attribute to nsfs_t. |
21 |
|
22 |
policy/modules/kernel/filesystem.if | 17 +++++++++++++++++ |
23 |
policy/modules/kernel/filesystem.te | 1 + |
24 |
policy/modules/system/init.te | 3 +++ |
25 |
3 files changed, 21 insertions(+) |
26 |
|
27 |
diff --git a/policy/modules/kernel/filesystem.if b/policy/modules/kernel/filesystem.if |
28 |
index 0db8233..b9b30da 100644 |
29 |
--- a/policy/modules/kernel/filesystem.if |
30 |
+++ b/policy/modules/kernel/filesystem.if |
31 |
@@ -3360,6 +3360,23 @@ interface(`fs_rw_nfsd_fs',` |
32 |
|
33 |
######################################## |
34 |
## <summary> |
35 |
+## Read nsfs inodes (e.g. /proc/pid/ns/uts) |
36 |
+## </summary> |
37 |
+## <param name="domain"> |
38 |
+## <summary> |
39 |
+## Domain allowed access. |
40 |
+## </summary> |
41 |
+## </param> |
42 |
+# |
43 |
+interface(`fs_read_nsfs_files',` |
44 |
+ gen_require(` |
45 |
+ type nsfs_t; |
46 |
+ ') |
47 |
+ |
48 |
+ allow $1 nsfs_t:file read_file_perms; |
49 |
+') |
50 |
+######################################## |
51 |
+## <summary> |
52 |
## Getattr on pstore dirs. |
53 |
## </summary> |
54 |
## <param name="domain"> |
55 |
|
56 |
diff --git a/policy/modules/kernel/filesystem.te b/policy/modules/kernel/filesystem.te |
57 |
index 89de79d..04ea6b6 100644 |
58 |
--- a/policy/modules/kernel/filesystem.te |
59 |
+++ b/policy/modules/kernel/filesystem.te |
60 |
@@ -127,6 +127,7 @@ fs_type(nfsd_fs_t) |
61 |
genfscon nfsd / gen_context(system_u:object_r:nfsd_fs_t,s0) |
62 |
|
63 |
type nsfs_t; |
64 |
+fs_type(nsfs_t) |
65 |
genfscon nsfs / gen_context(system_u:object_r:nsfs_t,s0) |
66 |
|
67 |
type oprofilefs_t; |
68 |
|
69 |
diff --git a/policy/modules/system/init.te b/policy/modules/system/init.te |
70 |
index a7fa7c0..4006e4f 100644 |
71 |
--- a/policy/modules/system/init.te |
72 |
+++ b/policy/modules/system/init.te |
73 |
@@ -199,6 +199,7 @@ ifdef(`init_systemd',` |
74 |
allow init_t self:netlink_kobject_uevent_socket create_socket_perms; |
75 |
allow init_t self:netlink_route_socket create_netlink_socket_perms; |
76 |
allow init_t self:netlink_selinux_socket create_socket_perms; |
77 |
+ allow init_t self:unix_dgram_socket lock; |
78 |
|
79 |
manage_files_pattern(init_t, init_var_run_t, init_var_run_t) |
80 |
manage_lnk_files_pattern(init_t, init_var_run_t, init_var_run_t) |
81 |
@@ -260,6 +261,8 @@ ifdef(`init_systemd',` |
82 |
# mount-setup |
83 |
fs_unmount_autofs(init_t) |
84 |
fs_getattr_pstore_dirs(init_t) |
85 |
+ # for network namespaces |
86 |
+ fs_read_nsfs_files(init_t) |
87 |
|
88 |
# systemd_socket_activated policy |
89 |
mls_socket_write_all_levels(init_t) |