1 #include <tunables/global>
2 profile "anbox-container" flags=(attach_disconnected,mediate_deleted) {
10 # Allow us to receive signals from anywhere.
13 # Allow us to send signals to ourselves
14 signal peer=@{profile_name},
16 # Allow other processes to read our /proc entries, futexes, perf tracing and
17 # kcmp for now (they will need 'read' in the first place). Administrators can
19 # deny ptrace (readby) ...
22 # Allow other processes to trace us by default (they will need 'trace' in
23 # the first place). Administrators can override with:
24 # deny ptrace (tracedby) ...
27 # Allow us to ptrace ourselves
28 ptrace peer=@{profile_name},
30 # ignore DENIED message on / remount
31 deny mount options=(ro, remount) -> /,
32 deny mount options=(ro, remount, silent) -> /,
34 # allow tmpfs mounts everywhere
37 # allow hugetlbfs mounts everywhere
38 mount fstype=hugetlbfs,
40 # allow mqueue mounts everywhere
43 # allow fuse mounts everywhere
47 # deny access under /proc/bus to avoid e.g. messing with pci devices directly
48 deny @{PROC}/bus/** wklx,
50 # deny writes in /proc/sys/fs but allow binfmt_misc to be mounted
51 mount fstype=binfmt_misc -> /proc/sys/fs/binfmt_misc/,
52 deny @{PROC}/sys/fs/** wklx,
54 # allow efivars to be mounted, writing to it will be blocked though
55 mount fstype=efivarfs -> /sys/firmware/efi/efivars/,
57 # block some other dangerous paths
58 deny @{PROC}/kcore rwklx,
59 deny @{PROC}/sysrq-trigger rwklx,
61 # deny writes in /sys except for /sys/fs/cgroup, also allow
62 # fusectl, securityfs and debugfs to be mounted there (read-only)
63 mount fstype=fusectl -> /sys/fs/fuse/connections/,
64 mount fstype=securityfs -> /sys/kernel/security/,
65 mount fstype=debugfs -> /sys/kernel/debug/,
66 deny mount fstype=debugfs -> /var/lib/ureadahead/debugfs/,
67 mount fstype=proc -> /proc/,
68 mount fstype=sysfs -> /sys/,
69 mount options=(rw, nosuid, nodev, noexec, remount) -> /sys/,
70 deny /sys/firmware/efi/efivars/** rwklx,
71 # note, /sys/kernel/security/** handled below
72 mount options=(move) /sys/fs/cgroup/cgmanager/ -> /sys/fs/cgroup/cgmanager.lower/,
73 mount options=(ro, nosuid, nodev, noexec, remount, strictatime) -> /sys/fs/cgroup/,
75 # deny reads from debugfs
76 deny /sys/kernel/debug/{,**} rwklx,
78 # allow paths to be made slave, shared, private or unbindable
79 # FIXME: This currently doesn't work due to the apparmor parser treating those as allowing all mounts.
80 # mount options=(rw,make-slave) -> **,
81 # mount options=(rw,make-rslave) -> **,
82 # mount options=(rw,make-shared) -> **,
83 # mount options=(rw,make-rshared) -> **,
84 # mount options=(rw,make-private) -> **,
85 # mount options=(rw,make-rprivate) -> **,
86 # mount options=(rw,make-unbindable) -> **,
87 # mount options=(rw,make-runbindable) -> **,
89 # allow bind-mounts of anything except /proc, /sys and /dev
90 mount options=(rw,bind) /[^spd]*{,/**},
91 mount options=(rw,bind) /d[^e]*{,/**},
92 mount options=(rw,bind) /de[^v]*{,/**},
93 mount options=(rw,bind) /dev/.[^l]*{,/**},
94 mount options=(rw,bind) /dev/.l[^x]*{,/**},
95 mount options=(rw,bind) /dev/.lx[^c]*{,/**},
96 mount options=(rw,bind) /dev/.lxc?*{,/**},
97 mount options=(rw,bind) /dev/[^.]*{,/**},
98 mount options=(rw,bind) /dev?*{,/**},
99 mount options=(rw,bind) /p[^r]*{,/**},
100 mount options=(rw,bind) /pr[^o]*{,/**},
101 mount options=(rw,bind) /pro[^c]*{,/**},
102 mount options=(rw,bind) /proc?*{,/**},
103 mount options=(rw,bind) /s[^y]*{,/**},
104 mount options=(rw,bind) /sy[^s]*{,/**},
105 mount options=(rw,bind) /sys?*{,/**},
107 # allow moving mounts except for /proc, /sys and /dev
108 mount options=(rw,move) /[^spd]*{,/**},
109 mount options=(rw,move) /d[^e]*{,/**},
110 mount options=(rw,move) /de[^v]*{,/**},
111 mount options=(rw,move) /dev/.[^l]*{,/**},
112 mount options=(rw,move) /dev/.l[^x]*{,/**},
113 mount options=(rw,move) /dev/.lx[^c]*{,/**},
114 mount options=(rw,move) /dev/.lxc?*{,/**},
115 mount options=(rw,move) /dev/[^.]*{,/**},
116 mount options=(rw,move) /dev?*{,/**},
117 mount options=(rw,move) /p[^r]*{,/**},
118 mount options=(rw,move) /pr[^o]*{,/**},
119 mount options=(rw,move) /pro[^c]*{,/**},
120 mount options=(rw,move) /proc?*{,/**},
121 mount options=(rw,move) /s[^y]*{,/**},
122 mount options=(rw,move) /sy[^s]*{,/**},
123 mount options=(rw,move) /sys?*{,/**},
125 # generated by: lxc-generate-aa-rules.py container-rules.base
126 deny /proc/sys/[^kn]*{,/**} wklx,
127 deny /proc/sys/k[^e]*{,/**} wklx,
128 deny /proc/sys/ke[^r]*{,/**} wklx,
129 deny /proc/sys/ker[^n]*{,/**} wklx,
130 deny /proc/sys/kern[^e]*{,/**} wklx,
131 deny /proc/sys/kerne[^l]*{,/**} wklx,
132 deny /proc/sys/kernel/[^smhd]*{,/**} wklx,
133 deny /proc/sys/kernel/d[^o]*{,/**} wklx,
134 deny /proc/sys/kernel/do[^m]*{,/**} wklx,
135 deny /proc/sys/kernel/dom[^a]*{,/**} wklx,
136 deny /proc/sys/kernel/doma[^i]*{,/**} wklx,
137 deny /proc/sys/kernel/domai[^n]*{,/**} wklx,
138 deny /proc/sys/kernel/domain[^n]*{,/**} wklx,
139 deny /proc/sys/kernel/domainn[^a]*{,/**} wklx,
140 deny /proc/sys/kernel/domainna[^m]*{,/**} wklx,
141 deny /proc/sys/kernel/domainnam[^e]*{,/**} wklx,
142 deny /proc/sys/kernel/domainname?*{,/**} wklx,
143 deny /proc/sys/kernel/h[^o]*{,/**} wklx,
144 deny /proc/sys/kernel/ho[^s]*{,/**} wklx,
145 deny /proc/sys/kernel/hos[^t]*{,/**} wklx,
146 deny /proc/sys/kernel/host[^n]*{,/**} wklx,
147 deny /proc/sys/kernel/hostn[^a]*{,/**} wklx,
148 deny /proc/sys/kernel/hostna[^m]*{,/**} wklx,
149 deny /proc/sys/kernel/hostnam[^e]*{,/**} wklx,
150 deny /proc/sys/kernel/hostname?*{,/**} wklx,
151 deny /proc/sys/kernel/m[^s]*{,/**} wklx,
152 deny /proc/sys/kernel/ms[^g]*{,/**} wklx,
153 deny /proc/sys/kernel/msg*/** wklx,
154 deny /proc/sys/kernel/s[^he]*{,/**} wklx,
155 deny /proc/sys/kernel/se[^m]*{,/**} wklx,
156 deny /proc/sys/kernel/sem*/** wklx,
157 deny /proc/sys/kernel/sh[^m]*{,/**} wklx,
158 deny /proc/sys/kernel/shm*/** wklx,
159 deny /proc/sys/kernel?*{,/**} wklx,
160 deny /proc/sys/n[^e]*{,/**} wklx,
161 deny /proc/sys/ne[^t]*{,/**} wklx,
162 deny /proc/sys/net?*{,/**} wklx,
163 deny /sys/[^fdck]*{,/**} wklx,
164 deny /sys/c[^l]*{,/**} wklx,
165 deny /sys/cl[^a]*{,/**} wklx,
166 deny /sys/cla[^s]*{,/**} wklx,
167 deny /sys/clas[^s]*{,/**} wklx,
168 deny /sys/class/[^n]*{,/**} wklx,
169 deny /sys/class/n[^e]*{,/**} wklx,
170 deny /sys/class/ne[^t]*{,/**} wklx,
171 deny /sys/class/net?*{,/**} wklx,
172 deny /sys/class?*{,/**} wklx,
173 deny /sys/d[^e]*{,/**} wklx,
174 deny /sys/de[^v]*{,/**} wklx,
175 deny /sys/dev[^i]*{,/**} wklx,
176 deny /sys/devi[^c]*{,/**} wklx,
177 deny /sys/devic[^e]*{,/**} wklx,
178 deny /sys/device[^s]*{,/**} wklx,
179 deny /sys/devices/[^v]*{,/**} wklx,
180 deny /sys/devices/v[^i]*{,/**} wklx,
181 deny /sys/devices/vi[^r]*{,/**} wklx,
182 deny /sys/devices/vir[^t]*{,/**} wklx,
183 deny /sys/devices/virt[^u]*{,/**} wklx,
184 deny /sys/devices/virtu[^a]*{,/**} wklx,
185 deny /sys/devices/virtua[^l]*{,/**} wklx,
186 deny /sys/devices/virtual/[^n]*{,/**} wklx,
187 deny /sys/devices/virtual/n[^e]*{,/**} wklx,
188 deny /sys/devices/virtual/ne[^t]*{,/**} wklx,
189 deny /sys/devices/virtual/net?*{,/**} wklx,
190 deny /sys/devices/virtual?*{,/**} wklx,
191 deny /sys/devices?*{,/**} wklx,
192 deny /sys/f[^s]*{,/**} wklx,
193 deny /sys/fs/[^c]*{,/**} wklx,
194 deny /sys/fs/c[^g]*{,/**} wklx,
195 deny /sys/fs/cg[^r]*{,/**} wklx,
196 deny /sys/fs/cgr[^o]*{,/**} wklx,
197 deny /sys/fs/cgro[^u]*{,/**} wklx,
198 deny /sys/fs/cgrou[^p]*{,/**} wklx,
199 deny /sys/fs/cgroup?*{,/**} wklx,
200 deny /sys/fs?*{,/**} wklx,
203 # Allow receive via unix sockets from anywhere
206 # Allow all unix in the container
207 unix peer=(label=@{profile_name}),
209 ### Feature: cgroup namespace
210 mount fstype=cgroup -> /sys/fs/cgroup/**,
212 ### Configuration: nesting
217 deny /dev/.lxd/proc/** rw,
218 deny /dev/.lxd/sys/** rw,
220 mount /var/lib/lxd/shmounts/ -> /var/lib/lxd/shmounts/,
221 mount none -> /var/lib/lxd/shmounts/,
222 mount fstype=proc -> /usr/lib/*/lxc/**,
223 mount fstype=sysfs -> /usr/lib/*/lxc/**,
224 mount options=(rw,bind),
225 mount options=(rw,rbind),
226 mount options=(rw,make-rshared),
228 # there doesn't seem to be a way to ask for:
229 # mount options=(ro,nosuid,nodev,noexec,remount,bind),
230 # as we always get mount to $cdir/proc/sys with those flags denied
231 # So allow all mounts until that is straightened out:
233 mount options=bind /var/lib/lxd/shmounts/** -> /var/lib/lxd/**,
235 mount options=(rw,make-slave) -> **,
236 mount options=(rw,make-rslave) -> **,
237 mount options=(rw,make-shared) -> **,
238 mount options=(rw,make-rshared) -> **,
239 mount options=(rw,make-private) -> **,
240 mount options=(rw,make-rprivate) -> **,
241 mount options=(rw,make-unbindable) -> **,
242 mount options=(rw,make-runbindable) -> **,
244 mount options=(rw,bind),
245 mount options=(rw,rbind),