Commit graph

65 commits

Author SHA1 Message Date
Ricky Wai
15fb633cb5 Allow zygote to read storage properties
Bug: 151316657
Test: Able to boot without warnings
Change-Id: If53e472b560d5cf73c145d668bc462ca6881fe4e
2020-06-30 10:27:58 +01:00
Inseob Kim
6ffdf1b001 Add new context packagemanager_config_prop
To remove bad context names exported[23]_default_prop

Bug: 155844385
Test: m selinux_policy
Change-Id: Ic4bbc8e45d810368a96f6985c2234798e73be82d
Merged-In: Ic4bbc8e45d810368a96f6985c2234798e73be82d
(cherry picked from commit 072b01438e)
2020-06-19 17:47:19 +09:00
Jiyong Park
93a99cf8fc Introduce apex_info_file type
/apex/apex-info-file.xml is labeled as apex_info_file. It is
created/written by apexd once by apexd, and can be read by zygote and
system_server. The content of the file is essentially the same as the
return value of getAllPackages() call to apexd.

Bug: 154823184
Test: m
Merged-In: Ic6af79ddebf465b389d9dcb5fd569d3a786423b2
(cherry picked from commit f1de4c02cc)
Change-Id: Ic6af79ddebf465b389d9dcb5fd569d3a786423b2
2020-05-27 09:35:11 +09:00
Ricky Wai
037e11b86e Ignore errors that zygote tries to setattr media_rw_data_file dir
Bug: 152043945
Test: No selinux error in boot
Change-Id: Id01377e6b8c7be9103bd1dec3283cf720e6f6af9
2020-03-23 17:13:00 +00:00
Pawin Vongmasa
76d7cf961e Allow XML file paths to be customized with sysprop
Three properties are declared as vendor-init-settable:
ro.media.xml_variant.codecs
ro.media.xml_variant.codecs_performance
ro.media.xml_variant.profiles

media_codecs.xml can now be named
media_codecs${ro.media.xml_variant.codecs}.xml

media_codecs_performance.xml can now be named
media_codecs_performance${ro.media.xml_variant.codecs_performance}.xml

media_profiles_V1_0 can now be named
media_profiles${ro.media.xml_variant.profiles}.xml

Test: Rename "media_codecs.xml" to "media_codecs_test.xml",
set ro.media.xml_variant.codecs to "_test", then
call "stagefright -i".

Test: Rename "media_codecs_performance.xml" to
"media_codecs_performance_test.xml",
set ro.media.xml_variant.codecs_performance to "_test", then
run android.media.cts.VideoDecoderPerfTest.

Test: Rename "media_profiles_V1_0.xml" to "media_profiles_test.xml",
set ro.media.xml_variant.profiles to "_test", then
run vts_mediaProfiles_validate_test.

Bug: 142102953
Change-Id: I407a0a327fcc8e799bb4079b11048a497565be48
2020-03-18 06:02:55 -07:00
Ricky Wai
ad538514a7 Allow zygote to go into media directory to bind mount obb dir
Bug: 148049767
Change-Id: I2134de4df0db3268340fcfec6ad1cb8a94e3e8f9
2020-02-19 14:24:27 +00:00
Zimuzo Ezeozue
5119becf5d Merge "Grant vold, installd, zygote and apps access to /mnt/pass_through" 2020-01-28 22:26:58 +00:00
Zim
fcf599c89c Grant vold, installd, zygote and apps access to /mnt/pass_through
/mnt/pass_through was introduced to allow the FUSE daemon unrestricted
 access to the lower filesystem (or sdcardfs).

At zygote fork time, the FUSE daemon will have /mnt/pass_through/0
bind mounted to /storage instead of /mnt/user/0. To keep /sdcard
(symlink to /storage/self/primary) paths working, we create a
'self' directory  with an additional 'primary' symlink to
/mnt/pass_through/0/emulated/0 which is a FUSE mount point.

The following components need varying sepolicy privileges:

Vold: Creates the self/primary symlink and mounts the lower filesystem
on /mnt/pass_through/0/emulated. So needs create_dir and mount access
+ create_file access for the symlink

zygote: In case zygote starts an app before vold sets up the paths.
This is unlikely but can happen if the FUSE daemon (a zygote forked app)
is started before system_server completes vold mounts.
Same sepolicy requirements as vold

installd: Needs to clear/destroy app data using lower filesystem
mounted on /mnt/pass_through so needs read_dir access to walk
/mnt/pass_through

priv_app (FUSE daemon): Needs to server content from the lower
filesystem mounted on /mnt/pass_through so needs read_dir access to
walk /mnt/pass_through

Bug: 135341433
Test: adb shell ls /mnt/pass_through/0/self/primary
Change-Id: I16e35b9007c2143282600c56adbc9468a1b7f240
2020-01-28 20:56:36 +00:00
Treehugger Robot
b9b2acff99 Merge "Whitelisting window_manager_native_boot system property" 2020-01-24 19:52:07 +00:00
Valerie Hau
7b2a2dff0c Whitelisting window_manager_native_boot system property
Bug: 147096935
Test: build, boot

Change-Id: Iadeefa3cfc9bb17eb19b60dbd18de047fa01b673
2020-01-21 22:54:49 +00:00
Jing Ji
2b12440ff7 Add rules for an unix domain socket for system_server
System_server will listen on incoming packets from zygotes.

Bug: 136036078
Test: atest CtsAppExitTestCases:ActivityManagerAppExitInfoTest
Change-Id: I42feaa317615b90c5277cd82191e677548888a71
2020-01-16 16:09:48 -08:00
Ricky Wai
ca6e01aa53 Allow zygote to bind mount /data/misc/profiles/cur
Bug: 143937733
Test: No denials at boot
Test: No denials seen when creating moun
Change-Id: Ia6b196dde6ed511ebff53b03891122b1120fec07
2020-01-14 11:34:15 +00:00
Ricky Wai
b2b7c02e7d Allow zygote to relabel CE and DE dirs from tmpfs to system_data_file
Also, allow zygote to scan dirs in /mnt/expand and relabel.

Test: No denials at boot
Test: No denials seen when creating mounts
Bug: 143937733
Change-Id: I86e77d27f5e9fb2f5852f787c7e5d9179c7404aa
2020-01-10 14:26:40 +00:00
Ricky Wai
5b1b423039 Allow Zygote and Installd to remount directories in /data/data
Zygote/Installd now can do the following operations in app data directory:
- Mount on it
- Create directories in it
- Mount directory for each app data, and get/set attributes

Bug: 143937733
Test: No denials at boot
Test: No denials seen when creating mounts
Change-Id: I6e852a5f5182f1abcb3136a3b23ccea69c3328db
2019-12-13 12:30:26 +00:00
Martijn Coenen
357eb193e9 Revert "Temporarily relax Zygote storage mounting rules."
This reverts commit 9f02b30a72.

This is no longer needed, because we never shipped app storage
sandboxes.

Bug: 130812417
Test: builds
Change-Id: Ia1f51db4904742d2ef15222f2350c67af0dd4a28
2019-11-22 16:02:07 +01:00
Tri Vo
f25025f6ff Reland "sepolicy: fix zygote JIT permissions w.r.t. ashmem"
zygote now allocates JIT memory using libcutils API (aosp/1135101)
instead of going to /dev/ashmem directly, which requires execute
permissions to ashmem_libcutils_device.

Bug: 134434505
Change-Id: I3b5eeac1ec06d8d70da327743174ca83eec6b41c
Test: boot crosshatch
2019-10-15 22:26:56 +00:00
Orion Hodson
09d9076513 Revert "sepolicy: fix zygote JIT permissions w.r.t. ashmem"
This reverts commit 7120b72a9b.

Reason for revert: http://b/142742451

Change-Id: Ib857e0a56a83c0466b92f944421e3bd11c9279b4
2019-10-15 21:15:44 +00:00
Tri Vo
7120b72a9b sepolicy: fix zygote JIT permissions w.r.t. ashmem
zygote now allocates JIT memory using libcutils API (aosp/1135101)
instead of going to /dev/ashmem directly, which requires execute
permissions to ashmem_libcutils_device.

