Commit Graph

11443 Commits

Author SHA1 Message Date
Mark Salyzyn
801918d14a bootstat: introduce sys.boot.reason
Add access to [persist.]sys.boot.reason, pstore, dmesg and logcat

Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: Id521609308e0e967b24d7558982b30a1fc4c0a32
2017-08-24 15:19:40 -07:00
Mark Salyzyn
006c2e9934 Switch /data/misc/reboot/last_reboot_reason to persistent property
Switch from /data/misc/reboot/last_reboot_reason to persistent
Android property persist.sys.boot.reason for indicating why the
device is rebooted or shutdown.

Introduce protection for all boot reason properties

Protect the following properties with these labels

ro.boot.bootreason      u:object_r:bootloader_boot_reason_prop:s0
sys.boot.reason         u:object_r:sys_boot_reason_prop:s0
persist.sys.boot.reason u:object_r:last_boot_reason_prop:s0

Setup the current as-need access rules for each.

ToDo: Remove u:object_r:reboot_data_file after internal fixes.

Test: system/core/bootstat/boot_reason_test.sh
Bug: 64687998
Change-Id: I3771c73933e8ae2d94aee936c7a38b6282611b80
2017-08-24 15:19:30 -07:00
Treehugger Robot
99cbe530c1 Merge "move build dependencies to sepolicy" 2017-08-23 21:31:31 +00:00
Alex Light
9cd2abc2a2 Grant cppreopts.sh permissions to cleanup if it fails
If cppreopts.sh failed to copy files for some reason it would leave
the temporary files sitting around in the data directory. This changes
the selinux rules so that cppreopts is able to get rid of these
temporary files.

Test: phone boots.
Bug: 63995897
Change-Id: I2a7e654c3a3cee7c9f0be8ba64e40c365eee4cfe
2017-08-23 16:00:23 +00:00
John Stultz
24537b2e96 sepolicy: Define and allow map permission for vendor dir
This patch tries to provide similar functionality as the previous
change made here:
https://android-review.googlesource.com/#/c/platform/system/sepolicy/+/432339/

Only, making sure we add the same map permissions for the vendor
directory.

Change-Id: Ia965df2881cdee8bb5d81278a1eb740def582871
Signed-off-by: John Stultz <john.stultz@linaro.org>
2017-08-23 05:41:36 +00:00
Jeff Vander Stoep
13fb5ed305 move build dependencies to sepolicy
Some selinux build packages are defined in embedded.mk,
others are defined in system/sepolicy/Android.mk. Move all
to sepolicy as a dependency of the phony package selinux_policy
which is defined in embedded.mk.

Test: build Marlin (Treble) and Angler (non-Treble)
Merged-In: Ib0443ad3da600447fbb51f2e9f91de04dcf5f9f6
Change-Id: Ib0443ad3da600447fbb51f2e9f91de04dcf5f9f6
2017-08-23 05:27:03 +00:00
Tianjie Xu
ced80e801b Merge "Allow update_verifier to write to kmsg"
am: d90d976e45

Change-Id: Id7dc23f6b1c401f350736585222a9e29bf5e3876
2017-08-17 19:19:40 +00:00
Tianjie Xu
d90d976e45 Merge "Allow update_verifier to write to kmsg" 2017-08-17 19:16:11 +00:00
Martijn Coenen
333808edf5 Merge "Remove display.qservice from service_contexts."
am: 109ee5f99c

Change-Id: I47562c12713809970d8531b453f08de74c53466f
2017-08-17 07:46:07 +00:00
Martijn Coenen
109ee5f99c Merge "Remove display.qservice from service_contexts." 2017-08-17 07:39:29 +00:00
Tianjie Xu
d499e9145a Allow update_verifier to write to kmsg
Denial message:
avc: denied { write } for pid=640 comm="update_verifier" name="kmsg"
dev="tmpfs" ino=13951 scontext=u:r:update_verifier:s0
tcontext=u:object_r:kmsg_device:s0 tclass=chr_file permissive=0

