Commit Graph

4151 Commits

Author SHA1 Message Date
Jiyong Park
04d2392c35 Don't use apexd when TARGET_FLATTEN_APEX == true
/system/apex/com.android.runtime is labeled as runtime_apex_dir
and init is allowed to mount on it.

When TARGET_FLATTEN_APEX is true (= ro.apex.updatable is unset or set to
false), apexd is not used to activate the built-in flattened APEXes.
Init simply bind-mounts /system/apex to /apex.

However, there is a special case here. The runtime APEX is installed as
either /system/apex/com.android.runtime.debug or
/system/apex/com.android.runtime.release, whereas it should be activated
on /apex/com.android.runtime - without the .debug or .release suffix.
To handle that case, the build system creates an empty directory
/system/apex/com.android.runtime and the .debug or .release directory
is bind-mounted to the empty directory by init at runtime.

Bug: 132413565
Test: marlin is bootable
Merged-In: I3fde5ff831429723fecd1fa5c10e44f636a63f09
Change-Id: I3fde5ff831429723fecd1fa5c10e44f636a63f09
(cherry picked from commit 99902a175b)
2019-05-29 07:06:28 +09:00
David Anderson
e93049f9f1 Merge "Allow init to mkdir inside /data/gsi." 2019-05-28 14:58:40 +00:00
Treehugger Robot
b693197a34 Merge "drop "allow healthd self:process execmem;"" 2019-05-23 22:17:31 +00:00
David Anderson
0b1094cc23 Allow init to mkdir inside /data/gsi.
Bug: 133435561
Test: adb shell gsi_tool install
Change-Id: Iaa610c72d8098e157bb89e321624369f86f4ea19
2019-05-23 13:45:00 -07:00
David Anderson
0f0fbd44f9 Merge "Fix selinux denials when applying updates in recovery." 2019-05-23 20:15:45 +00:00
Nick Kralevich
b192f0e7c7 drop "allow healthd self:process execmem;"
The execmem capability indicates that the processes creates anonymous
executable memory, which is most commonly used for JITing functionality.
All of the healthd executable code comes from the filesystem, and
healthd does not rely on JITing or loading code from non-file based
sources, so this permission is unnecessary.

Bug: 32659667
Test: compiles and boots
Change-Id: Ifb2b68625b191cb002dbb134cace6ddd215236e8
2019-05-23 11:17:21 -07:00
David Anderson
d431c2bfe5 Fix selinux denials when applying updates in recovery.
These lines are copied from update_engine.te, and are needed to update
dynamic partitions in recovery.

Bug: 132943965
Test: sideload OTA on cuttlefish
Change-Id: Id03a658aac69b8d20fa7bb758530a4469c75cf9c
2019-05-22 15:52:03 -07:00
Nikita Ioffe
1c4a5260c1 selinux: Allow dumpstate send signals to vold
Test: adb bugreport
Test: verified vold stacktrace is present in bugreport
Bug: 132344997
Change-Id: I0ebf7f171d854b9aaf894ccb8c7a5f68f18e692b
Merged-In: I0ebf7f171d854b9aaf894ccb8c7a5f68f18e692b
(cherry picked from commit f7c3d19d29)
2019-05-21 20:39:07 +01:00
Tao Bao
ccf8af80b0 Merge "Add vendor_misc_writer." 2019-05-21 13:41:07 +00:00
Treehugger Robot
5a3d30eadf Merge "Relabel /proc/kpageflags and grant access to heapprofd." 2019-05-21 00:03:59 +00:00
Tao Bao
42c05cfcc1 Add vendor_misc_writer.
The space between 2K and 16K in /misc is currently reserved for vendor's
use (as claimed in bootloader_message.h), but we don't allow vendor
module to access misc_block_device other than vendor_init.

The change in the topic adds a `misc_writer` tool as a vendor module,
which allows writing data to the vendor space to bridge the gap in the
short term. This CL adds matching labels to grant access.

