Commit graph

397 commits

Author SHA1 Message Date
Mark Salyzyn
8bc025a5f7 Merge "access to /proc/slabinfo"
am: e0637cfc8e

Change-Id: Ie5f10c93d27607879db52177cd498eec0d61f782
2018-06-15 08:04:18 -07:00
Mark Salyzyn
d6eaed854d access to /proc/slabinfo
init, dumpstate and shell

Test: check avc for init is now gone
Bug: 7232205
Bug: 109821005
Change-Id: I299a0ba29bcc97a97047f12a5c48f6056f5e6de5
2018-06-14 10:18:45 -07:00
Andreas Huber
4d6a5e8700 Fingerprint data is now stored in one of two ways depending on the
shipping API version:

For devices shipped on O-MR1 nothing changes, data is stored
under /data/system/users/<user-id>/fpdata/...

Devices shipped from now on will instead store fingerprint data under
/data/vendor_de/<user-id>/fpdata.

Support for /data/vendor_de and /data/vendor_ce has been added to vold.

Bug: 36997597
Change-Id: Ibc7cc33b756f64abe68a749c0ada0ca4f6d92514
Merged-In: Ibc7cc33b756f64abe68a749c0ada0ca4f6d92514
Test: manually
(cherry picked from commit 6116daa71a)
2018-05-16 14:22:14 -07:00
Jeff Vander Stoep
1279a7ae85 resolve merge conflicts of bc34fa26ac to pi-dev-plus-aosp
Bug: None
Test: None
Change-Id: Ie9d2f35efd5bf39d0282ccc41fdd3f974d7c01bf
2018-05-04 19:03:03 -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
Tri Vo
bfe1e42143 Merge "SELinux type for vendor public libs." am: 59e9d2d8c9
am: 9d99ee2316

Change-Id: I50978971a2cf6221024d91edde0cb85b9415f7be
2018-05-03 13:11:21 -07:00
Tri Vo
29497b623e SELinux type for vendor public libs.
Vendor public libs are exposed to apps (not system), and their ABI
stability is guaranteed by vendor. Introducing new selinux type so that
we don't conflate concepts of same-process HAL and vendor public lib.
The former is exposed to all domains, while the latter should only be
acessible by apps.

Bug: 76413554
Test: build-only change, policy builds
Change-Id: I89dad351374f46c7fe2726991eb4c05064c37ed5
2018-05-02 14:51:05 -07:00
Paul Crowley
67861bcc03 Add metadata_file class for root of metadata folder. am: 42bd1638bf
am: b494ab07fb

Change-Id: I25139c13561468d585814daa2f79b35a390730ee
2018-04-24 10:41:23 -07:00
Paul Crowley
42bd1638bf Add metadata_file class for root of metadata folder.
Bug: 77335096
Test: booted device with metadata encryption and without
Change-Id: I5bc5d46deb4e91912725c4887fde0c3a41c9fc91
2018-04-23 14:14:49 -07:00
Jeff Vander Stoep
df6d77cd45 Protect dropbox service data with selinux am: 4d3ee1a5b6
am: 1874950d21

Change-Id: Id2e5359054ae6d1882b0c99011ee09d1b75fa604
2018-04-18 15:05:34 -07:00
Jeff Vander Stoep
4d3ee1a5b6 Protect dropbox service data with selinux
Create a new label for /data/system/dropbox, and neverallow direct
access to anything other than init and system_server.

While all apps may write to the dropbox service, only apps with
android.permission.READ_LOGS, a signature|privileged|development
permission, may read them. Grant access to priv_app, system_app,
and platform_app, and neverallow access to all untrusted_apps.

Bug: 31681871
Test: atest CtsStatsdHostTestCases
Test: atest DropBoxTest
Test: atest ErrorsTests
Change-Id: Ice302b74b13c4d66e07b069c1cdac55954d9f5df
2018-04-18 19:53:03 +00:00
Tri Vo
8c1a1b2472 Sepolicy for rw mount point for vendors.
Bug: 64905218
Test: device boots with /mnt/vendor present and selinux label
mnt_vendor_file applied correctly.
Change-Id: Ib34e2859948019d237cf2fe8f71845ef2533ae27
Merged-In: Ib34e2859948019d237cf2fe8f71845ef2533ae27
(cherry picked from commit 210a805b46)
2018-04-17 21:04:15 +00:00
Tri Vo
5fd38baf04 Merge "Sepolicy for rw mount point for vendors." into pi-dev
am: ae0b835c58

Change-Id: I72eb24a252571974b8732facf500a6f23eb9ccf1
2018-04-17 13:42:27 -07:00
TreeHugger Robot
ae0b835c58 Merge "Sepolicy for rw mount point for vendors." into pi-dev 2018-04-17 19:16:56 +00:00
Jeff Sharkey
b469c30069 Add exFAT support; unify behind "sdcard_type".
We're adding support for OEMs to ship exFAT, which behaves identical
to vfat.  Some rules have been manually enumerating labels related
to these "public" volumes, so unify them all behind "sdcard_type".

Test: atest
Bug: 67822822
Change-Id: I09157fd1fc666ec5d98082c6e2cefce7c8d3ae56
2018-04-16 12:49:10 -06:00
Tri Vo
210a805b46 Sepolicy for rw mount point for vendors.
Bug: 64905218
Test: device boots with /mnt/vendor present and selinux label
mnt_vendor_file applied correctly.
Change-Id: Ib34e2859948019d237cf2fe8f71845ef2533ae27
2018-04-16 11:07:40 -07:00
Jeff Sharkey
ea3997beab Merge "Add exFAT support; unify behind "sdcard_type"." am: ba89007178
am: ff0369ad4c

Change-Id: I3d323c85ff019824be74fa6887b0578f308e6251
2018-04-14 16:28:52 -07:00
Jeff Sharkey
000cafc701 Add exFAT support; unify behind "sdcard_type".
We're adding support for OEMs to ship exFAT, which behaves identical
to vfat.  Some rules have been manually enumerating labels related
to these "public" volumes, so unify them all behind "sdcard_type".

Test: atest
Bug: 67822822
Change-Id: I09157fd1fc666ec5d98082c6e2cefce7c8d3ae56
2018-04-13 14:08:10 -06:00
Jeff Vander Stoep
e8db0b37ad Merge "Rename qtaguid_proc to conform to name conventions" am: 38a84cf8da
am: d093691cda

Change-Id: Ie6ffba47ea2164260d60115a738c57f0e47f04be
2018-04-03 21:53:11 -07:00
Jeff Vander Stoep
bdf2a9c417 Rename qtaguid_proc to conform to name conventions
Test: build
Bug: 68774956
Change-Id: I0f9fd87eb41e67e14f35e49eba13e3d1de745250
2018-04-03 14:47:38 -07:00
Tri Vo
f350c884e0 silence innocuous denials to /proc and /sys am: 422fb98e2e
am: fc5fa22fa0

Change-Id: I2ebe936d736a8dfcd3abf969c4116bad52b4ae3c
2018-03-21 20:25:24 +00:00
Tri Vo
422fb98e2e silence innocuous denials to /proc and /sys
Bug: 74182216
Test: build bullhead, sailfish sepolicy
Change-Id: I6d0635a49c025870c9ecb46147e6c9a1c407fe16
2018-03-21 10:48:22 -07:00
Tri Vo
c8f2d0d476 Merge "Revert "silence innocuous denials to /proc and /sys"" am: 341d34b582
am: fc33d6eff1

Change-Id: I487eca7219014ebc257167e5af301f80a082d317
2018-03-21 17:12:21 +00:00
Tri Vo
cee3f687eb Revert "silence innocuous denials to /proc and /sys"
This reverts commit 09b1d962ef.

Reason for revert: bullhead broken

Change-Id: Ib4562f944cdc2618cc3ed3beb4f612f0ef8b3223
2018-03-21 16:37:23 +00:00
Tri Vo
59a1b52538 Merge changes from topic "dontaudit_proc_sys" am: 795eae3a41
am: 36f82363e4

Change-Id: I0ab2bc44fb7f788a188b00a5baa8dafb0f1da027
2018-03-20 23:18:48 +00:00
Tri Vo
f170dfb789 silence innocuous denials to /proc and /sys
Bug: 74182216
Test: build policy
Change-Id: Idf90c1a96943266d52508ce72b8554d8b5c594c9
(cherry picked from commit 09b1d962ef)
2018-03-20 14:22:16 -07:00
Tri Vo
62e6850a2b proc_type attribute for files under /proc.
With this attribute it will be easier to reference /proc files.

Bug: 74182216
Test: policy builds
Change-Id: I5b7da508d821e45f122832261a742a201e8fdf2c
(cherry picked from commit 41bf08e592)
2018-03-20 14:21:36 -07:00
Tri Vo
09b1d962ef silence innocuous denials to /proc and /sys
Bug: 74182216
Test: build policy
Change-Id: Idf90c1a96943266d52508ce72b8554d8b5c594c9
2018-03-19 14:58:25 -07:00
Tri Vo
41bf08e592 proc_type attribute for files under /proc.
With this attribute it will be easier to reference /proc files.

Bug: 74182216
Test: policy builds
Change-Id: I5b7da508d821e45f122832261a742a201e8fdf2c
2018-03-19 14:58:25 -07:00
Robert Sesek
869562e9e3 Remove rules for starting the webview_zygote as a child of init.
The webview_zygote is now launched as a child-zygote process from the
main zygote process.

Bug: 63749735
Test: m
Test: Launch "Third-party licenses" activity from Settings, and it
      renders correctly via the WebView.
Merged-In: I9c948b58a969d35d5a5add4b6ab62b8f990645d1
Change-Id: I153476642cf14883b0dfea0d9f5b3b5e30ac1c08
2018-02-23 10:55:22 -05:00
TreeHugger Robot
d580a23ec1 Merge "Remove rules for starting the webview_zygote as a child of init." 2018-02-23 15:54:32 +00:00
Primiano Tucci
4120c8c94d perfetto: Make producer socket MLS-aware am: 5ef6669b04 am: 2337f2950c
am: 8bf6ccb78a

Change-Id: I40e25bbdec238c250308f8a09571e4c4a1bea363
2018-02-21 20:17:09 +00:00
Primiano Tucci
5ef6669b04 perfetto: Make producer socket MLS-aware
The previous selinux rules obtained via audit2allow didn't really
work with the case of apps connecting to the producer socket,
despite all the allow rules being correctly in place.
This was failing our CTS tests.

The reason for the failure (see denials pasted below) is due to
Multi Level Security (for multi-user), which was still preventing
apps form a different level to connect to the traced producer
socket and write to the shmem buffers they get passed back.
This CL tags the objects being accessed as mlstrusted.
CTS tests pass with this CL.

Denials:
avc: denied { write } for pid=8545 comm="traced_probes" name="traced_producer" dev="tmpfs" ino=23629 scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:object_r:traced_producer_socket:s0 tclass=sock_file permissive=1
avc: denied { write } for pid=8545 comm="traced_probes" name="traced_producer" dev="tmpfs" ino=23629 scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:object_r:traced_producer_socket:s0 tclass=sock_file permissive=1
avc: denied { connectto } for pid=8545 comm="traced_probes" path="/dev/socket/traced_producer" scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:r:traced:s0 tclass=unix_stream_socket permissive=1
avc: denied { connectto } for pid=8545 comm="traced_probes" path="/dev/socket/traced_producer" scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:r:traced:s0 tclass=unix_stream_socket permissive=1
avc: denied { write } for pid=8545 comm="traced_probes" path=2F6D656D66643A706572666574746F5F73686D656D202864656C6574656429 dev="tmpfs" ino=104483 scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:object_r:traced_tmpfs:s0 tclass=file permissive=1