Bug: 64713327
Test: update_verifier logs successfully during boot time.
Change-Id: I421b1e6660239e5ffc624e504f5945d400510407
2017-08-16 13:09:56 -07:00
Martijn Coenen
e18873591d Remove display.qservice from service_contexts.
This is a Qualcomm proprietary service,
and does not belong here.

Test: boot Marlin
Bug: 63391760
Merged-In: If7469051f6cef3e2440f7021ae26c9815ff54820
Change-Id: If7469051f6cef3e2440f7021ae26c9815ff54820
2017-08-16 10:11:53 +02:00
TreeHugger Robot
09d37ab90b Merge "Add screencap domain." into stage-aosp-master 2017-08-14 19:26:41 +00:00
Steven Moreland
0bf4d0db05 Add screencap domain.
am: 6b780b358f  -s ours

Change-Id: I61d2951d682b236e7643b7b81eb5c52f84024950
2017-08-14 18:49:35 +00:00
Steven Moreland
9216a6adc9 Add screencap domain.
Only seeing this denial in permissive:
allow shell screencap_exec:file getattr;

Bug: 37565047
Test: adb shell screencap w/o root
Test: cts-tradefed run cts-dev --module CtsAadbHostTestCases
Merged-In: I9f31d2067e002e7042646ee38dbfc06687481ac7
Change-Id: I9f31d2067e002e7042646ee38dbfc06687481ac7
2017-08-14 11:46:08 -07:00
Steven Moreland
6b780b358f Add screencap domain.
Only seeing this denial in permissive:
allow shell screencap_exec:file getattr;

Bug: 37565047
Test: adb shell screencap w/o root
Test: cts-tradefed run cts-dev --module CtsAadbHostTestCases
Merged-In: I9f31d2067e002e7042646ee38dbfc06687481ac7
Change-Id: I9f31d2067e002e7042646ee38dbfc06687481ac7
2017-08-14 17:19:40 +00:00
Josh Gao
530e168c67 Add /dev/kmsg_debug.
am: 94e2a921cb

Change-Id: I3cb9bd4305fe3f6d720f757a232d4bb38de98895
2017-08-11 22:54:15 +00:00
Josh Gao
94e2a921cb Add /dev/kmsg_debug.
Add /dev/kmsg_debug on userdebug devices, to allow crash_dump to log
crashes to dmesg when logd isn't up yet (or is the one crashing).

Bug: http://b/36574794
Test: stop tombstoned; crasher; dmesg
Change-Id: I6ffe11bc613e88198893e82712719522b74fe1be
2017-08-11 13:25:43 -07:00
Nick Kralevich
881fe06f34 Validate no-cross-domain /proc/PID access
am: 7a46380969

Change-Id: Iba80938afccd21f0c3b69626223b35c672358e77
2017-08-11 19:17:29 +00:00
Nick Kralevich
7a46380969 Validate no-cross-domain /proc/PID access
Android uses hidepid=2 to restrict visibility to other /proc entries on
the system. This helps preserve user, application, and system
confidentiality by preventing unauthorized access to application metadata,
and addresses attacks such as
http://www.cs.ucr.edu/~zhiyunq/pub/sec14_android_activity_inference.pdf

Ensure the SELinux (weaker) equivalent is being enforced by adding
neverallow compile time assertions.