Bug: 134434505
Test: boot crosshatch
Change-Id: I0a54d64bd4656fafd2f03701d7828cfa94c08f04
2019-10-08 11:31:46 -07:00
Tri Vo
08bf97db8c sepolicy: allow zygote to use ashmem fds
Ashmem FD selinux labels have recently been changed (aosp/1127917) from
"ashmemd" to the label of the whichever process opens the fd, which
resulted in the following denial:

avc: denied { use } for
path="/dev/ashmemf5dc2dbf-d1e7-457e-b694-93c84704135e" dev="tmpfs"
ino=18972 ioctlcmd=0x7704 scontext=u:r:zygote:s0
tcontext=u:r:system_server:s0 tclass=fd permissive=1

Test: m selinux_policy
Change-Id: I4880420014bda21cd4f83e3d6190c3cfaa76822f
2019-10-02 15:25:48 -07:00
Nicolas Geoffray
f77e8c1b0c Allow zygote to create fds and map executable.
This is so that zygote can create the JIT cache with memfd_create
(or ashmem when memfd is not available).

Test: boot
Bug: 119800099
Change-Id: I88f1f6b1c930a8d22985b306a238f60b4af59f9c
2019-06-17 20:18:23 +01:00
Ryan Mitchell
ef1a64e231 Allow zygote to scan static overlays on /oem
During preloading resources, zygote scans the overlay directories of
supported partitions looking for android RROs to apply statically. Zygote
currently is allowed to read overlays in /oem/overlay, but zygote does
not have the search permission to be able to scan /oem.

Without this patch, this denial is logged:
04-04 14:57:40.136   876   876 I auditd  : type=1400 audit(0.0:9):
avc: denied { search } for comm="main" name="oem" dev="dm-3" ino=46
scontext=u:r:zygote:s0 tcontext=u:object_r:oemfs:s0 tclass=dir
permissive=0

Bug: 121033532
Test: booting without denials and stat oem succeeds
Change-Id: I661f3e0aff7ec3513870d08ddc122fc359b8f995
2019-04-17 16:06:34 +00:00
Steven Moreland
c46e31c961 private: allow zygote mnt_expand_file:dir getattr;
zygote is using this permission to preload Java libraries.

Bug: 128529256
Test: boot
Change-Id: If7e56409ae0171f5a04eadb2c297c865f9d4ffaf
2019-03-20 16:26:43 +00:00
Cheney Ni
e55a74bdff Add rules for accessing the related bluetooth_audio_hal_prop
This change allows those daemons of the audio and Bluetooth which
include HALs to access the bluetooth_audio_hal_prop. This property is
used to force disable the new BluetoothAudio HAL.
  - persist.bluetooth.bluetooth_audio_hal.disabled

Bug: 128825244
Test: audio HAL can access the property
Change-Id: I87a8ba57cfbcd7d3e4548aa96bc915d0cc6b2b74
2019-03-20 03:12:25 +00:00
Andreas Gampe
08450264ae Sepolicy: Allow zygote to pick up dalvikcache artifacts
Allow the zygote to pick up integrity-checked boot classpath
artifacts from the dalvik cache.

Bug: 125474642
Test: m
Test: manual
Merged-In: I45d760c981c55a52bd0b22c79a9cba4868a09528
Change-Id: I45d760c981c55a52bd0b22c79a9cba4868a09528
2019-03-19 10:36:12 -07:00
Sudheer Shanka
a3423bb74b Update a comment to match the latest rules.
Test: n/a
Change-Id: Ib45a25b3c9b987f56c350b91d72caca8a16fb52e
2019-02-14 11:48:49 -08:00
Sudheer Shanka
868c075e0e Allow zygote to create files under sdcardfs.
sdcardfs will automatically try to create .nomedia file
under Android/{data,obb} and this is being attributed
to whoever is trying to create Android/{data,obb} dirs.
Earlier this is used to done from app context but now
zygote handles the creation of these dirs.