Change-Id: I1598bc0b07bf39b8d0420b66caf06a4ca884f383
Bug: 73340039
Test: CtsPerfettoTestCases
2018-02-21 14:37:58 +00:00
Robert Sesek
ca4c4e57b2 Remove rules for starting the webview_zygote as a child of init.
The webview_zygote is now launched as a child-zygote process from the
main zygote process.

Bug: 63749735
Test: m
Test: Launch "Third-party licenses" activity from Settings, and it
      renders correctly via the WebView.
Change-Id: I9c948b58a969d35d5a5add4b6ab62b8f990645d1
2018-02-16 16:26:42 -05:00
Jeff Vander Stoep
dc54573b81 Merge "label /data/vendor{_ce,_de}" am: 3721b0513d am: 7fd715ea82
am: 037f20b9c0

Change-Id: Ie7bcebebf47c7e0ea879ffb84c6dc3ce2e5b7259
2018-02-09 06:09:45 +00:00
Jeff Vander Stoep
d25ccabd24 label /data/vendor{_ce,_de}
Restrictions introduced in vendor init mean that new devices
may not no longer exempt vendor init from writing to system_data_file.
This means we must introduce a new label for /data/vendor which
vendor_init may write to.

Bug: 73087047
Test: build and boot Taimen and Marlin. Complete SUW, enroll fingerprint
    No new denials.

Change-Id: I65f904bb28952d4776aab947515947e14befbe34
2018-02-08 17:21:25 +00:00
Carmen Jackson
e3817434ae Merge changes from topic "user-build-traceur" am: 0fe4586bb1 am: 5f15d4edc7
am: a94aaeb0ff

Change-Id: I7c3006caae89234c1f9e77e93f870800f3552bac
2018-02-05 20:53:04 +00:00
Carmen Jackson
2c8ca45d2d Use a whitelisting strategy for tracefs.
This changes tracefs files to be default-enabled in debug mode, but
default-disabled with specific files enabled in user mode.

Bug: 64762598
Test: Successfully took traces in user mode.

Change-Id: I572ea22253e0c1e42065fbd1d2fd7845de06fceb
2018-02-05 10:03:06 -08:00
Paul Crowley
60676fd89d Merge "Allow vendor_init and e2fs to enable metadata encryption" am: 5d422a305d am: 55b3a9d21e
am: 72750a917f

Change-Id: I3a830a8622c14579b41e4182fcba8db46020e746
2018-02-02 16:56:27 +00:00
Paul Crowley
d9a4e06ec5 Allow vendor_init and e2fs to enable metadata encryption
Bug: 63927601
Test: Enable metadata encryption in fstab on Taimen, check boot success.

Change-Id: Iddbcd05501d360d2adc4edf8ea7ed89816642d26
2018-02-01 13:25:34 -08:00
Jeff Vander Stoep
ccf965e9ca Test that /data is properly labeled
Data outside of /data/vendor should have the core_data_file_type.
Exempt data_between_core_and_vendor for some types.

Ensure core_data_file_type and coredomain_socket do not get expanded
to their underlying types.

Test: build sepolicy for all targets in master (this is a build time
    test)
Bug: 34980020
Change-Id: I59387a87875f4603a001fb03f22fa31cae84bf5a
(cherry picked from commit bdd454792d)
2018-01-30 10:11:38 -08:00
Jeffrey Vander Stoep
77a2d71fc2 Merge "Test that /data is properly labeled" 2018-01-25 00:57:23 +00:00
TreeHugger Robot
8cd8c42223 Merge "Fingerprint data is now stored in one of two ways depending on the" 2018-01-24 20:24:22 +00:00
Marissa Wall
dad1a1ee98 Merge "sepolicy: restrict access to uid_cpupower files" am: 24e8eff35d am: 6ad9b56176
am: 67d7275265

Change-Id: I2d5fe930c4cdca93f94a7b5cf1dc6ca609de05ce
2018-01-24 20:11:43 +00:00
Marissa Wall
dfe063c37d sepolicy: restrict access to uid_cpupower files
Do not let apps read /proc/uid_cpupower/time_in_state,
/proc/uid_cpupower/concurrent_active_time,
/proc/uid_cpupower/concurrent_policy_time.

b/71718257

Test: Check that they can't be read from the shell
    without root permissions and system_server was able
    to read them

Change-Id: I812694adfbb4630f7b56aa7096dc2e6dfb148b15
2018-01-24 08:39:09 -08:00
Jeff Vander Stoep
bdd454792d Test that /data is properly labeled
Data outside of /data/vendor should have the core_data_file_type.
Exempt data_between_core_and_vendor for some types.

Ensure core_data_file_type and coredomain_socket do not get expanded
to their underlying types.

Test: build sepolicy for all targets in master (this is a build time
    test)
Bug: 34980020
Change-Id: I59387a87875f4603a001fb03f22fa31cae84bf5a
2018-01-24 08:15:49 -08:00
Joel Galenson
ac3c29d8cb Fix init error trying to access file. am: cf391269ac am: ff8bf596a4
am: e032393e9b

Change-Id: I7e0cb28c9e5c16c9fb1937698daedfce2c512bf8
2018-01-24 05:27:45 +00:00
Joel Galenson
cf391269ac Fix init error trying to access file.
Init tries to write /proc/sys/vm/min_free_order_shift but fails due to
a SELinux denial.  This gives the file a new label and gives init the
ability to write it.

Test: Build and booted Sailfish (a couple of days ago).
Change-Id: Ic93862b85c468afccff2019d84b927af9ed2a84d
2018-01-23 17:32:16 -08:00
Andreas Huber
6116daa71a Fingerprint data is now stored in one of two ways depending on the
shipping API version:

For devices shipped before Android P nothing changes, data is stored
under /data/system/users/<user-id>/fpdata/...

Devices shipped from now on will instead store fingerprint data under
/data/vendor_de/<user-id>/fpdata.

Support for /data/vendor_de and /data/vendor_ce has been added to vold.

Bug: 36997597
Change-Id: Ibc7cc33b756f64abe68a749c0ada0ca4f6d92514
Test: manually
2018-01-23 14:30:38 -08:00
Yi Jin
de962429dc Selinux permissions for incidentd project am: bc24ba7283 am: 6c112fb3b2
am: cf06833c4b

Change-Id: I5835260d115aab09c5107130240e2c4988b192b7
2018-01-23 21:11:33 +00:00
Tri Vo
32d201709a Merge "dumpstate: remove access to 'proc' and 'sysfs' types." am: 0a2f862715 am: 1452e0a235
am: cf8a45eaf4

Change-Id: Ia07f01de94a598994b2e390c7c2316f1a9290aca
2018-01-23 21:11:18 +00:00
Yi Jin
bc24ba7283 Selinux permissions for incidentd project
Bug: 64222712
Test: manual
Change-Id: Ica77ae3c9e535eddac9fccf11710b0bcb3254ab3
2018-01-23 19:08:49 +00:00
Tri Vo
218d87c01c dumpstate: remove access to 'proc' and 'sysfs' types.
And grant appropriate permissions to more granular types.

Bug: 29319732
Bug: 65643247
Test: adb bugreport; no new denials to /proc or /sys files.

Change-Id: Ied99546164e79bfa6148822858c165177d3720a5
2018-01-23 03:24:37 +00:00
Max Bires
acc900f92f Adding write permissions to traceur am: 35c363897d am: ca824eb278
am: 311c3e1df1

Change-Id: Id3e056483b4726a2765869d0f4f46c093c3937ef
2018-01-23 00:29:28 +00:00
Max Bires
35c363897d Adding write permissions to traceur
Fixing denials that stopped traceur from being able to write to
debugfs_tracing. Also cleaning up general find denials for services that
traceur doesn't have permission to access.

Additionally, labeling /data/local/trace as a trace_data_file in order
to give traceur a UX friendly area to write its traces to now that it
will no longer be a shell user. It will be write/readable by traceur,
and deletable/readable by shell.

Test: Traceur functionality is not being blocked by selinux policy
Bug: 68126425
Change-Id: I201c82975a31094102e90bc81454d3c2a48fae36
2018-01-22 21:06:36 +00:00
Tri Vo
1ec780732d Remove proc and sysfs access from system_app and platform_app. am: 06d7dca4a1 am: 32205bc52a
am: 0e1770d76b

Change-Id: I30e7650a7468a76075f227d2c3edca08ae046097
2018-01-20 01:46:10 +00:00
Tri Vo
06d7dca4a1 Remove proc and sysfs access from system_app and platform_app.
Bug: 65643247
Test: manual
Test: browse internet
Test: take a picture
Change-Id: I9faff44b7a025c7422404d777113e40842ea26dd
2018-01-20 01:05:21 +00:00
Jeff Vander Stoep
89ea84aabb relabel files in /proc/net/xt_qtaguid/ am: 43303c8b89 am: 02dbf4e0a1
am: 2beb891520

Change-Id: Idfe7ef49572476508ef52391f221029d662ffad8
2018-01-11 20:43:04 +00:00
Jeff Vander Stoep
43303c8b89 relabel files in /proc/net/xt_qtaguid/
/proc/net/xt_qtaguid is used by apps to track their network data
use. Limit access to just zygote spawned processes - apps and
system_server, omitting access to isolated_app which is not allowed
to create network sockets.
As Android moves to eBPF for app's network data stats, access to
/proc/net/xt_qtaguid will be removed entirely. Segmenting access off
is the first step.
Bug: 68774956

This change also helps further segment and whitelist access to
files in /proc/net and is a step in the lockdown of /proc/net.
Bug: 9496886

Test: boot Taimen. Walk through setup-wizard. Make phone call and
    video call. Browse web. Watch youtube. Navigate in maps.
Test: cts-tradefed run cts -m CtsAppSecurityHostTestCases -t \
    android.appsecurity.cts.AppSecurityTests
Test: cts-tradefed run cts -m CtsNativeNetTestCases
Test: cts-tradefed run cts -m CtsIncidentHostTestCases -t \
    com.android.server.cts.NetstatsIncidentTest
Test: cts-tradefed run cts -m CtsOsTestCases -t \
    android.os.cts.StrictModeTest
Test: cts-tradefed run cts -m CtsNetTestCases -t \
    android.net.cts.TrafficStatsTest
Test: cts-tradefed run cts -m CtsUsageStatsTestCases -t \
    android.app.usage.cts.NetworkUsageStatsTest
Test: vts-tradefed run vts -m VtsQtaguidTest
Change-Id: Idddd318c56b84564142d37b11dcc225a2f2800ea
2018-01-11 16:46:36 +00:00
Primiano Tucci
214f47963b Perfetto SELinux policies am: c80f9e037b am: 3ed0362a30
am: 7c5113d79f

Change-Id: I70969b44d0fe8cc732848453bcbb8657df7fd08c
2018-01-10 00:43:53 +00:00
Primiano Tucci
c80f9e037b Perfetto SELinux policies
Perfetto is a performance instrumentation and logging framework,
living in AOSP's /external/pefetto.
Perfetto introduces in the system one binary and two daemons
(the binary can specialize in either depending on the cmdline).

1) traced: unprivileged daemon. This is architecturally similar to logd.
   It exposes two UNIX sockets:
   - /dev/socket/traced_producer : world-accessible, allows to stream
     tracing data. A tmpfs file descriptor is sent via SCM_RIGHTS
     from traced to each client process, which needs to be able to
     mmap it R/W (but not X)
   - /dev/socket/traced_consumer : privilege-accessible (only from:
     shell, statsd). It allows to configure tracing and read the trace
     buffer.
2) traced_probes: privileged daemon. This needs to:
   - access tracingfs (/d/tracing) to turn tracing on and off.
   - exec atrace
   - connect to traced_producer to stream data to traced.