Long term goal is to move /misc as vendor owned, then to provide HAL
access from core domain (b/132906936).

Bug: 132906936
Test: Build crosshatch that includes misc_writer module. Invoke
      /vendor/bin/misc_writer to write data to /misc.
Change-Id: I4c18d78171a839ae5497b3a61800193ef9e51b3b
2019-05-20 14:40:15 -07:00
Florian Mayer
87b5e75042 Relabel /proc/kpageflags and grant access to heapprofd.
Bug: 132952543

Change-Id: I3d956ba7279af37d783515c0bf649e6fb94c3082
2019-05-20 20:18:10 +01:00
Tao Bao
264a929edb Set persist.sys.device_provisioned vendor-init-readable.
`persist.sys.device_provisioned` is set (more precisely, "will be set",
via internal change in ag/7567585) by system_server based on device
privisioning state. This CL grants vendor_init to set up action triggers
based on the property value.

avc:  denied  { read } for property=persist.sys.device_provisioned pid=0 uid=0 gid=0 scontext=u:r:vendor_init:s0 tcontext=u:object_r:system_prop:s0 tclass=file permissive=0

Bug: 131702833
Bug: 132906936
Test: Set an init trigger that waits on `persist.sys.device_provisioned`.
      Check that there's no longer a denial.
Change-Id: I64e50bd31c90db4b3bdd3bd014a90d7bef708b57
2019-05-20 10:44:04 -07:00
Treehugger Robot
21770a1603 Merge "Allow init to set context for super_block_device" 2019-05-17 23:16:33 +00:00
Hridya Valsaraju
217e977107 Allow init to set context for super_block_device
Fixes the following denial during boot:

[    1.358156] selinux: SELinux: Could not set context for
/dev/block/platform/soc/1d84000.ufshc/by-name/super:  Permission denied\x0a
[    1.358275] audit: type=1400 audit(951562.676:7):
avc:  denied  { relabelto } for  pid=1 comm="init" name="super"
dev="tmpfs" ino=17657 scontext=u:r:init:s0 tcontext=u:object_r:super_block_device:s0
tclass=lnk_file permissive=0

Bug: 124410201
Test: make
Change-Id: Ib6752b8a6ae4211ba8c0a7417295b8144a2fed67
2019-05-17 09:35:51 -07:00
Nick Kralevich
9fd6a90a4c Delete ineffective netd neverallow assertion
It doesn't make sense to write neverallow assertions where an attribute
negation exists allowing the operation. When such a negation exists,
domains can "opt-out" of the neverallow assertion by declaring their
use of the attribute. Such trivially bypassable assertions provide
no security nor architectural guarantees.

"netdomain" is such an attribute. This attribute is used by processes to
indicate that they communicate with the network, for example, using
TCP/UDP sockets. Vendor code is freely allowed to use network
communication by declaring their use of the attribute.

Because the attribute is usable to any vendor domain, the "no socket
connections to netd" restriction is pointless and provides a false sense
of security. Any process can opt-out of these restrictions by just
declaring their use of networking functionality. This also results in
ineffective policy bloat, making it difficult to reason about the policy
and make changes.

Delete the ineffective, misleading neverallow assertion.

Test: compiles
Change-Id: Ia72d9660a337ef811e56c9227af29b17d043b99f
2019-05-14 01:33:55 -07:00
Maciej Żenczykowski
44328c061d sepolicy - move public clatd to private
Clatd is effectively an internal implementation detail of netd.
It exists as a separate daemon only because this gives us a better
security boundary.  Netd is it's only launcher (via fork/exec) and
killer.

Generated via:
  { echo; cat public/clatd.te; echo; } >> private/clatd.te
  rm -f public/clatd.te

  plus a minor edit to put coredomain after clatd type declaration
  and required changes to move netd's clatd use out of public into private.