Bug: 124345887
Test: manual
Change-Id: I96feada2f5edff2ece2586a532b069a58a36dd3b
2019-02-14 18:49:57 +00:00
Sudheer Shanka
176c91cc19 Allow zygote to create dirs under /mnt/user/*.
Bug: 124058579
Test: manual
Change-Id: I5b6736544cc8ffc9fd823834fe0edb7a388c6cf0
2019-02-08 12:01:50 -08:00
Sudheer Shanka
21095967f8 Allow zygote to mounton /mnt/user/*.
Bug: 124009234
Test: manual
Change-Id: Ia06506f5dbdacbb5e6e3c1b2bee7f58dec0ed0e7
2019-02-06 15:18:51 -08:00
Sudheer Shanka
5989be67fd Allow zygote to stat() sdcardfs file.
Bug: 123948473
Test: manual
Change-Id: I2d90c4dc90fbc0828e2f498bcab4801d93492321
2019-02-05 14:50:37 -08:00
Sudheer Shanka
ccec725ff9 Temporary rule to allow zygote to access vfat.
Extension to change Id633337095c0a3b69d9b8652bcc3327810339cf3
to deal with secondary storage devices.

Bug: 123533205
Test: manual
Change-Id: I24e1550af9589be9b238fba83837bf684aa02e3f
2019-02-04 16:38:41 -08:00
Mathieu Chartier
0327d10599 Add device_config_runtime_native_boot_prop
Some runtime properties require reboots and should be in the
native_boot namespace instead of native.

Bug: 120794191
Bug: 123524494
Test: set a property and ensure it can be read in AndroidRuntime.cpp
Change-Id: I1d1e984dcba26dd04d34a7d30fc63e1b75a8a311
2019-02-01 13:46:34 -08:00
Jeff Sharkey
9f02b30a72 Temporarily relax Zygote storage mounting rules.
In the kernel, sdcardfs wraps the contents of /data/media, which has
the label "media_rw_data_file".  As part of this wrapping, it should
change the label to be "sdcardfs", but we've seen evidence that this
isn't always happening.

To temporarily unblock dogfooding while we continue investigating,
relax rules to allow Zygote to mount from either "sdcardfs" or
"media_rw_data_file", which as described above, are equivalant.

Bug: 123533205
Test: manual
Change-Id: Id633337095c0a3b69d9b8652bcc3327810339cf3
2019-01-31 17:21:30 -07:00
Mathieu Chartier
669cef88a3 Rename runtime -> runtime_native property namespace
The convention for native properties is to use _native suffix.

Bug: 123524494
Bug: 120794191
Test: set a property and ensure it can be read in AndroidRuntime.cpp

Change-Id: I69feab9be78f24d812b8f953d3ec06a5d8d18f15
2019-01-29 10:20:36 -08:00
Mathieu Chartier
05ad04dd91 Add runtime property permissions for experiments
Bug: 120794191
Bug: 123524494
Test: set a property and ensure it can be read in AndroidRuntime.cpp

Change-Id: Ib37102f35e9987d3d9baff83c45571a5d632ad50
2019-01-28 12:39:23 -08:00
Martijn Coenen
1bbda7e662 Initial sepolicy for app_zygote.
The application zygote is a new sort of zygote process that is a
child of the regular zygote. Each application zygote is tied to the
application for which it's launched. Once it's started, it will
pre-load some of the code for that specific application, much like
the regular zygote does for framework code.

Once the application zygote is up and running, it can spawn
isolated service processes that run in the isolated_app domain. These
services can then benefit from already having the relevant
application code and data pre-loaded.

The policy is largely the same as the webview_zygote domain,
however there are a few crucial points where the policy is different.

1) The app_zygote runs under the UID of the application that spawned
   it.
2) During app_zygote launch, it will call a callback that is
   controlled by the application, that allows the application to
   pre-load code and data that it thinks is relevant.

Especially point 2 is imporant: it means that untrusted code can run
in the app_zygote context. This context is severely limited, and the
main concern is around the setgid/setuid capabilities. Those conerns
are mitigated by installing a seccomp filter that only allows
setgid/setuid to be called in a safe range.

Bug: 111434506
Test: app_zygote can start and fork children without denials.
Change-Id: I1cc49ee0042d41e5ac6eb81d8f8a10ba448d4832
2019-01-21 08:24:41 +00:00
Sudheer Shanka
2bac81dfab Allow zygote to create files at /mnt/user/.*
Bug: 111789719
Test: manual
Change-Id: I5a5c1da69fd5d55e3276bb7384a94b9831e3cccd
2018-12-12 21:05:38 -08:00
Nicolas Geoffray
6949a392b3 Allow zygote to JIT.
bug: 110870380
Test: device boots, artificially creating a rwx mapping in zygote works.

Change-Id: I81a32b616a68f186867af25528a0348d1ad73a50
2018-11-17 19:46:11 +00:00
Nick Kralevich
caf42d615d Transient SELinux domain for system_server JIT
Create a transient SELinux domain where system_server can perform
certain JIT setup. The idea is that system_server will start in the
system_server_startup domain, setup certain JIT pages, then perform a
one-way transition into the system_server domain. From that point,
further JITing operations are disallowed.

Bug: 62356545
Test: device boots, no permission errors
Change-Id: Ic55b2cc5aba420ebcf62736622e08881a4779004
2018-10-31 12:32:01 +00:00
Tri Vo
90cf5a7fb3 same_process_hal_file: access to individual coredomains
Remove blanket coredomain access to same_process_hal_file in favor of
granular access. This change takes into account audits from go/sedenials
(our internal dogfood program)

Bug: 37211678
Test: m selinux_policy
Change-Id: I5634fb65c72d13007e40c131a600585a05b8c4b5
2018-10-26 18:03:01 +00:00
Sudheer Shanka
684cdb6615 Allow zygote to search sdcardfs dirs.
Bug: 117440207
Bug: 111890351
Test: manual
Change-Id: Ie218dec3e4f0f5dbade6d1c4d28b259909664056
2018-10-08 16:21:03 -07:00
Howard Ro
98de322a03 Allow zygote to write to statsd and refactor
We plan on migrating MetricsLogger to write to statsd socket. So we need to
allow zygote, which writes to logd using MetricsLogger, to also be able
to statsd. We also re-locate some sepolicies to write to statsd socket
in their respective policy definitions.

Bug: 110537511
Test: no failure/violations observed
Change-Id: I21fd352a25ed946516f9a45ac3b5e9bf97b059bc
2018-10-08 13:48:28 -07:00
Sudheer Shanka
4fc64db5c1 Allow zygote to mount on sdcardfs dirs.
Bug: 111890351
Test: manual
Change-Id: I37d632c9877c6d6f929937d8e25098763807630c
2018-09-28 13:28:46 -07:00
Benjamin Gordon
342362ae3e sepolicy: grant dac_read_search to domains with dac_override
kernel commit 2a4c22426955d4fc04069811997b7390c0fb858e (fs: switch order
of CAP_DAC_OVERRIDE and CAP_DAC_READ_SEARCH checks) swapped the order of
dac_override and dac_read_search checks.  Domains that have dac_override
will now generate spurious denials for dac_read_search unless they also
have that permission.  Since dac_override is a strict superset of
dac_read_search, grant dac_read_search to all domains that already have
dac_override to get rid of the denials.

Bug: 114280985
Bug: crbug.com/877588
Test: Booted on a device running 4.14.
Change-Id: I5c1c136b775cceeb7f170e139e8d4279e73267a4
2018-09-19 15:54:37 -06:00
Nick Kralevich
6cf9160e82 add links to docs explaining motivations behind neverallow assertions.
Test: comments only. Policy compiles.
Change-Id: Ic51533d37fff6c553950a122f33a48e3c119c67c
2018-09-12 15:53:48 -07:00
Benjamin Gordon
7ed266c678 sepolicy: Fix references to self:capability
commit 9b2e0cbeea added a new
self:global_capability_class_set macro that covers both self:capability
and self:cap_userns.  Apply the new macro to various self:capability
references that have cropped up since then.

Bug: 112307595
Test: policy diff shows new rules are all cap_userns
Change-Id: I3eb38ef07532a8e693fd549dfdbc4a6df5329609
2018-08-21 15:55:23 +00:00
Jeff Vander Stoep
f45db06c2b Deprivilege haiku
Clatd and zygote
are all overprivileged
as is storaged

Test: Verify no "granted" messages from dogfooders. Build flash
aosp_taimen-userdebug. Verify no denials.
Change-Id: I735adcffed553962ad12072716a7200883930dcf
2018-06-04 11:07:08 -07:00
Jeff Vander Stoep
7a4af30b38 Start the process of locking down proc/net
Files in /proc/net leak information. This change is the first step in
determining which files apps may use, whitelisting benign access, and
otherwise removing access while providing safe alternative APIs.

To that end, this change:
* Introduces the proc_net_type attribute which will assigned to any
new SELinux types in /proc/net to avoid removing access to privileged
processes. These processes may be evaluated later, but are lower
priority than apps.
* Labels /proc/net/{tcp,tcp6,udp,udp6} as proc_net_vpn due to existing
use by VPN apps. This may be replaced by an alternative API.
* Audits all other proc/net access for apps.
* Audits proc/net access for other processes which are currently
granted broad read access to /proc/net but should not be including
storaged, zygote, clatd, logd, preopt2cachename and vold.

Bug: 9496886
Bug: 68016944
Test: Boot Taimen-userdebug. On both wifi and cellular: stream youtube
    navigate maps, send text message, make voice call, make video call.
    Verify no avc "granted" messages in the logs.
Test: A few VPN apps including "VPN Monster", "Turbo VPN", and
"Freighter". Verify no logspam with the current setup.
Test: atest CtsNativeNetTestCases
Test: atest netd_integration_test
Test: atest QtaguidPermissionTest
Test: atest FileSystemPermissionTest

Change-Id: I7e49f796a25cf68bc698c6c9206e24af3ae11457
Merged-In: I7e49f796a25cf68bc698c6c9206e24af3ae11457
(cherry picked from commit 087318957f)
2018-05-04 21:36:33 +00:00
Jaekyun Seok
224921d18a Whitelist vendor-init-settable bluetooth_prop and wifi_prop
Values of the following properties are set by SoC vendors on some
devices including Pixels.
- persist.bluetooth.a2dp_offload.cap
- persist.bluetooth.a2dp_offload.enable
- persist.vendor.bluetooth.a2dp_offload.enable
- ro.bt.bdaddr_path
- wlan.driver.status

So they should be whitelisted for compatibility.

Bug: 77633703
Test: succeeded building and tested with Pixels
Change-Id: Ib2b81bcc1fd70ddd571dc7fb2b923b576d62b7d5
2018-04-13 09:25:06 +09:00
Jeff Vander Stoep
7e5ec2bc3d Suppress spurious denial
Addresses:
avc: denied { sys_resource } scontext=u:r:zygote:s0
tcontext=u:r:zygote:s0 tclass=capability

Bug: 77905989
Test: build and flash taimen-userdebug
Change-Id: If2413c3005df02a70661464d695211acbcda4094
(cherry picked from commit 816e744d998cb327fbd20f3124b22398bea2b8e4)
2018-04-11 12:20:32 -07:00
Alan Stokes
06bac37f51 Installd doesn't need to create cgroup files.
cgroupfs doesn't allow files to be created, so this can't be needed.

Also remove redundant neverallow and dontaudit rules. These are now
more broadly handled by domain.te.

Bug: 74182216

Test: Denials remain silenced.

Change-Id: If7eb0e59f567695d987272a2fd36dbc251516e9f

(cherry picked from commit 8e8c109350)
2018-04-09 13:49:13 +01:00