init.rc file:
https://android-review.googlesource.com/c/platform/external/perfetto/+/575382/14/perfetto.rc

Bug: 70942310
Change-Id: Ia3b5fdacbd5a8e6e23b82f1d6fabfa07e4abc405
2018-01-10 00:18:46 +00:00
Luis Hector Chavez
9c72ef8904 Merge "Revert "Allow callers of uevent_kernel_*() access to /proc/sys/kernel/overflowuid"" am: 3ec0dbf7d1 am: df624b3479
am: 45b0aa3308

Change-Id: I9c08801a5fdf232f2e70d2d97e22e7d2e90dcbbb
2018-01-09 20:21:47 +00:00
Luis Hector Chavez
7ae939e84b Revert "Allow callers of uevent_kernel_*() access to /proc/sys/kernel/overflowuid"
This reverts commit 640e595a68. The
corresponding code in libcutils was removed, so this is now unneeded.

Bug: 71632076
Test: aosp_sailfish still works

Change-Id: I615bab83e9a83bc14439b8ab90c00d3156b0a7c4
2018-01-08 13:09:34 -08:00
Chenbo Feng
7921ff073b sepolicy: Allow mount cgroupv2 and bpf fs am: 254ad0da3a am: 956e099ec6
am: 13c3ed2836

Change-Id: I5a753a23f0b03d7d8db14337efd6ea970a90a38b
2018-01-02 22:12:04 +00:00
Chenbo Feng
254ad0da3a sepolicy: Allow mount cgroupv2 and bpf fs
Some necessary sepolicy rule changes for init process to create directory,
mount cgroupv2 module and mount bpf filesystem. Also allow netd to create
and pin bpf object as files and read it back from file under the
directory where bpf filesystem is mounted.

Test: bpf maps show up under /sys/fs/bpf/
Change-Id: I579d04f60d7e20bd800d970cd28cd39fda9d20a0
2018-01-02 11:52:33 -08:00
Ricky Wai
7494cc133c Add Network Watchlist data file selinux policy(Used in ConfigUpdater) am: ff3b957e63 am: 56a9edb19e
am: a70a3ca0ba

Change-Id: I208790e37ba208f72b02a5caf595d84b34dd8cb2
2018-01-02 18:29:22 +00:00
Ricky Wai
ff3b957e63 Add Network Watchlist data file selinux policy(Used in ConfigUpdater)
Bug: 63908748
Test: Able to boot
Change-Id: I14d8856d7aac7be9d1f26ecf5bfff69ea5ee9607
2018-01-02 18:16:46 +00:00
Jeffrey Vander Stoep
678082147d Revert "Audit app access to /proc/net/*"
This reverts commit 84f9685972.

Fixes: 70874565
Reason for revert: massive logspam during phone calls.

Change-Id: If00e46535f71209eea999e4d5d499bf40a5f16fd
2017-12-21 20:05:26 -08:00
xshu
96b44bec14 Wifi hal - Firmware dump permissions am: 6ad3c891bc am: 40868b952e
am: 5a90141fbd

Change-Id: I62223088adf7681ba868822efe43264c8fc4c987
2017-12-19 01:04:51 +00:00
xshu
6ad3c891bc Wifi hal - Firmware dump permissions
we are aiming to improve logging performance by having wifi hal
directly write to the flash.

Wifi hal need to be able to create, write, and delete files in
a directory. This will be restricted to userdebug and eng builds only.