Test: build and install on non-aosp test device, atest, check for selinux clat denials
Change-Id: I80f110b75828f3657986e64650ef9e0f9877a07c
2019-05-11 17:47:25 -07:00
Maciej Żenczykowski
fbae4d9b35 Merge "selinux - remove clatd tun creation privs" 2019-05-09 00:11:29 +00:00
Treehugger Robot
5a883148a0 Merge "Move ro.boot.dynamic_partitions to vendor" 2019-05-08 21:39:26 +00:00
Maciej Żenczykowski
3e41b297d2 selinux - remove clatd tun creation privs
No longer needed, since this is now done by netd.

In a separate commit so it can potentially not be backported to Q
if we so desire.

Test: build/installed on crosshatch with netd/clatd changes,
  and observed functioning ipv4 on ipv6 only network with no
  avc denials

Bug: 65674744
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Id927ee73469d3e90f5111bd5e31ed760a58c8ebe
2019-05-08 10:22:48 +00:00
Maciej Żenczykowski
8fa5ebdee7 mtp: support using pppox_socket family
Kernel commit da69a5306ab92e07224da54aafee8b1dccf024f6
("selinux: support distinctions among all network address families")
modified the kernel to support fine grain differentiation of socket
families, if userspace enables it (which Android does).

Modify the mtp SELinux policy to allow the use of pppox_socket
(needed for kernels 4.14 or greater) and the generic "socket" family
(for kernels below 4.14).

Bug: 130852066
Test: compiles
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I8ac4c2f98f823120060e51438b39254898f4a27e
2019-05-08 01:16:38 -07:00
Hridya Valsaraju
761ce69a25 Move ro.boot.dynamic_partitions to vendor
VTS tests are run after flashing a GSI image on the device.
The properties ro.boot.dynamic_partitions and ro.boot.dynamic_partitions_retrofit
are currently placed in product partition and will be overwritten by the GSI image.
We need to move these properties to vendor partition so that they will be available
even after the device is flashed with GSI.

Bug: 132197773
Test: build and flash, adb getprop ro.boot.dynamic_partitions
Change-Id: Ib04896ef744d8d2daa5cb3feee2cbf45aae2ba51
2019-05-07 16:16:27 -07:00
Treehugger Robot
3e034a2270 Merge "dontaudit su unlabeled:vsock_socket *" 2019-05-07 00:36:51 +00:00
Maciej Żenczykowski
ae68bf23b6 dontaudit su unlabeled:vsock_socket *
Fix for:
  type=1400 audit(): avc: denied { getopt } for comm=73657276657220736F636B6574 scontext=u:r:su:s0 tcontext=u:object_r:unlabeled:s0 tclass=vsock_socket
  type=1400 audit(): avc: denied { setopt } for comm=73657276657220736F636B6574 scontext=u:r:su:s0 tcontext=u:object_r:unlabeled:s0 tclass=vsock_socket
  type=1400 audit(): avc: denied { read } for comm="adbd" scontext=u:r:su:s0 tcontext=u:object_r:unlabeled:s0 tclass=vsock_socket
  type=1400 audit(): avc: denied { write } for comm="adbd" scontext=u:r:su:s0 tcontext=u:object_r:unlabeled:s0 tclass=vsock_socket

Test: now less audit warnings!
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I3bd1b2262dc6dcb099403d24611db66aac9aecb0
2019-05-06 14:36:39 -07:00
Nick Kralevich
e9cafb91d2 ppp: support using pppox_socket family
Kernel commit da69a5306ab92e07224da54aafee8b1dccf024f6
("selinux: support distinctions among all network address families")
modified the kernel to support fine grain differentiation of socket
families, if userspace enables it (which Android does).

Modify the ppp SELinux policy to allow the use of pppox_socket
(needed for kernels 4.14 or greater) and the generic "socket" family
(for kernels below 4.14).

Addresses the following denials:

04-19 20:25:34.059 16848 16848 I pppd    : type=1400 audit(0.0:8703): avc: denied { read write } for dsm=HS_Q path="socket:[171178]" dev="sockfs" ino=171178 scontext=u:r:ppp:s0 tcontext=u:r:mtp:s0 tclass=pppox_socket permissive=1
04-19 20:25:34.075 16848 16848 I pppd    : type=1400 audit(0.0:8704): avc: denied { ioctl } for dsm=HS_Q path="socket:[171179]" dev="sockfs" ino=171179 ioctlcmd=0x7437 scontext=u:r:ppp:s0 tcontext=u:r:mtp:s0 tclass=pppox_socket permissive=1

Bug: 130852066
Test: compiles
Change-Id: I00cc07108acaac5f2519ad0093d9db9572e325dc
2019-05-06 12:57:51 -07:00
Maciej Żenczykowski
6450e0038b selinux - allow netd to create tun device and pass it in via open fd across execve to clatd cli
This is needed to resolve some race conditions between clatd startup and interface naming/numbering.

This resolves:
  type=1400 audit(): avc: denied { read write } for comm="Binder:820_4" name="tun" dev="tmpfs" ino=20564 scontext=u:r:netd:s0 tcontext=u:object_r:tun_device:s0 tclass=chr_file
  type=1400 audit(): avc: denied { open } for comm="Binder:820_4" path="/dev/tun" dev="tmpfs" ino=20564 scontext=u:r:netd:s0 tcontext=u:object_r:tun_device:s0 tclass=chr_file
  type=1400 audit(): avc: denied { ioctl } for comm="Binder:820_4" path="/dev/tun" dev="tmpfs" ino=20564 ioctlcmd=0x54ca scontext=u:r:netd:s0 tcontext=u:object_r:tun_device:s0 tclass=chr_file
  type=1400 audit(): avc: denied { create } for comm="Binder:820_4" scontext=u:r:netd:s0 tcontext=u:r:netd:s0 tclass=tun_socket

Test: built/installed on crosshatch with netd->clatd tunfd passing and observed no selinux denials
Bug: 65674744
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ib501c755e11ec8a3a22c8aa333b5af7ec0bff306
2019-05-05 02:55:20 +00:00
Maciej Żenczykowski
b3b12729f4 Merge "selinux - netd - tighten down bpf policy" 2019-05-03 22:28:00 +00:00
Maciej Żenczykowski
487fcb87c0 selinux - netd - tighten down bpf policy
bpf programs/maps are now loaded by the bpfloader, not netd

Test: built/installed on crosshatch which uses eBPF - no avc denials

Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1ebd82e6730d62d1966da3c4634ecd78ce703543
2019-05-03 19:39:46 +00:00
Maciej Żenczykowski
210cdc6fa4 dnsmasq - allow getattr on unix stream sockets
Fix for:
  type=1400 audit(): avc: denied { getattr } for comm="dnsmasq" path="socket:[25224]" dev="sockfs" ino=25224 scontext=u:r:dnsmasq:s0 tcontext=u:r:netd:s0 tclass=unix_stream_socket permissive=0 b/77868789

Test: built and observed no more avc denials on aosp blueline

Bug: 77868789
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I5af4d01e17f2d37335f523a49c7b1f81886edfa2
2019-05-03 06:16:57 +00:00
Treehugger Robot
3db3b1148b Merge "Add TODOs" 2019-05-02 18:41:55 +00:00
Treehugger Robot
21417a7965 Merge "selinux - allow dnsmasq to getattr on fifos" 2019-05-02 17:37:20 +00:00
Nick Kralevich
44b0efb332 Add TODOs
Bug: 131761776
Test: compiles
Change-Id: Iba3ad475ce25a1ece96717ceecb7c4df8e358d48
2019-05-02 08:29:21 -07:00
Treehugger Robot
1415c2da7d Merge "Allow psi monitor users to setched kernel threads" 2019-05-02 14:48:41 +00:00
Maciej Żenczykowski
afa10f7223 selinux - allow dnsmasq to getattr on fifos
This is presumably libc isatty detection on stdin/out/err.
Either way - allowing it is harmless.