TODO: The "shell" user runs as both an Android application, as well as
spawned via adb shell. This was a mistake. We should separate out the
"shell" Android app into it's own SELinux domain. For now, exclude the
shell from this assertion. (The shell Android app is covered by
hidepid=2, so there's no leaking of data, but still, it's over
privileged today and should be cleaned up.

Bug: 23310674
Test: policy compiles. Compile time assertion only.
Change-Id: I0e1a6506b2719aabf7eb8127f046c4ada947ba90
2017-08-11 10:05:22 -07:00
Manoj Gupta
508db351a1 Merge "Fix static analyzer warnings."
am: 4b547a1516

Change-Id: Id5b85ec29220cdbc15aab72ddf4dfbd2d4ef2fc7
2017-08-02 02:47:37 +00:00
Treehugger Robot
4b547a1516 Merge "Fix static analyzer warnings." 2017-08-02 02:35:48 +00:00
Manoj Gupta
3cdd4a4b0d Fix static analyzer warnings.
Fix the following warnings:

system/sepolicy/tools/sepolicy-analyze/neverallow.c:346:9: warning:
Potential leak of memory pointed to by '__s1'
system/sepolicy/tools/sepolicy-analyze/neverallow.c:346:9: warning:
Potential leak of memory pointed to by 'id'
system/sepolicy/tools/sepolicy-analyze/neverallow.c:364:13: warning:
Potential leak of memory pointed to by 'classperms'
system/sepolicy/tools/sepolicy-analyze/neverallow.c:364:13: warning:
Potential leak of memory pointed to by 'node'

Bug: b/27101951
Test:Warnings are gone.
Change-Id: Ib9b2e0b9f19950b4b764d438ee58340e6c022ef5
2017-08-01 15:46:44 -07:00
Ruchi Kandoi
7ceea48409 Allow nfc application to set nfc property
am: df9649503a

Change-Id: I5e793a78ad471b27fdc0bb88596ab23f6ac43dc4
2017-08-01 20:46:45 +00:00
Ruchi Kandoi
df9649503a Allow nfc application to set nfc property
type=1400 audit(1501520483.066:14): avc: denied { write } for pid=3330
comm=4173796E635461736B202331 name="property_service" dev="tmpfs"
ino=10749 scontext=u:r:nfc:s0 tcontext=u:object_r:property_socket:s0
tclass=sock_file permissive=0

Test: No sepolicy denials
Bug: 64010793
Change-Id: I8d73e8e19cd4d0a8c61f1f184820c53e5cc2b6d6
2017-07-31 10:07:13 -07:00
Jeff Vander Stoep
4e9601887f system_server: allow writing to timerslack_ns
am: 5c41d40ecd

Change-Id: I6a60af407a6a95e3d48818de28619dc5ba44284f
2017-07-29 02:37:33 +00:00
Jeff Vander Stoep
5c41d40ecd system_server: allow writing to timerslack_ns
The only file in /proc/<pid>/ that is world writeable is
/proc/<pid>/timerslack_ns so granting selinux write permission to
a process's /proc/<pid>/ file only allows writing to timerslack_ns
(unless the process is running as system UID).

Addresses denials such as:
avc: denied { write } for comm="Binder:1117_2" name="timerslack_ns"
dev="proc" ino=27908 scontext=u:r:system_server:s0
tcontext=u:r:priv_app:s0 tclass=file permissive=1

Bug: 30675296
Test: build
Change-Id: I2cee8ce73a0dc05d771881c36da2fde5411859fb
2017-07-28 23:41:25 +00:00
Jeff Vander Stoep
d22cbc8ffb Merge "domain_deprecated is dead"
am: f1b06df3d6

Change-Id: I0d98e192600c94f983d7b0347715e2ba6a8b8dab
2017-07-28 23:22:43 +00:00
Treehugger Robot
f1b06df3d6 Merge "domain_deprecated is dead" 2017-07-28 23:13:17 +00:00
Jeff Vander Stoep
b5da252e45 domain_deprecated is dead
long live domain.te!

Remove all references.

Bug: 28760354
Test: build
Merged-In: I99953ecc7d275fdbe8e56d8f47a27d1f9e1cc09a
Change-Id: I99953ecc7d275fdbe8e56d8f47a27d1f9e1cc09a
2017-07-28 22:01:46 +00:00
TreeHugger Robot
55f0ecb7c7 Merge "Add missing comment from my previous merge in 47966ce." into stage-aosp-master 2017-07-28 16:06:52 +00:00
Tim Kryger
4ebe609ac5 Merge "Fix selinux denials during bugreport"
am: bfbe96acfd

Change-Id: I12a2ed20022edf9da528f0ab5941cc5df8e418ab
2017-07-28 15:12:47 +00:00
Tim Kryger
bfbe96acfd Merge "Fix selinux denials during bugreport" 2017-07-28 15:06:46 +00:00
Jeff Vander Stoep
8e589af690 domain_deprecated: remove sysfs rules
am: 275f6dd5a3

Change-Id: I02b2eb1a5bbd0cf3a4bbeffbe70e442ba4cf8ee6
2017-07-27 22:29:43 +00:00
Tim Kryger
b7e1f2dd19 Fix selinux denials during bugreport
avc: denied { read } for pid=1704 comm="top" name="stat" dev="proc" ino=4026532297 scontext=u:r:dumpstate:s0 tcontext=u:object_r:proc_stat:s0 tclass=file permissive=0
avc: denied { read } for pid=1636 comm="dumpstate" name="lcd-backlight" dev="sysfs" ino=16592 scontext=u:r:dumpstate:s0 tcontext=u:object_r:sysfs_leds:s0 tclass=lnk_file permissive=0
avc: denied { call } for pid=2230 comm="dumpsys" scontext=u:r:dumpstate:s0 tcontext=u:r:installd:s0 tclass=binder permissive=0
avc: denied { create } for pid=1700 comm="ip" scontext=u:r:dumpstate:s0 tcontext=u:r:dumpstate:s0 tclass=netlink_xfrm_socket permissive=0

Bug: 62410287
Bug: 35350306
Change-Id: I65be3678c64214ebeb544e0e155bce88b21adf02
Signed-off-by: Tim Kryger <tkryger@google.com>
2017-07-27 13:57:12 -07:00
Jeff Vander Stoep
275f6dd5a3 domain_deprecated: remove sysfs rules
Clean up the remaining granted permissions in domain_deprecated.

avc: granted { read open } for comm="uncrypt"
path="/sys/firmware/devicetree/base/firmware/android/fstab/compatible"
dev="sysfs" ino=17591 scontext=u:r:uncrypt:s0
tcontext=u:object_r:sysfs:s0 tclass=file
avc: granted { getattr } for comm="uncrypt"
path="/sys/firmware/devicetree/base/firmware/android/compatible"
dev="sysfs" ino=17583 scontext=u:r:uncrypt:s0
tcontext=u:object_r:sysfs:s0 tclass=file

vc: granted { read open } for comm="update_engine"
path="/sys/firmware/devicetree/base/firmware/android/fstab" dev="sysfs"
ino=17258 scontext=u:r:update_engine:s0 tcontext=u:object_r:sysfs:s0
tclass=dir
avc: granted { getattr } for comm="update_engine"
path="/sys/firmware/devicetree/base/firmware/android/fstab/compatible"
dev="sysfs" ino=17259 scontext=u:r:update_engine:s0
tcontext=u:object_r:sysfs:s0 tclass=file

Bug: 28760354
Test: build
Change-Id: Id318ce84894c1001361923f5205de093a15c1e6a
2017-07-27 20:03:16 +00:00
Jeffrey Vander Stoep
d7989e8bd2 Merge "netd: relax binder neverallow rules for hwservices"
am: 4fc64f2fc3

Change-Id: I7dd6ea7bb5d767afb98a39e56214dd05d4585c93
2017-07-27 19:38:15 +00:00
Jeffrey Vander Stoep
4fc64f2fc3 Merge "netd: relax binder neverallow rules for hwservices" 2017-07-27 19:28:13 +00:00
Joel Galenson
87e5116239 Add missing comment from my previous merge in 47966ce.
Test: Built.
Change-Id: Ia5f5b52e10e9411cd87901053675d9e77a622529
2017-07-27 12:23:00 -07: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
Jeff Vander Stoep
07c650ebf2 netd: relax binder neverallow rules for hwservices
Relax neverallow rule restricting binder access to/from netd so that
netd can export hwbinder services to vendor components.

Continue to disallow app access to netd via binder.

Bug: 36682246
Test: build
Change-Id: I8e558ea1add6c36b966ec1da204062ea82df3f3f
2017-07-27 16:51:27 +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
1bc17b611b Merge "cgroup: allow associate to tmpfs"
am: 5a30eadc49

Change-Id: I02b0984e1ecb119e2793d01a950e2e643d3ea5c8
2017-07-26 20:33:22 +00:00
Treehugger Robot
5a30eadc49 Merge "cgroup: allow associate to tmpfs" 2017-07-26 20:20:55 +00:00
Jeff Vander Stoep
3d765cfd08 Merge "system_server: read symlinks in /cache"
am: 825173e3c2

Change-Id: Ic7acb327cf684e6b82b1d40b408c039e02c0a7fd
2017-07-26 19:19:45 +00:00
Treehugger Robot
825173e3c2 Merge "system_server: read symlinks in /cache" 2017-07-26 19:08:21 +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
a4cada7439 system_server: read symlinks in /cache
type=1400 audit(0.0:6): avc: denied { read } for comm="Thread-5"
name="cache" dev="dm-0" ino=13 scontext=u:r:system_server:s0
tcontext=u:object_r:cache_file:s0 tclass=lnk_file permissive=0

Bug: 64067152
Test: build
Change-Id: Ie90c0343a834aa87b7ded41f503e05d9b63b3244
2017-07-26 09:58:47 -07:00
Jeff Vander Stoep
ad95219cf4 domain_deprecated: remove proc access
am: c15d54ef1a

Change-Id: I5b47e2ced9dd5aa92727076e4cef0cc4ebaeaf7c
2017-07-26 13:28:23 +00:00
Jeff Vander Stoep
c15d54ef1a domain_deprecated: remove proc access
Remove "granted" logspam. Grante the observed permissions to the
individual processes that need them and remove the permission from
domain_deprecated.

avc: granted { read open } for comm="ndroid.settings"
path="/proc/version" dev="proc" ino=4026532081
scontext=u:r:system_app:s0 tcontext=u:object_r:proc:s0 tclass=file
avc: granted { getattr } for comm=4173796E635461736B202332
path="/proc/pagetypeinfo" dev="proc" ino=4026532129
scontext=u:r:system_app:s0 tcontext=u:object_r:proc:s0 tclass=file

avc: granted { read open } for comm="uncrypt" path="/proc/cmdline"
dev="proc" ino=4026532072 scontext=u:r:uncrypt:s0
tcontext=u:object_r:proc:s0 tclass=file

avc: granted { read open } for comm="update_engine"
path="/proc/sys/kernel/random/boot_id" dev="proc" ino=15852829
scontext=u:r:update_engine:s0 tcontext=u:object_r:proc:s0 tclass=file

avc: granted { read open } for comm="tiveportallogin"
path="/proc/vmstat" dev="proc" ino=4026532130
scontext=u:r:platform_app:s0:c512,c768 tcontext=u:object_r:proc:s0
tclass=file

This change is specifically not granting the following since it
should not be allowed:
avc: granted { read open } for comm="crash_dump64"
path="/proc/filesystems" dev="proc" ino=4026532416
scontext=u:r:dex2oat:s0 tcontext=u:object_r:proc:s0 tclass=file
avc: granted { read } for comm="crash_dump64" name="filesystems"
dev="proc" ino=4026532416 scontext=u:r:dex2oat:s0
tcontext=u:object_r:proc:s0 tclass=file
avc: granted { getattr } for comm="crash_dump64"
path="/proc/filesystems" dev="proc" ino=4026532416
scontext=u:r:dex2oat:s0 tcontext=u:object_r:proc:s0 tclass=file

Bug: 64032843
Bug: 28760354
Test: build
Change-Id: Ib309e97b6229bdf013468dca34f606c0e8da96d0
2017-07-25 17:34:27 -07:00