Bug: 70170285
Test: compile, run on device
Change-Id: Id0cd317411f4c393d7529aa31b501046d7350edb
2017-12-18 13:11:02 -08:00
TreeHugger Robot
58bf871783 Merge "Audit app access to /proc/net/*" 2017-12-18 15:15:19 +00:00
Jeff Vander Stoep
84f9685972 Audit app access to /proc/net/*
Many processes including third party apps are expected to
access /proc/net/xt_qtaguid/stats. Give this file a new label
to avoid spamming the logs and temporarily grant read access to
all processes.

Read-only permission is adequate for all processes based on unix
permissions.
sailfish:/ # ls -laZ /proc/net/xt_qtaguid/stats
-r--r--r--  1 root net_bw_stats u:object_r:proc_net_xt_qtaguid_stats:s0 stats

Bug: 9496886
Bug: 68016944
Bug: 70722355
Test: Build/flash Sailfish. Browse in Chrome and watch videos in youtube.
    No "denied" or "granted" selinux messages observed in the logs.

Change-Id: I29f1ee806c8149988b9b93a950790d14754927ef
2017-12-15 16:34:39 -08:00
Marissa Wall
15ba57cce6 Merge "Restrict access to uid_concurrent_*_time" am: 40ed4283e4 am: 5b17322a87
am: 3337c82e7c

Change-Id: Id7dba03c422e4f9a2d094c7b26a773ababe2ab47
2017-12-13 20:27:09 +00:00
Marissa Wall
80ee23f74a Restrict access to uid_concurrent_*_time
Do not let apps read uid_concurrent_active_time and
uid_concurrent_policy_time.

b/68399339

Test: Check that they can't be read from the shell
    without root permissions and system_server was able
    to read them

Change-Id: I6f09ef608607cb9f4084ba403a1e7254b8c49a06
2017-12-12 19:19:04 +00:00
Andreas Gampe
89e02ed37b Merge "Sepolicy: Label kernel notes" am: 1d7fcdd59a am: aee0b123b7
am: 5059b423aa

Change-Id: I4665e89aba12c2a357317f2325ed60c9bfa89773
2017-12-08 00:22:26 +00:00
Andreas Gampe
9213fe0217 Sepolicy: Label kernel notes
Label /sys/kernel/notes.

Bug: 70275668
Test: m
Change-Id: Ieb666425d2db13f85225fb902fe06b0bf2335bef
2017-12-06 13:55:06 -08:00
Tri Vo
3c0a52076f Label /proc/sys/kernel/pid_max as proc_pid_max. am: 4081fd3993 am: ab35e4343b
am: a7351f93f7

Change-Id: Ifee5631ffbb9842f01683612da012286efcfaf5a
2017-11-28 19:19:06 +00:00
Tri Vo
4081fd3993 Label /proc/sys/kernel/pid_max as proc_pid_max.
And give shell domain read access to /proc/sys/kernel/pic_max.

Bug: 69569397
Test: adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
--gtest_filter=pthread.pthread_mutex_owner_tid_limit
Change-Id: Ib56c18ed553ad2c2113e6913788a4c00965483cc
2017-11-28 08:42:46 -08:00
Tri Vo
a087581232 Merge "system_server: access to /proc/sys/fs/pipe-max-size" am: 25576730c9 am: 1bd4443aa6
am: 00057abcfc

Change-Id: I6d6b75701e35b35501935162670f906f9c757d4b
2017-11-17 17:25:23 +00:00
Tri Vo
e7f4934d06 system_server: access to /proc/sys/fs/pipe-max-size
Label /proc/sys/fs/pipe-max-size with new type proc_pipe_conf and give
system_server access to it.

Addresses this denial:
avc: denied { read } for name="pipe-max-size" dev="proc" ino=93817
scontext=u:r:system_server:s0 tcontext=u:object_r:proc:s0 tclass=file
permissive=0

Bug: 69175449
Bug: 69324398
Test: sailfish boots
Test: adb bugreport
Test: craft an unresponsive app, trigger ANR, make sure traces are dumped
into /data/anr
Above denial from system_server not observed, no denials to proc_pipe_conf
observed.
Change-Id: I7c71f05820a4945ba982e29f76e9d9f4458b2b59
2017-11-16 12:30:53 -08:00
Tianjie Xu
0de7ffc5a7 Merge "Allow update_engine to access /data/misc/update_engine_log" am: 07ff610768 am: 39ec2bb6e3
am: 565a93fc6c

Change-Id: I7bcf5b4c91b949b7621499605bb049053dc9baa6
2017-11-10 22:18:26 +00:00
Tri Vo
2734f0d25b Merge changes from topic "cki_proc_init" am: aa93dad669 am: cec8b2cd1b
am: cd1bfb8480

Change-Id: Ib39d79bacd1827d4c549781d4d23d7404c183c84
2017-11-10 00:11:25 +00:00
Hakan Kvist
6fe014f8cb Allow update_engine to access /data/misc/update_engine_log
Add label update_engine_log_data_file for log files created by
update engine in directory /data/misc/update_engine_log.

Bug: 65568605
Test: manual
Change-Id: I379db82a0ea540e41cb3b8e03f93d9ce64fac7c9
2017-11-09 14:21:49 -08:00
Tri Vo
84e181bcd7 init: label /proc dependencies and remove access to proc
New types and files labeled with them:
1. proc_abi:
  /proc/sys/abi/swp

2. proc_dirty:
  /proc/sys/vm/dirty_background_ratio
  /proc/sys/vm/dirty_expire_centisecs

3. proc_diskstats:
  /proc/diskstats

4. proc_extra_free_kbytes:
  /proc/sys/vm/extra_free_kbytes

5. proc_hostname:
  /proc/sys/kernel/domainname
  /proc/sys/kernel/hostname

6. proc_hung_task:
  /proc/sys/kernel/hung_task_timeout_secs

7. proc_max_map_count:
  /proc/sys/vm/max_map_count

8. proc_panic:
  /proc/sys/kernel/panic_on_oops

9. proc_sched:
  /proc/sys/kernel/sched_child_runs_first
  /proc/sys/kernel/sched_latency_ns
  /proc/sys/kernel/sched_rt_period_us
  /proc/sys/kernel/sched_rt_runtime_us
  /proc/sys/kernel/sched_tunable_scaling
  /proc/sys/kernel/sched_wakeup_granularity_ns

10. proc_uptime:
  /proc/uptime

Files labeled with already existing types:
1. proc_perf:
  /proc/sys/kernel/perf_event_paranoid

2. proc_sysrq:
  /proc/sys/kernel/sysrq

3. usermodehelper:
  /proc/sys/kernel/core_pipe_limit

Changes to init domain:
1. Removed access to files with 'proc' label.
2. Added access to newly introduced types + proc_kmsg.

Bug: 68949041
Test: walleye boots without denials from u:r:init:s0.
Test: system/core/init/grab-bootchart.sh does not trigger denials from
u:r:init:s0
Change-Id: If1715c3821e277679c320956df33dd273e750ea2
2017-11-08 14:46:09 -08:00
Luis Hector Chavez
ba872bb288 Allow callers of uevent_kernel_*() access to /proc/sys/kernel/overflowuid am: 640e595a68 am: fe5554828e
am: 4953e49c69

Change-Id: I7f0f8d58f0cd8bb79e9d63b8f272db9f0ec2f4f5
2017-11-08 02:18:58 +00:00
Luis Hector Chavez
640e595a68 Allow callers of uevent_kernel_*() access to /proc/sys/kernel/overflowuid
Bug: 62378620
Test: Android in Chrome OS can call uevent_kernel_recv() and not fail
      with EIO.
Test: bullhead networking still works

Change-Id: I4dd5d2148ee1704c4fa23d7fd82d1ade19b58cbd
2017-11-08 01:39:28 +00:00
Jeff Vander Stoep
cae7ef0f46 Annotate data types owned by the core platform am: dd7e36c0f2 am: ed9a9cd4db
am: da866142ae

Change-Id: Id3af88a84c1d43e83f68c9df03a69d508dcdc550
2017-11-06 18:31:05 +00:00
Jeff Vander Stoep
dd7e36c0f2 Annotate data types owned by the core platform
This will be used to enforce data separation between platform and
vendor.

Test: build
Bug: 34980020
Change-Id: Ia312f00068d3982c7aae7e35bd0c96a6eb9ea3be
2017-11-06 16:38:05 +00:00
Tom Cherry
6ccc0f90f3 Merge "Add label for /proc/sys/vm/page-cluster" am: 2286b39712 am: 74e051e898
am: 3f96a8dc46

Change-Id: I9932164a205bb71ee49dcb75db2f53ae9ff39536
2017-10-25 16:23:25 +00:00
Tri Vo
c0be97f141 Merge "/proc, /sys access from uncrypt, update_engine, postinstall_dexopt" am: 71b19aa601 am: d67ded6873
am: b2cacef8af

Change-Id: I8dbe7395ac2fe400953cde06e3dbf042c207cb6e
2017-10-24 20:55:12 +00:00
Tom Cherry
8bdb1dab56 Add label for /proc/sys/vm/page-cluster
Test: boot sailfish with no audit when writing to page-cluster
Change-Id: I2bfebdf9342594d66d95daaec92d71195c93ffc8
2017-10-24 13:53:51 -07:00
Tri Vo
04fb82f232 /proc, /sys access from uncrypt, update_engine, postinstall_dexopt
New types:
1. proc_random
2. sysfs_dt_firmware_android

Labeled:
1. /proc/sys/kernel/random as proc_random.
2. /sys/firmware/devicetree/base/firmware/android/{compatible, fstab,
vbmeta} as sysfs_dt_firmware_android.

Changed access:
1. uncrypt, update_engine, postinstall_dexopt have access to generic proc
and sysfs labels removed.
2. appropriate permissions were added to uncrypt, update_engine,
update_engine_common, postinstall_dexopt.

Bug: 67416435
Bug: 67416336
Test: fake ota go/manual-ab-ota runs without denials
Test: adb sideload runs without denials to new types
Change-Id: Id31310ceb151a18652fcbb58037a0b90c1f6505a
2017-10-24 16:40:45 +00:00
Jeffrey Vander Stoep
be5a486306 Merge "hal_audio: remove access to audiohal_data_file" am: 1b223839e0 am: 0787c2ea35
am: 61ad248999

Change-Id: I98b56852873b9dca53e9780405e8d51abd9172b5
2017-10-23 23:13:19 +00:00
Jeff Vander Stoep
b1a921e24e hal_audio: remove access to audiohal_data_file
This is no longer used and violates Treble data separation.

Bug: 68057930
Test: verify on Sailfish that /data/misc/audiohal doesn't exist
    This dir appears to be Qualcomm specific and should not have
    been defined in core policy.

Change-Id: I55fba7564203a7f8a1d8612abd36ec1f89dc869d
2017-10-21 03:29:36 +00:00
Tri Vo
8dabc2ce74 Restrict netd fwk policy.
Remove netd access to sysfs_type attribute.

These were moved from vendor to fwk policy:
1. sysfs_net type declaration
2. labeling of /sys/devices/virtual/net with sysfs_net
3. netd access to sysfs_net

Bug: 65643247
Test: can browse internet without netd denials
Test: netd_unit_test, netd_integration_test without netd denials
Merged-In: Ic1b95a098f438c4c6bc969bee801bf7dd1a13f6e
Change-Id: Ic1b95a098f438c4c6bc969bee801bf7dd1a13f6e
(cherry picked from commit e62a56b717)
2017-10-20 22:07:01 +00:00
Tri Vo
e62a56b717 Restrict netd fwk policy.
Remove netd access to sysfs_type attribute.

These were moved from vendor to fwk policy:
1. sysfs_net type declaration
2. labeling of /sys/devices/virtual/net with sysfs_net
3. netd access to sysfs_net

Bug: 65643247
Test: can browse internet without netd denials
Test: netd_unit_test, netd_integration_test without netd denials
Change-Id: Ic1b95a098f438c4c6bc969bee801bf7dd1a13f6e
2017-10-17 14:46:47 -07:00
Tri Vo
1c166c6d83 Merge "Label system_server's dependencies in sysfs." am: 975efbe5d2 am: fb49dc5211 am: 8269fec076
am: 24f994bba7

Change-Id: I4656b8b13db086950040055f36c444bb01197de0
2017-10-15 05:49:31 +00:00
Tri Vo
1960215c49 Label system_server's dependencies in sysfs.
New types:
sysfs_android_usb
sysfs_ipv4
sysfs_power
sysfs_rtc
sysfs_switch
sysfs_wakeup_reasons

Labeled:
/sys/class/android_usb, /sys/devices/virtual/android_usb ->sysfs_android_usb
/sys/class/rtc -> sysfs_rtc
/sys/class/switch, /sys/devices/virtual/switch -> sysfs_switch
/sys/power/state, /sys/power/wakeup_count -> sysfs_power
/sys/kernel/ipv4 -> sysfs_ipv4
/sys/kernel/wakeup_reasons -> sysfs_wakeup_reasons

Removed access to sysfs and sysfs_type from system_server and added
appropriate access to new types.

Bug: 65643247
Test: sailfish boots without violation from system_server or to new labels.
Change-Id: I27250fd537d76c8226defa138d84fe2a4ce2d5d5
2017-10-12 14:51:20 -07:00
Tao Bao
488c4a6c68 Create sysfs_dm label. am: 5b4bea438a am: 28dca27ba2 am: a35083e015
am: 29c909ff34

Change-Id: Iba58bad1f82fbbb2221fbdb007a5c10d83925dfa
2017-10-11 17:13:43 +00:00
Tao Bao
5b4bea438a Create sysfs_dm label.
Prior to this CL, /sys/devices/virtual/block/dm-X was using the generic
sysfs label. This CL creates sysfs_dm label and grants the following
accesses:
 - update_verifier to read sysfs_dm dir and file at
   /sys/devices/virtual/block/dm-X.
 - vold to write sysfs_dm.

Bug: 63440407
Test: update_verifier successfully triggers blocks verification and
      marks a sucessful boot;
Test: No sysfs_dm related denials on sailfish.
Change-Id: I6349412707800f1bd3a2fb94d4fe505558400c95
2017-10-10 14:42:24 -07:00
Dan Cashman
eceee125d4 Merge "Remove reboot_data_file." am: f3f194c09a am: 9cac761df7 am: 17491f6b9c
am: 33edd89696

Change-Id: Iba4aba8833f3543d8e28c5d469667bbeb09b860e
2017-10-09 23:54:33 +00:00
Dan Cashman
76d0e4180a Remove reboot_data_file.
Bug: 64687998
Test: Builds.
Change-Id: I7a5b65d34382b8b76e55c523811a0f17dd9c1051
2017-10-09 14:25:10 -07:00
Tri Vo
cc5464fd7d Merge "Extend access to proc/asound/*" am: a045c854c5 am: bd435bf8e9 am: 32f7d8f89e
am: 16ef7ca87c

Change-Id: I1562fed1d63a80682684ff0dfaf6a3773eaf60f0
2017-10-06 20:10:25 +00:00
Tri Vo
464f59ae10 Extend access to proc/asound/*
Renamed this type:
proc_asound_cards -> proc_asound

Labeled /proc/asound/devices as proc_asound.

We now use proc_asound type to label files under /proc/asound which we
want to expose to system components.

Bug: 66988327
Test: Pixel 2 boots, can play sound with or without headphones, and
selinux denials to proc_asound are not seen.

Change-Id: I453d9bfdd70eb80931ec9e80f17c8fd0629db3d0
2017-10-06 10:29:03 -07:00
Dan Cashman
91d398d802 Sync internal master and AOSP sepolicy.
Bug: 37916906
Test: Builds 'n' boots.
Change-Id: Ia1d86264446ebecc1ca79f32f11354921bc77668
Merged-In: I208ec6a864127a059fb389417a9c6b259d7474cb
2017-09-26 14:38:47 -07:00
Tri Vo
9bf6a953ee Explicitly label vold dependecies in /proc
1. Labeled:
/proc/cmdline -> proc_cmdline

2. Removed access to proc label from vold domain.

3. Added access proc_cmdline to these domains:
init, kernel, vold

4. Also, added proc_drop_caches access to vold.

Bug: 66497047
Test: device boots without selinux denials to new labels
Change-Id: Ic88d11b7e56b07c0e8bd874e7f72788922a218e3
2017-09-21 15:48:48 -07:00
Tri Vo
62f2842c80 Explicitly label filesystem files in /proc
proc files needed by fwk that were labeled:
/proc/filesystems -> proc_filesystems
/proc/mounts -> proc_mounts
/proc/swaps -> proc_mounts

Removed access to proc label from these domains:
e2fs, fsck, fsck_untrusted, sdcardd

e2fs: added access to proc_filesystems, proc_mounts, proc_swaps
fsck: added access to proc_mounts, proc_swaps
fsck_untrusted: added access to proc_mounts
sdcardd: added access to proc_filesystems
vold: added access to proc_filesystems, proc_mounts

Bug: 66199084
Test: device boots without selinux denials to new labels or proc label.
Change-Id: If0f19e22074419dab0b3a0c6f3a300ea8cb94523
2017-09-20 15:13:08 -07:00
Tri Vo
6928dd3b8b Merge "Explicitly label system_server's dependencies in /proc" 2017-09-20 16:43:45 +00:00
Tri Vo
8c2323d3f9 Explicitly label system_server's dependencies in /proc
Labeled:
/proc/asound/cards -> proc_asound_cards
/proc/loadavg -> proc_loadavg
/proc/pagetypeinfo -> proc_pagetypeinfo
/proc/version -> proc_version
/proc/vmallocinfo -> proc_vmallocinfo

system_server: added access to all new types  and removed access to proc label.
init: added access to proc_version.
dumpstate: added access to proc_pagetypeinfo, proc_version,
proc_vmallocinfo.
hal_audio: added access to proc_asound_cards.
all_untrusted_apps: extended neverallow rule to include new labels.

Bug: 65980789
Test: device boots without selinux denials to the newly introduced
labels.
Test: "adb shell dumpstate" throws no violations to new labels.
Change-Id: Ic60facd3d4776e38d5e3ba003d06ada4e52c7dca
2017-09-19 21:23:06 +00:00
Jeff Sharkey
2740a3d100 Destroy vold socket interface completely.
Long live Binder.

Test: yes
Bug: 13758960
Change-Id: I11da7f14862024d9e9b901cfac1f22f1147174fa
2017-09-18 17:04:41 -06:00
Tri Vo
87ed5e8dbf Explicitly label logd's dependencies in /proc.
labeled /proc/kmsg as proc_kmsg, changed logd's access from proc to
proc_kmsg, and added a compat mapping.

Bug: 65643247
Test: device boots without selinux denials to the newly introduced proc_kmsg
Test: logd-unit-tests passes

Merged-In: I92c9f5694289eb6a94c4d90f14e2de4d46b5228e
Change-Id: I92c9f5694289eb6a94c4d90f14e2de4d46b5228e
(partial CP of commit 528da6fe3a)
2017-09-14 15:09:33 -07:00
Tri Vo
528da6fe3a Explicitly label logd's dependencies in /proc.
labeled /proc/kmsg as proc_kmsg, changed logd's access from proc to
proc_kmsg, and added a compat mapping.

Bug: 65643247
Test: device boots without selinux denials to the newly introduced proc_kmsg
Test: logd-unit-tests passes
Change-Id: I92c9f5694289eb6a94c4d90f14e2de4d46b5228e
2017-09-13 16:32:40 -07:00
Jin Qian
4de505b6fb allow init to run mke2fs tools to format partitions
Test: let fs_mgr format a damaged /data partition
Bug: 35219933
Change-Id: If92352ea7a70780e9d81ab10963d63e16b793792
(cherry picked from commit 5f573ab2aa)
2017-09-11 18:34:10 +00:00
Martijn Coenen
f7942eb3b2 Merge "Prevent access to nonplat_service_contexts on full_treble." into oc-mr1-dev
am: 346a913c34

Change-Id: Icb294c01b8a8af1f8e0cff4bce13b0eaab8ab8c3
2017-08-12 12:19:42 +00:00
Martijn Coenen
431a03bb9f Prevent access to nonplat_service_contexts on full_treble.
On Full Treble devices, servicemanager should only service
services from the platform service_contexts file.

Created new type to separate plat_ and nonplat_service_contexts,
and added new type to mapping (although I don't think this type
should have been used by vendors).

Bug: 36866029
Test: Marlin/Taimen boot
Change-Id: Ied112c64f22f8486a7415197660faa029add82d9
2017-08-11 14:49:56 +02:00
Joel Galenson
47966cecbb resolve merge conflicts of 27c0aa7a to stage-aosp-master
Test: I solemnly swear I tested this conflict resolution.

Merged-In: Ia28707ec565a0792bc882fbffe9e8ab9968535f5
Change-Id: I1f087fe5e7a71761a16673331619f52998473b44
2017-07-27 17:18:04 +00:00
Joel Galenson
27c0aa7a42 Move file labeling to genfs_contexts.
This should improve performance, as file_contexts is slower than
genfs_contexts.

Bug: 62413700
Test: Built, flashed, and booted Sailfish.  Verified that the
files have the correct context and that wifi, web, and atrace work.

Merged-In: Ia28707ec565a0792bc882fbffe9e8ab9968535f5
Change-Id: I9546f3af3c95e3443684ae4764881b69987611ef
2017-07-27 13:19:55 +00:00
Jeff Vander Stoep
96cfceb1d3 Merge "cgroup: allow associate to tmpfs" am: 5a30eadc49 am: 1bc17b611b am: 1c5ee00f7b
am: 2876629a22

Change-Id: I65fcc2f6339db80e1ecc22b849df23307c7fa64f
2017-07-26 20:45:55 +00:00
Jeff Vander Stoep
2876629a22 Merge "cgroup: allow associate to tmpfs" am: 5a30eadc49 am: 1bc17b611b
am: 1c5ee00f7b

Change-Id: I64b8b41f5557efbafcd509afe6abe9b558982d58
2017-07-26 20:42:21 +00:00
Jeff Vander Stoep
1bc17b611b Merge "cgroup: allow associate to tmpfs"
am: 5a30eadc49

Change-Id: I02b0984e1ecb119e2793d01a950e2e643d3ea5c8
2017-07-26 20:33:22 +00:00
Jeff Vander Stoep
5dcaa67b6f cgroup: allow associate to tmpfs
Allows groups to be mounted at /dev/memcg

Addresses:
avc: denied { associate } for comm="init" name="memcg"
scontext=u:object_r:cgroup:s0 tcontext=u:object_r:tmpfs:s0
tclass=filesystem permissive=0

Bug: 64067152
Test: build
Change-Id: Ic8f641e841fe09c8f7fd487ed67cf0ab4860a1cc
2017-07-26 10:21:58 -07:00
Jeff Vander Stoep
ece21859fc create separate usermodehelper type for sysfs
Prevent files in /proc from incorrectly having sysfs_type attribute.

Rework neverallows so that ueventd has write access to all of
/sys which it needs to handle uevents.

Bug: 63147833
Test: Build. Flash angler, verify files are correctly labeled and no
    new denials are in the logs.

Change-Id: Ib94d44e78cee0e83e2ac924f1c72e611e8e73558
2017-07-12 12:26:12 -07:00
Andres Oportus
2f0d04962a Merge "Allow only system_server to read uid_time_in_state" am: 439364d20e am: e96aad0998
am: 3ce2c6f866

Change-Id: Ic54d118a477d1827952e1c54216ff01838d985d7
2017-07-01 13:04:04 +00:00
Andres Oportus
e96aad0998 Merge "Allow only system_server to read uid_time_in_state"
am: 439364d20e

Change-Id: I726672b2e3379e2e53d3c6b26482147f11d06d8e
2017-07-01 12:54:07 +00:00
Andres Oportus
97b955de13 Allow only system_server to read uid_time_in_state
Bug: 62706738
Bug: 34133340
Test: Check that uid_time_in_state can't be read from
the shell without root permissions and that
"dumpsys batterystats --checkin| grep ctf" shows frequency
data (system_server was able to read uid_time_in_state)

Change-Id: Ic6a54da4ebcc9e10b0e3af8f14a45d7408e8686e
(cherry picked from commit 4dc88795d0)
2017-06-30 22:07:57 -07:00
Jeff Vander Stoep
b596907cae Mark debugfs type with debugfs_type attribute
Test: build policy
Change-Id: If13838e8da6e3fe14bb5c7c7ade6f8ac0d5d1982
2017-06-25 15:35:54 -07:00
Andres Oportus
9babe8f143 Merge "Allow only system_server to read uid_time_in_state" 2017-06-16 21:25:18 +00:00
Andres Oportus
4dc88795d0 Allow only system_server to read uid_time_in_state
Bug: 62706738
Bug: 34133340
Test: Check that uid_time_in_state can't be read from
the shell without root permissions and that
"dumpsys batterystats --checkin| grep ctf" shows frequency
data (system_server was able to read uid_time_in_state)

Change-Id: Ic6a54da4ebcc9e10b0e3af8f14a45d7408e8686e
2017-06-16 11:54:47 -07:00
Joel Galenson
92fdd8954f Properly give some files the debugfs_tracing context only in debug mode.
One of my previous commits removed this, so I am now restoring it.

This commit also contains a bit of cleanup from previous commits by
removing some unneeded types.

It also fixes traceur by porting ag/2409144 to master.

Bug: 62413700, 62547086
Test: Built, flashed, and booted Marlin.  Verified that the files have
the correct context.  Verified that atrace and traceur work.

Change-Id: I76fa0e9060aff554687d57ab3976c8704a4068f0
2017-06-14 15:50:21 -07:00
Jeff Vander Stoep
4a057c9459 Files on /data must have the data_file_type attr
This will be enforced by build-time and CTS tests.

Test: build policy
Change-Id: Ie852fa59670969a2352a97be357d37e420fb180e
2017-06-08 20:03:18 +00:00
Narayan Kamath
f194aad208 SEPolicy: Changes for new stack dumping scheme.
Applications connect to tombstoned via a unix domain socket and request
an open FD to which they can write their traces. This socket has a new
label (tombstoned_java_trace_socket) and appdomain and system_server are
given permissions to connect and write to it.

Apps no longer need permissions to open files under /data/anr/ and
these permissions will be withdrawn in a future change.

Bug: 32064548
Test: Manual

(cherry picked from commit a8832dabc7f3b7b2381760d2b95f81abf78db709)

(cherry picked from commit 11bfcc1e96)

Change-Id: Icc60d227331c8eee70a9389ff1e7e78772f37e6f
2017-05-31 10:01:48 +00:00
Narayan Kamath
e628cb5b2d SEPolicy: Changes for new stack dumping scheme.
Applications connect to tombstoned via a unix domain socket and request
an open FD to which they can write their traces. This socket has a new
label (tombstoned_java_trace_socket) and appdomain and system_server are
given permissions to connect and write to it.

Apps no longer need permissions to open files under /data/anr/ and
these permissions will be withdrawn in a future change.

Bug: 32064548
Test: Manual

Merged-In: I70a3e6e230268d12b454e849fa88418082269c4f
Change-Id: Ib4b73fc130f4993c44d96c8d68f61b6d9bb2c7d5
2017-05-31 08:54:37 +01:00
Narayan Kamath
11bfcc1e96 SEPolicy: Changes for new stack dumping scheme.
Applications connect to tombstoned via a unix domain socket and request
an open FD to which they can write their traces. This socket has a new
label (tombstoned_java_trace_socket) and appdomain and system_server are
given permissions to connect and write to it.

Apps no longer need permissions to open files under /data/anr/ and
these permissions will be withdrawn in a future change.

Bug: 32064548
Test: Manual

(cherry picked from commit a8832dabc7f3b7b2381760d2b95f81abf78db709)

Change-Id: I70a3e6e230268d12b454e849fa88418082269c4f
2017-05-30 18:16:38 +01:00
Alex Vakulenko
c4055f0d04 SELinux policies for PDX services
Specify per-service rules for PDX transport. Now being able to
grant permissions to individual services provided by processes,
not all services of a process.

Also tighter control over which permissions are required for
client and server for individual components of IPC (endpoints,
channels, etc).

Bug: 37646189
Change-Id: I78eb8ae8b6e08105666445a66bfcbd2f1d69d0ea
Merged-Id: I78eb8ae8b6e08105666445a66bfcbd2f1d69d0ea
2017-05-15 10:07:05 -07:00
Luke Song
f8af70bef8 Move sensord sepolicy am: 2dd9ae33f7
am: 9639c5a841

Change-Id: Ia45f76ea09566cab4d36aa8f3a039ba4ebcf6f0c
2017-05-13 01:24:21 +00:00
Luke Song
2dd9ae33f7 Move sensord sepolicy
Sensord move in ag/2106763 should be accompanied by corresponding
sepolicy move of sensord-related files/declarations.

Bug: 36996994
Test: Sailfish build shows no related permission errors
Change-Id: Ibe41b363f7ca2752b5d3e0961298985cf784663d
2017-05-11 16:25:03 -07:00
Alex Vakulenko
251b15a601 Merge "SELinux policies for PDX services" into oc-dev am: 7e6176400b
am: 14847b075b

Change-Id: I2e467b433481631148ad5a761ebeff76459a4a54
2017-05-11 19:07:39 +00:00
Alex Vakulenko
41daa7f859 SELinux policies for PDX services
Specify per-service rules for PDX transport. Now being able to
grant permissions to individual services provided by processes,
not all services of a process.

Also tighter control over which permissions are required for
client and server for individual components of IPC (endpoints,
channels, etc).

Bug: 37646189
Change-Id: I78eb8ae8b6e08105666445a66bfcbd2f1d69d0ea
2017-05-10 16:39:19 -07:00
Jin Qian
5f573ab2aa allow init to run mke2fs tools to format partitions
Test: let fs_mgr format a damaged /data partition
Bug: 35219933
Change-Id: If92352ea7a70780e9d81ab10963d63e16b793792
2017-05-09 10:58:45 -07:00
Abodunrinwa Toki
0fbd4f3e9b SELinux configuration for TextClassifier model updates. am: adfc5db008
am: f0226fd330

Change-Id: If2878d81835f8e429dd7c82c17edd4290028d4d1
2017-04-27 20:02:39 +00:00
Abodunrinwa Toki
adfc5db008 SELinux configuration for TextClassifier model updates.
Test: bit FrameworksCoreTests:android.view.textclassifier.TextClassificationManagerTest
Bug: 34780396
Change-Id: I8b98fef913df571e55474ea2529f71750874941c
2017-04-27 18:54:00 +01:00
Andreas Gampe
c848d37d5a Sepolicy: Fix asanwrapper
Add asanwrapper support for system server under sanitization.

Bug: 36138508
Test: m && m SANITIZE_TARGET=address SANITIZE_LITE=true
Test: adb root && adb shell setprop wrap.system_server asanwrapper
Change-Id: Id930690d2cfd8334c933e0ec5ac62f88850331d0
2017-04-19 16:33:45 -07:00
Carmen Jackson
25788df115 Add selinux rules for additional file contexts in userdebug
These rules allow the additional tracepoints we need for running traceur
in userdebug builds to be writeable.

Bug: 37110010
Test: I'm testing by running atrace -l and confirming that the
tracepoints that I'm attempting to enable are available.

Change-Id: Ia352100ed67819ae5acca2aad803fa392d8b80fd
2017-04-18 14:33:41 -07:00
Martijn Coenen
3ea47b9249 Add hwservice_contexts and support for querying it.
hwservicemanager can check hwservice_contexts files
both from the framework and vendor partitions.

Initially, have a wildcard '*' in hwservice_contexts
that maps to a label that can be added/found from
domain. This needs to be removed when the proper policy
is in place.

Also, grant su/shell access to hwservicemanager list
operations, so tools like 'lshal' continue to work.

Bug: 34454312
Test: Marlin boots
Change-Id: I3a02d97a82458692b528d85c1b8e78b6f82ea1bc
2017-04-12 18:07:12 -07:00
Jiyong Park
ba23c8fa96 Rename vndk-stable to vndk-sp (SP=Same-process)
The concept of VNDK-stable set is gone because they no longer need to be
stable across several Android releases. Instead, they are just small set
of system libraries (other than Low-Level NDK) that can be used by
same-process HALs. They need to be stable only during an Android release
as other VNDK libraries. However, since they are eligible for double
loading, we still need to distinguish those libs from other VNDK
libraries. So we give them a name vndk-sp, which means VNDK designed for
same-process HALs.

Bug: 37139956
Test: booting successful with vndk-sp libs in /vendor/lib(64)?/vndk-sp
Change-Id: I892c4514deb3c6c8006e3659bed1ad3363420732
2017-04-10 14:30:48 +09:00
Jiyong Park
a4768fa8b5 sepolicy: allow access to vndk-stable libs
Vndk-stable libs are system libs that are used by same process HALs.
Since same process HALs can be loaded to any process, so are vndk-stable
libs.

Bug: 37138502
Test: none, because the directory is currently empty and thus this is
no-op. sailfish builds and boots.

Change-Id: I67a2c8c2e4c3517aa30b4a97dc80dc2800e47b5a
2017-04-07 21:16:19 +09:00
Sandeep Patil
277a20ebec sepolicy: relabel /vendor
The CL splits /vendor labeling from /system. Which was allowing all
processes read, execute access to /vendor.

Following directories will remain world readable
 /vendor/etc
 /vendor/lib(64)/hw/

Following are currently world readable but their scope
will be minimized to platform processes that require access
 /vendor/app
 /vendor/framework/
 /vendor/overlay

Files labelled with 'same_process_hal_file' are allowed to be
read + executed from by the world. This is for Same process HALs and
their dependencies.

Bug: 36527360
Bug: 36832490
Bug: 36681210
Bug: 36680116
Bug: 36690845
Bug: 36697328
Bug: 36696623
Bug: 36806861
Bug: 36656392
Bug: 36696623
Bug: 36792803

All of the tests were done on sailfish, angler, bullhead, dragon
Test: Boot and connect to wifi
Test: Run chrome and load websites, play video in youtube, load maps w/
      current location, take pictures and record video in camera,
      playback recorded video.
Test: Connect to BT headset and ensure BT audio playback works.
Test: OTA sideload using recovery
Test: CTS SELinuxHostTest pass

Change-Id: I278435b72f7551a28f3c229f720ca608b77a7029
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-04-05 13:58:32 -07:00
Amit Mahajan
8b080ee260 rild does not communicate with BT/system_server/mediaserver over sockets
Test: manual (verified no denials in basic telephony operations)
Bug: 36613472
Change-Id: I31274adee2cb6293102446cd2d6d547c50616836
2017-04-04 14:04:49 -07:00
Martijn Coenen
c3a9e7df5f Merge "Add target for vndservice_contexts." into oc-dev 2017-04-04 03:41:47 +00:00
Martijn Coenen
6676c234fc Add target for vndservice_contexts.
So we can limit vndservicemanager access to
just vndservice_contexts.

Bug: 36052864
Test: servicemanager,vndservicemanager work
Change-Id: I7b132d4f616ba1edd0daf7be750d4b7174c4e188
2017-04-03 15:39:42 -07:00
Jeffrey Vander Stoep
814edf8c90 Merge "Ban core components from accessing vendor data types" into oc-dev 2017-04-01 14:20:37 +00:00
Jeff Vander Stoep
50563c0367 Ban core components from accessing vendor data types
Vendor and system components are only allowed to share files by
passing open FDs over HIDL. Ban all directory access and all file
accesses other than what can be applied to an open FD such as
ioctl/stat/read/write/append.

This commit asserts that core components marked with attribute
coredomain may only access core data types marked with attribute
core_data_file_type.

A temporary exemption is granted to domains that currently rely on
access.

(cherry picked from commit cd97e71084)

Bug: 34980020
Test: build Marlin policy
Change-Id: I2f0442f2628fbac1f2f7aa5ddf2a13e16b2546cc
2017-04-01 07:16:40 -07:00
Alex Klyubin
2f6151ea44 Tighten restrictions on core <-> vendor socket comms
This futher restricts neverallows for sockets which may be exposed as
filesystem nodes. This is achieved by labelling all such sockets
created by core/non-vendor domains using the new coredomain_socket
attribute, and then adding neverallow rules targeting that attribute.

This has now effect on what domains are permitted to do. This only
changes neverallow rules.

Test: mmm system/sepolicy
Bug: 36577153

(cherry picked from commit cf2ffdf0d8)

Change-Id: Iffeee571a2ff61fb9515fa6849d060649636524e
2017-03-31 09:17:54 -07:00
Sandeep Patil
394539c599 Merge changes from topic 'sefiles_relabel' into oc-dev
* changes:
  mac_permissions: explicitly label all mac_permissions files
  sepolicy: explicitly label all sepolicy files
  seapp_context: explicitly label all seapp context files
  file_context: explicitly label all file context files
  service_contexts: label service_contexts explicitly
  prop_context: correctly label all property_context files
2017-03-29 21:51:02 +00:00
Alex Klyubin
0f6c047d2e tee domain is a vendor domain
As a result, Keymaster and DRM HALs are permitted to talk to tee domain
over sockets. Unfortunately, the tee domain needs to remain on the
exemptions list because drmserver, mediaserver, and surfaceflinger are
currently permitted to talk to this domain over sockets.

We need to figure out why global policy even defines a TEE domain...

Test: mmm system/sepolicy
Bug: 36601092
Bug: 36601602
Bug: 36714625
Bug: 36715266
Change-Id: I0b95e23361204bd046ae5ad22f9f953c810c1895
2017-03-29 13:13:27 -07:00
Sandeep Patil
bb24f3abe1 mac_permissions: explicitly label all mac_permissions files
*mac_permissions.xml files need to be explicitly labeled as they are now split
cross system and vendor and won't have the generic world readable
'system_file' or 'rootfs' label.

Bug: 36003167
Test: no new 'mac_perms_file' denials at boot complete on sailfish
Test: successfully booted into recovery without denials and sideloaded
      OTA update.
Test: Launch 'chrome' and succesfully load a website.
Test: Launch Camera and take a picture.
Test: Launch Camera and record a video, succesfully playback recorded
      video

Change-Id: I1c882872bb78d1242ba273756ef0dc27487f58fc
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-03-29 10:24:20 -07:00
Sandeep Patil
136caa1b65 sepolicy: explicitly label all sepolicy files
sepolicy files need to be explicitly labeled as they are now split
cross system and vendor and won't have the generic world readable
'system_file' or 'rootfs' label.

Bug: 36527360
Test: no new 'sepolicy_file' denials at boot complete on sailfish
Test: successfully booted into recovery without denials and sideloaded
      OTA update.
Test: Launch 'chrome' and succesfully load a website.
Test: Launch Camera and take a picture.
Test: Launch Camera and record a video, succesfully playback recorded
      video

Change-Id: I6fe8ba31588c2d75521c6e2b0bf7e6d6eaf80a19
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-03-29 10:23:01 -07:00
Sandeep Patil
1e149967a2 seapp_context: explicitly label all seapp context files
seapp_context files need to be explicitly labeled as they are now split
cross system and vendor and won't have the generic world readable
'system_file' label.

Bug: 36002414
Test: no new 'seapp_context' denials at boot complete on sailfish
Test: successfully booted into recovery without denials and sideloaded
      OTA update.
Test: ./cts-tradefed run singleCommand cts --skip-device-info \
      --skip-preconditions --skip-connectivity-check --abi \
      arm64-v8a --module CtsSecurityHostTestCases -t \
      android.security.cts.SELinuxHostTest#testAospSeappContexts
Test: Launch 'chrome' and succesfully load a website.
Test: Launch Camera and take a picture.
Test: Launch Camera and record a video, succesfully playback recorded
      video

Change-Id: I19b3e50c6a7c292713d3e56ef0448acf6e4270f7
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-03-29 10:20:11 -07:00
Sandeep Patil
c9cf7361c1 file_context: explicitly label all file context files
file_context files need to be explicitly labeled as they are now split
across system and vendor and won't have the generic world readable
'system_file' label.

Bug: 36002414
Test: no new 'file_context' denials at boot complete on sailfish
Test: successfully booted into recovery without denials and sideloaded
OTA update.
Test: ./cts-tradefed run singleCommand cts --skip-device-info \
       --skip-preconditions --skip-connectivity-check --abi \
       arm64-v8a --module CtsSecurityHostTestCases -t \
       android.security.cts.SELinuxHostTest#testAospFileContexts

Change-Id: I603157e9fa7d1de3679d41e343de397631666273
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-03-29 10:17:21 -07:00
Sandeep Patil
939d16b59f service_contexts: label service_contexts explicitly
The label applies to all service_contexts regardless of their location.
This also lets us track the service_contexts usage and limit access to
the files for the corresponding object manager alone.

Bug: 36002427
Test: Boot sailfish and observe no denials for 'serice_contexts'
Test: cts-tradefed run singleCommand cts --skip-device-info \
          --skip-preconditions --skip-connectivity-check \
          --abi arm64-v8a --module CtsSecurityHostTestCases \
          -t android.security.cts.SELinuxHostTest#testAospServiceContexts

Change-Id: I97fc8b24bc99ca5c00d010fb522cd39a35572858
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-03-29 10:13:34 -07:00
Sandeep Patil
54a4200134 prop_context: correctly label all property_context files
split property context file in vendor and sytem were left untouched by
the recent changes. This was working accidentally because they were
still accessible to all domains as 'system_file'.

Bug: 36002573
Test: Boot sailfish to observe no new denials.
Test: 'adb sideload' OTA on sailfish successfully

Change-Id: I5bec058b59db83d2a431e9f7e91c5a09af7d2942
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-03-29 10:10:32 -07:00
Jeff Vander Stoep
4a478c47f4 Ban vendor components access to core data types
Vendor and system components are only allowed to share files by
passing open FDs over HIDL. Ban all directory access and all file
accesses other than what can be applied to an open file:
stat/read/write/append.

This commit marks core data types as core_data_file_type and bans
access to non-core domains with an exemption for apps. A temporary
exemption is also granted to domains that currently rely on
access with TODOs and bug number for each exemption.

Bug: 34980020
Test: Build and boot Marlin. Make phone call, watch youtube video.
      No new denials observed.
Change-Id: I320dd30f9f0a5bf2f9bb218776b4bccdb529b197
2017-03-28 15:44:39 -07:00
Josh Gao
3dcc37f3c1 Merge "Mark system_ndebug_socket as mlstrustedobject." am: ad38a45cc3 am: e2acb915ad
am: 53047f6d7e

Change-Id: I6e4dac9c891dae5318651a8a44fd7da34e86964c
2017-03-28 00:41:31 +00:00
Josh Gao
3d3d370bbb Mark system_ndebug_socket as mlstrustedobject.
Address the following denial:

    audit(0.0:644): avc: denied { write } for name="ndebugsocket" dev="dm-2" ino=654091 scontext=u:r:crash_dump:s0:c512,c768 tcontext=u:object_r:system_ndebug_socket:s0 tclass=sock_file permissive=0

Bug: http://b/36278094
Test: mm
Change-Id: I0df115a3682385cee72adbfc4687221cd7c51a4d
2017-03-21 15:44:11 -07:00
Jaesoo Lee
329255049c enabled /sbin/modprobe for recovery mode am: d363b0f9eb am: 59454ea491
am: 5a7a046eb6

Change-Id: I423489335646a6f2cb82ff88c5e1502df7d94981
2017-03-16 01:31:11 +00:00
Jaesoo Lee
d363b0f9eb enabled /sbin/modprobe for recovery mode
This change defines new policy for modprobe (/sbin/modprobe) that should
be used in both recovery and android mode.

Denials:
[   16.986440] c0    437 audit: type=1400 audit(6138546.943:5): avc:
denied  { read } for  pid=437 comm="modprobe" name="modules" dev="proc"
ino=4026532405 scontext=u:object_r:modprobe:s0
tcontext=u:object_r:proc:s0 tclass=file permissive=1
[   16.986521] c0    437 audit: type=1400 audit(6138546.943:6): avc:
denied  { open } for  pid=437 comm="modprobe" path="/proc/modules"
dev="proc" ino=4026532405 scontext=u:object_r:modprobe:s0
tcontext=u:object_r:proc:s0 tclass=file permissive=1
[   16.986544] c0    437 audit: type=1400 audit(6138546.943:7): avc:
denied  { getattr } for  pid=437 comm="modprobe" path="/proc/modules"
dev="proc" ino=4026532405 scontext=u:object_r:modprobe:s0
tcontext=u:object_r:proc:s0 tclass=file permissive=1

Bug: 35633646
Test: Build and tested it works in sailfish recovery. The modprobe is
invoked in init.rc (at the end of 'on init') with following command line

    exec u:r:modprobe:s0 -- /sbin/modprobe -a nilfs2 ftl

Change-Id: Ie70be6f918bea6059f806e2eb38cd48229facafa
2017-03-16 01:19:58 +00:00
Fyodor Kupolov
05765ed98c Merge "Split preloads into media_file and data_file" am: 2d22fd814f am: 82d5e46eaf
am: b1e3910a21

Change-Id: I6ddf641d6649f2978c9f8ac70a97156709fea8bd
2017-03-15 17:25:01 +00:00
Fyodor Kupolov
b238fe6662 Split preloads into media_file and data_file
Untrusted apps should only access /data/preloads/media and demo directory.

Bug: 36197686
Test: Verified retail mode.
      Checked non-privileged APK cannot access /data/preloads
Change-Id: I8e9c21ff6aba799aa31bf06893cdf60dafc04446
2017-03-15 00:49:37 +00:00
Po-Chien Hsueh
9a29301376 sepolicy: Move hostapd to vendor
Move hostapd to vendor/bin/ because it's only used by WIFI HAL.
This commit is for sepolicy corresponding changes.

Bug: 34236942
Bug: 34237659
Test: Hotspot works fine. Integration test.

Change-Id: I2ee165970a20f4015d5d62fc590d448e9acb92c1
2017-03-09 11:17:45 +08:00
Yabin Cui
5b15baeb1e Make /proc/sys/kernel/perf_event_max_sample_rate accessible to untrusted_app.
perf_event_max_sample_rate is needed to be read for native profiling,
otherwise CTS test can fail on devices with kernel >= 4.4. Before this CL,
the file is not readable from untrusted_app domain. This CL makes it readable
from both shell domain and untrusted_app domain.

Bug: http://b/35554543
Test: build and test on marlin.
Change-Id: Id118e06e3c800b70a749ab112e07a4ec24bb5975
2017-03-07 11:05:55 -08:00
Calin Juravle
2b291121b9 SElinux: Clean up code related to foreign dex use
We simplified the way we track whether or not a dex file is used by
other apps. DexManager in the framework keeps track of the data and we
no longer need file markers on disk.

Test: device boots, foreign dex markers are not created anymore

Bug: 32871170
Change-Id: I464ed6b09439cf0342020ee07596f9aa8ae53b62
2017-03-07 10:59:26 -08:00
Nick Kralevich
50bb7b5a67 Label /proc/misc
Label /proc/misc and allow access to untrusted_apps targeting older API
versions, as well as update_engine_common.

/proc/misc is used by some banking apps to try to detect if they are
running in an emulated environment.

TODO: Remove access to proc:file from update_engine_common after more
testing.

Bug: 35917228
Test: Device boots and no new denials.
Change-Id: If1b97a9c55a74cb74d1bb15137201ffb95b5bd75
2017-03-03 12:20:38 -08:00
Todd Poynor
7290f63354 Add /data/misc/reboot and reboot_data_file context
Add a file context for keeping track of last reboot reason and label
directory /data/misc/reboot/ for this purpose.

(Cherry picked from commit ca051f6d07)

Bug: 30994946
Test: manual: reboot ocmmand, setprop sys.powerctl, SoC thermal mgr
Change-Id: I9569420626b4029a62448b3f729ecbbeafbc3e66
2017-02-28 13:34:01 -08:00
Nick Kralevich
4cae28d43c tracefs: avoid overly generic regexes
On boot, Android runs restorecon on a number of virtual directories,
such as /sys and /sys/kernel/debug, to ensure that the SELinux labels
are correct. To avoid causing excessive boot time delays, the restorecon
code aggressively prunes directories, to avoid recursing down directory
trees which will never have a matching SELinux label.

See:
* https://android-review.googlesource.com/93401
* https://android-review.googlesource.com/109103

The key to this optimization is avoiding unnecessarily broad regular
expressions in file_contexts. If an overly broad regex exists, the tree
pruning code is ineffective, and the restorecon ends up visiting lots of
unnecessary directories.

The directory /sys/kernel/debug/tracing contains approximately 4500
files normally, and on debuggable builds, this number can jump to over
9000 files when the processing from wifi-events.rc occurs. For
comparison, the entire /sys/kernel/debug tree (excluding
/sys/kernel/debug/tracing) only contains approximately 8000 files. The
regular expression "/sys/kernel(/debug)?/tracing/(.*)?" ends up matching
a significant number of files, which impacts boot performance.

Instead of using an overly broad regex, refine the regex so only the
files needed have an entry in file_contexts. This list of files is
essentially a duplicate of the entries in
frameworks/native/cmds/atrace/atrace.rc .

This change reduces the restorecon_recursive call for /sys/kernel/debug
from approximately 260ms to 40ms, a boot time reduction of approximately
220ms.

Bug: 35248779
Test: device boots, no SELinux denials, faster boot.
Change-Id: I70f8af102762ec0180546b05fcf014c097135f3e
2017-02-12 08:40:32 -08:00
Nick Bray
084faf0259 Add policies for new services.
Bug: 30989383
Bug: 34731101
Test: manual
Change-Id: Icf9d48568b505c6b788f2f5f456f2d709969fbeb
2017-02-09 15:15:11 -08:00
Joe Onorato
41f93db9de Add incident command and incidentd daemon se policy.
Test: adb shell incident
Bug: 31122534
Change-Id: I4ac9c9ab86867f09b63550707673149fe60f1906
2017-02-07 15:52:07 -08:00
Chad Brubaker
4c40d7344c Merge ephemeral data and apk files into app
The rules for the two types were the same and /data/app-ephemeral is
being removed. Remove these types.

Test: Builds
Change-Id: I520c026395551ad1362dd2ced53c601d9e6f9b28
2017-02-06 10:16:50 -08:00
Calin Juravle
01ee59a7b4 Remove SElinux audit to libart_file
Since it was introduced it caused quite a few issues and it spams the
SElinux logs unnecessary.

The end goal of the audit was to whitelist the access to the
interpreter. However that's unfeasible for now given the complexity.

Test: devices boots and everything works as expected
      no more auditallow logs

Bug: 29795519
Bug: 32871170
Change-Id: I9a7a65835e1e1d3f81be635bed2a3acf75a264f6
2017-01-31 23:43:14 +00:00
Mark Salyzyn
d33a9a194b logd: restrict access to /dev/event-log-tags
Create an event_log_tags_file label and use it for
/dev/event-log-tags.  Only trusted system log readers are allowed
direct read access to this file, no write access.  Untrusted domain
requests lack direct access, and are thus checked for credentials via
the "plan b" long path socket to the event log tag service.

Test: gTest logd-unit-tests, liblog-unit-tests and logcat-unit-tests
Bug: 31456426
Bug: 30566487
Change-Id: Ib9b71ca225d4436d764c9bc340ff7b1c9c252a9e
2017-01-31 15:50:15 +00:00
Steven Moreland
62aee3b41b hal_light: add permission to sys/class/leds.
/sys/class/leds is the standard location for linux files dealing with
leds, however the exact contents of this directory is non-standard
(hence the need for a hal).

Bug: 32022100
Test: compiles and works for the subset of common files
Change-Id: I7571d7267d5ed531c4cf95599d5f2acc22287ef4
2017-01-20 00:17:11 +00:00
Josh Gao
d94c5be52d Add mlstrustedobject to tombstone_data_file.
Bug: http://b/30705528
Bug: http://b/34450704
Test: mma
Change-Id: I315a52411232b6ff38d014a2e0fadb0bcfbc1f3f
2017-01-19 10:49:32 -08:00
mukesh agrawal
3a6bc68e64 allow init and system_server access to tracing
Revise policy, to allow init and system_server to configure,
clear, and read kernel trace events. This will enable us to
debug certain WiFi failures.

Note that system_server is restricted to only accessing
a wifi-specific trace instance. (Hence, system_server is
not allowed to interfere with atrace.) Moreover, even for
the wifi trace instance, system_server is granted limited
permissions. (system_server can not, e.g., change which
events are traced.)

Note also that init and system_server are only granted these
powers on userdebug or eng builds.

The init.te and system_server.te changes resolve the
following denials:

// Denials when wifi-events.rc configures tracing
{ write } for pid=1 comm="init" name="instances" dev="debugfs" ino=755 scontext=u:r:init:s0 tcontext=u:object_r:debugfs_tracing_instances:s0 tclass=dir permissive=1
{ add_name } for pid=1 comm="init" name="wifi" scontext=u:r:init:s0 tcontext=u:object_r:debugfs_tracing_instances:s0 tclass=dir permissive=1
{ create } for pid=1 comm="init" name="wifi" scontext=u:r:init:s0 tcontext=u:object_r:debugfs_tracing_instances:s0 tclass=dir permissive=1
{ write } for pid=1 comm="init" name="tracing_on" dev="debugfs" ino=18067 scontext=u:r:init:s0 tcontext=u:object_r:debugfs_wifi_tracing:s0 tclass=file permissive=1
{ write } for pid=1 comm="init" name="buffer_size_kb" dev="debugfs" ino=18061 scontext=u:r:init:s0 tcontext=u:object_r:debugfs_tracing_instances:s0 tclass=file permissive=1

// Denials when system_server sets up fail-safe
// (auto-terminate tracing if system_server dies)
{ search } for pid=882 comm="system_server" name="instances" dev="debugfs" ino=755 scontext=u:r:system_server:s0 tcontext=u:object_r:debugfs_tracing_instances:s0 tclass=dir permissive=1
{ read } for pid=882 comm="system_server" name="free_buffer" dev="debugfs" ino=18063 scontext=u:r:system_server:s0 tcontext=u:object_r:debugfs_wifi_tracing:s0 tclass=file permissive=1
{ open } for pid=882 comm="system_server" path="/sys/kernel/debug/tracing/instances/wifi/free_buffer" dev="debugfs" ino=18063 scontext=u:r:system_server:s0 tcontext=u:object_r:debugfs_wifi_tracing:s0 tclass=file permissive=1
{ getattr } for pid=882 comm="system_server" path="/sys/kernel/debug/tracing/instances/wifi/free_buffer" dev="debugfs" ino=18063 scontext=u:r:system_server:s0 tcontext=u:object_r:debugfs_wifi_tracing:s0 tclass=file permissive=1

// Denials when system_server toggles tracing on or off
// (WifiStateMachine is a thread in system_server)
{ search } for pid=989 comm="WifiStateMachin" name="instances" dev="debugfs" ino=755 scontext=u:r:system_server:s0 tcontext=u:object_r:debugfs_tracing_instances:s0 tclass=dir permissive=1
{ write } for pid=989 comm="WifiStateMachin" name="tracing_on" dev="debugfs" ino=18067 scontext=u:r:system_server:s0 tcontext=u:object_r:debugfs_wifi_tracing:s0 tclass=file permissive=1
{ open } for pid=989 comm="WifiStateMachin" path="/sys/kernel/debug/tracing/instances/wifi/tracing_on" dev="debugfs" ino=18067 scontext=u:r:system_server:s0 tcontext=u:object_r:debugfs_wifi_tracing:s0 tclass=file permissive=1
{ getattr } for pid=989 comm="WifiStateMachin" path="/sys/kernel/debug/tracing/instances/wifi/tracing_on" dev="debugfs" ino=18067 scontext=u:r:system_server:s0 tcontext=u:object_r:debugfs_wifi_tracing:s0 tclass=file permissive=1
{ write } for pid=989 comm="WifiStateMachin" name="tracing_on" dev="debugfs" ino=18067 scontext=u:r:system_server:s0 tcontext=u:object_r:debugfs_wifi_tracing:s0 tclass=file permissive=1
{ open } for pid=989 comm="WifiStateMachin" path="/sys/kernel/debug/tracing/instances/wifi/tracing_on" dev="debugfs" ino=18067 scontext=u:r:system_server:s0 tcontext=u:object_r:debugfs_wifi_tracing:s0 tclass=file permissive=1
{ getattr } for pid=989 comm="WifiStateMachin" path="/sys/kernel/debug/tracing/instances/wifi/tracing_on" dev="debugfs" ino=18067 scontext=u:r:system_server:s0 tcontext=u:object_r:debugfs_wifi_tracing:s0 tclass=file permissive=1

// Denials when system_server reads the event trace
// (This happens in response to a dumpsys request)
{ search } for pid=3537 comm="Binder:882_B" name="instances" dev="debugfs" ino=755 scontext=u:r:system_server:s0 tcontext=u:object_r:debugfs_tracing_instances:s0 tclass=dir permissive=1
{ read } for pid=3537 comm="Binder:882_B" name="trace" dev="debugfs" ino=18059 scontext=u:r:system_server:s0 tcontext=u:object_r:debugfs_wifi_tracing:s0 tclass=file permissive=1
{ open } for pid=3537 comm="Binder:882_B" path="/sys/kernel/debug/tracing/instances/wifi/trace" dev="debugfs" ino=18059 scontext=u:r:system_server:s0 tcontext=u:object_r:debugfs_wifi_tracing:s0 tclass=file permissive=1
{ getattr } for pid=3537 comm="Binder:882_B" path="/sys/kernel/debug/tracing/instances/wifi/trace" dev="debugfs" ino=18059 scontext=u:r:system_server:s0 tcontext=u:object_r:debugfs_wifi_tracing:s0 tclass=file permissive=1
{ write } for pid=3537 comm="Binder:882_B" name="trace" dev="debugfs" ino=18059 scontext=u:r:system_server:s0 tcontext=u:object_r:debugfs_wifi_tracing:s0 tclass=file permissive=1

Bug: 27254565
Test: manual
Manual test:
- Build this CL along with CL:322337
- Verify that system boots, and that we can connect to GoogleGuest.
  (Testing of actual trace functionality with require some more
  patches in frameworks/opt/net/wifi.)
$ adb root && adb shell dmesg | egrep 'avc: denied.+debugfs'

Change-Id: Ib6eb4116549277f85bd510d25fb30200f1752f4d
2017-01-18 15:17:16 -08:00
Josh Gao
cb3eb4eef9 Introduce crash_dump debugging helper.
Replace the global debuggerd with a per-process debugging helper that
gets exec'ed by the process that crashed.

Bug: http://b/30705528
Test: crasher/crasher64, `debuggerd <pid>`, `kill -ABRT <pid>`
Change-Id: Iad1b7478f7a4e2690720db4b066417d8b66834ed
2017-01-18 15:03:24 -08:00
Jin Qian
d345906b14 Define policy for /proc/uid_io/stats
New procfs file read by storaged to dump fg/bg IO usage.

Remove kmsg rule since it's no longer used by storaged.

Allow storaged to find permission_service to translate UID
to package name.

Test: adb shell storaged -u
Bug: 34198239
Change-Id: I74654662c75571cbe166cf2b8cbab84828218cbd
2017-01-18 11:00:57 -08:00
Jeff Sharkey
828433c892 Define policy for /proc/uid_procstat/set.
New procfs file written by the system_server to communicate fg/bg
state of UIDs to switch the statistics counter sets used.

avc: denied { write } for name="set" dev="proc" ino=4026531862 scontext=u:r:system_server:s0 tcontext=u:object_r:proc:s0 tclass=file permissive=1

Test: builds, boots, counter sets updated
Bug: 34360629
Change-Id: I2efbfbba9e73f50ce50a80a3dffd3b14fa55c048
2017-01-17 18:34:17 -07:00
Jim Miller
54e0e5af8f New SeLinux policy for fingerprint HIDL
Move from fingerprintd to new fingerprint_hal and update SeLinux policy.

Test: Boot with no errors related to fingerprint sepolicy
Bug: 33199080
Change-Id: Idfde0cb0530e75e705033042f64f3040f6df22d6
2017-01-13 13:28:31 -08:00
ynwang
9fa8823cdf Storaged permission setting
Allowing storaged for reading from pseudo filesystems and debugfs.

Bug: 32221677

Change-Id: I837cead9a68f0b399703b64d724cb9c4b205c335
2017-01-07 01:12:45 +00:00
Nick Kralevich
e427a2b2be untrusted_app: allow access to /proc/tty/drivers
/proc/tty/drivers is read by applications to figure out if they are
running in an emulated environment. Specifically, they look for the
string "goldfish" within that file.

Arguably this is not an Android API, and really shouldn't be exposed to
applications, but:

1) A largish number of applications break if they can't read this file;
2) The information here isn't particularly sensitive

While we could spend a bunch of time trying to get applications fixed,
there are bigger fish to fry. It's not worth the battle.

Test: "ls -laZ /proc/tty/drivers" is labeled properly.
Bug: 33214085
Bug: 33814662
Bug: 33791054
Bug: 33211769
Bug: 26813932
Change-Id: Icc05bdc1c917547a6dca7d76636a1009369bde49
2017-01-04 08:43:09 -08:00
Jerry Zhang
f921dd9cad Move MediaProvider to its own domain, add new MtpServer permissions
Also move necessary priv_app permissions into MediaProvider domain and
remove MediaProvider specific permissions from priv_app.

The new MtpServer permissions fix the following denials:

avc: denied { write } for comm=6D747020666673206F70656E name="ep0" dev="functionfs" ino=12326 scontext=u:r:priv_app:s0:c512,c768 tcontext=u:object_r:functionfs:s0 tclass=file permissive=1

denial from setting property sys.usb.ffs.mtp.ready, context priv_app

Bug: 30976142
Test: Manual, verify permissions are allowed
Change-Id: I4e66c5a8b36be21cdb726b5d00c1ec99c54a4aa4
2016-12-12 11:05:33 -08:00
Jeff Sharkey
8b1d45201d installd has moved on to Binder; goodbye socket!
After a series of recent commits, installd has fully migrated over
to Binder, and all socket-based communication has been removed.

Test: builds, boots, apps install fine, pre-OTA dexopt works
Bug: 13758960, 30944031
Change-Id: Ia67b6260de58240d057c99b1bbd782b44376dfb5
2016-12-09 15:39:37 -07:00
dcashman
2e00e6373f sepolicy: add version_policy tool and version non-platform policy.
In order to support platform changes without simultaneous updates from
non-platform components, the platform and non-platform policies must be
split.  In order to provide a guarantee that policy written for
non-platform objects continues to provide the same access, all types
exposed to non-platform policy are versioned by converting them and the
policy using them into attributes.

This change performs that split, the subsequent versioning and also
generates a mapping file to glue the different policy components
together.

Test: Device boots and runs.
Bug: 31369363
Change-Id: Ibfd3eb077bd9b8e2ff3b2e6a0ca87e44d78b1317
2016-12-06 08:56:02 -08:00
Chad Brubaker
6f090f6911 Label ephemeral APKs and handle their install/uninstall
Fixes: 32061937
Test: install/uninstall and verified no denials
Change-Id: I487727b6b32b1a0fb06ce66ed6dd69db43c8d536
2016-11-12 00:27:28 +00:00
Robert Sesek
dc43f7cd84 Add the "webview_zygote" domain.
The webview_zygote is a new unprivileged zygote and has its own sockets for
listening to fork requests. However the webview_zygote does not run as root
(though it does require certain capabilities) and only allows dyntransition to
the isolated_app domain.

Test: m
Test: angler boots

Bug: 21643067
Change-Id: I89a72ffe6dcb983c4a44048518efd7efb7ed8e83
2016-11-11 10:13:17 -05:00
Mikhail Naganov
2ff6b4da73 Update SELinux policy for audiohal
Change-Id: Iaa9907ed516c947175a59bf49938c0ee03b4f6d1
2016-10-21 09:53:15 -07:00
Prashant Malani
b32b4a112f sepolicy: Add policy for vibrator HIDL service
Fixes the following denials:
avc: denied { open } for pid=7530 comm="android.hardwar" path="/sys/devices/virtual/timed_output/vibrator/enable" dev="sysfs" ino=20519 scontext=u:r:android_hardware_vibrator_1_0_service:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=1
avc: denied { call } for pid=9173 comm="Binder:7735_C" scontext=u:r:system_server:s0 tcontext=u:r:android_hardware_vibrator_1_0_service:s0 tclass=binder permissive=1

Test: m
Bug: 32021191
Change-Id: I243a86b449794e3c2f0abf91ddcf405eff548d0c
2016-10-13 11:41:30 -07:00
Chad Brubaker
06cf31eb63 Rename autoplay_app to ephemeral_app
Test: Builds and boots
Change-Id: I3db64e12f0390c6940f5745eae83ce7efa7d65a9
2016-10-07 09:52:31 -07:00
dcashman
cc39f63773 Split general policy into public and private components.
Divide policy into public and private components.  This is the first
step in splitting the policy creation for platform and non-platform
policies.  The policy in the public directory will be exported for use
in non-platform policy creation.  Backwards compatibility with it will
be achieved by converting the exported policy into attribute-based
policy when included as part of the non-platform policy and a mapping
file will be maintained to be included with the platform policy that
maps exported attributes of previous versions to the current platform
version.

Eventually we would like to create a clear interface between the
platform and non-platform device components so that the exported policy,
and the need for attributes is minimal.  For now, almost all types and
avrules are left in public.

Test: Tested by building policy and running on device.

Change-Id: Idef796c9ec169259787c3f9d8f423edf4ce27f8c
2016-10-06 13:09:06 -07:00
Renamed from file.te (Browse further)