This fixes:
  type=1400 audit(): avc: denied { getattr } for comm="dnsmasq" path="pipe:[38315]" dev="pipefs" ino=38315 scontext=u:r:dnsmasq:s0 tcontext=u:r:netd:s0 tclass=fifo_file permissive=0

Test: built and observed no more avc denials on crosshatch

Bug: 77868789
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ieab51aeb67ebb85b6c778410ba96963612277ae4
2019-05-01 18:04:22 -07:00
Wei Wang
e95d8e9550 Allow psi monitor users to setched kernel threads
psi monitor sched_setscheduler(kworker->task, SCHED_FIFO, &param) was added into pa/1282597

Bug: 131252752
Bug: 129476847
Test: build
Change-Id: I69fdd90e4a39da8d33b417efc7ea7a0da9d9290b
2019-05-01 10:23:02 -07:00
Anton Hansson
c165185e05 Make new vendor properties settable by vendor_init
These properties were moved to /vendor as part of b/130025216.
Allow them to be set by vendor_init, too.

Bug: 130025216
Bug: 131066061
Test: no SELinux warnings for said props at boot
Change-Id: I5293831bedb89e9c8d3ddf13cf7babde26872f28
2019-05-01 13:21:17 +01:00
Treehugger Robot
4eb1a20c77 Merge "Sepolicy: add dynamic_system_prop" 2019-05-01 10:33:29 +00:00
Hung-ying Tyan
565384db61 Sepolicy: add dynamic_system_prop
and allow shell and system_app (Settings) to set it to enable Dynamic System Update.
Also allow priv_app (user of the API) to read it.

Bug: 119647479
Bug: 129060539
Test: run the following command on crosshatch-user:
      adb shell setprop persist.sys.fflag.override.settings_dynamic_system 1

Change-Id: I24a5382649c64d36fd05a59bc87faca87e6f0eb8
Merged-In: I24a5382649c64d36fd05a59bc87faca87e6f0eb8
2019-04-30 18:29:56 +08:00
Jim Blackler
3cfad10c04 lmkd: grant access to /proc/lowmemorykiller
lmkd needs to read /proc/lowmemorykiller to send statslog events in response to
applications being killed.

Bug: 130017100
Change-Id: I929d5a372e1b2f63b7b5ed421f1898ebddaec01c
2019-04-29 10:49:58 +00:00
Carmen Jackson
2798b5fc93 Add selinux rule to allow Traceur to enable the traced daemon.
Bug: 130784724
Test: manual
Change-Id: Ic1903e273f5a136b3e0b14a901a60d8d0a81b211
Merged-In: Ic1903e273f5a136b3e0b14a901a60d8d0a81b211
2019-04-26 16:18:56 -07:00
Miao Wang
8c2f4babee Allow NNAPI HAL services access model files provided by privapp.
Bug: 131169221
Test: mm
Change-Id: I1004821bd30e2a0586b14178e352e885cabfc002
(cherry picked from commit aa568e1c79)
2019-04-24 21:15:45 -07:00
Luke Huang
75b25384bb Merge "Sepolicy for netutils_wrapper to use binder call" 2019-04-25 03:09:30 +00:00
Treehugger Robot
91c35aeab6 Merge "Adding vendor_apex_file for /vendor/apex" 2019-04-24 23:32:56 +00:00
Treehugger Robot
e4af840db6 Merge "Allow idmap1 to read vmdl*.tmp APK install files" 2019-04-24 19:56:48 +00:00
Jooyung Han
ea61d198f2 Adding vendor_apex_file for /vendor/apex
apexd needs to read /vendor/apex dir and files in it.

Bug: 131190070
Bug: 123378252
Test: 1. Add apex to /vendor/apex
      -> see if boot succeeds with new policy
      2. Add flattened apex to /vendor/apex
      -> see if only root files are labelled as vendor_apex_file

Change-Id: I37795ab6d659ac82639ba5e34d628fe1b5cdb350
2019-04-25 02:54:14 +09:00
Winson Chiu
7e7291a763 Allow idmap1 to read vmdl*.tmp APK install files
When upgrading a package, PackageParser acts on the temporary
APK file copied from the install location. This is passed to
idmap, which doesn't have read access because it's missing an
SELinux rule.

This is needed to fix a bug with manifest overlaying on updating
an app, a feature kept alive for Q.

Relevant logs when updating a target:
[  550.068083] type=1400 audit(1556124408.583:3812): avc: denied { read } for comm="idmap" name="base.apk" dev="vdc" ino=8770 scontext=u:r:idmap:s0 tcontext=u:object_r:apk_tmp_file:s0 tclass=file permissive=1
[  550.090115] type=1400 audit(1556124408.583:3812): avc: denied { read } for comm="idmap" name="base.apk" dev="vdc" ino=8770 scontext=u:r:idmap:s0 tcontext=u:object_r:apk_tmp_file:s0 tclass=file permissive=1
[  550.092064] type=1400 audit(1556124408.603:3813): avc: denied { open } for comm="idmap" path="/data/app/vmdl1238645679.tmp/base.apk" dev="vdc" ino=8770 scontext=u:r:idmap:s0 tcontext=u:object_r:apk_tmp_file:s0 tclass=file permissive=1
[  550.096202] type=1400 audit(1556124408.603:3813): avc: denied { open } for comm="idmap" path="/data/app/vmdl1238645679.tmp/base.apk" dev="vdc" ino=8770 scontext=u:r:idmap:s0 tcontext=u:object_r:apk_tmp_file:s0 tclass=file permissive=1
[  550.098459] type=1400 audit(1556124408.613:3814): avc: denied { map } for comm="idmap" path="/data/app/vmdl1238645679.tmp/base.apk" dev="vdc" ino=8770 scontext=u:r:idmap:s0 tcontext=u:object_r:apk_tmp_file:s0 tclass=file permissive=1
[  550.101640] type=1400 audit(1556124408.613:3814): avc: denied { map } for comm="idmap" path="/data/app/vmdl1238645679.tmp/base.apk" dev="vdc" ino=8770 scontext=u:r:idmap:s0 tcontext=u:object_r:apk_tmp_file:s0 tclass=file permissive=1
[  550.104239] type=1400 audit(1556124408.613:3815): avc: denied { getattr } for comm="idmap" path="/data/app/vmdl1238645679.tmp/base.apk" dev="vdc" ino=8770 scontext=u:r:idmap:s0 tcontext=u:object_r:apk_tmp_file:s0 tclass=file permissive=1

Bug: 130559507

Test: manual adb push /system/product/app/TestApp.apk with
/system/product/overlay/TestOverlay.apk enabling disabled launcher
Activity in TestApp; adb install -r TestApp.apk keeps enabled state
with changes

Change-Id: Ieeb7fb4f79ae091d0febf42ca358e7ffdfa6c3ff
2019-04-24 16:48:06 +00:00
Treehugger Robot
e556d33294 Merge "Allow signals to power/thermal HAL from dumpstate" 2019-04-24 06:39:24 +00:00
Tao Bao
2952a20565 Merge "Move ro.build.ab_update to vendor property." 2019-04-23 22:16:48 +00:00
Wei Wang
addfe4679d Allow signals to power/thermal HAL from dumpstate
Bug: 129711808
Test: Take BR
Change-Id: Ibcb03698a6e2966f4913ddb6e674502bce4df235
2019-04-23 14:22:41 -07:00
Mikhail Naganov
1c3b84b00d Merge "Allow mediaserver to find "audio" service" 2019-04-23 16:46:16 +00:00