Commit graph

7813 commits

Author SHA1 Message Date
Tao Bao
0733c2066f Merge "recovery.te: Allow writing to sysfs_devices_system_cpu."
am: 94d76c877b

Change-Id: I3d4343c5c1bc210253e24de8aeec192e331ffebb
2016-11-22 23:57:21 +00:00
Treehugger Robot
94d76c877b Merge "recovery.te: Allow writing to sysfs_devices_system_cpu." 2016-11-22 23:48:44 +00:00
Nick Kralevich
a824fa33ca neverallow some /proc file reads
am: 0b7506ff53

Change-Id: I8093d316ef2f0e5839073b88351bca4eace75b7b
2016-11-22 23:26:07 +00:00
Tao Bao
ee7960c05d recovery.te: Allow writing to sysfs_devices_system_cpu.
recovery (update_binary) may need to set up cpufreq during an update.

avc:  denied  { write } for  pid=335 comm="update_binary" name="scaling_max_freq" dev="sysfs" ino=7410 scontext=u:r:recovery:s0 tcontext=u:object_r:sysfs_devices_system_cpu:s0 tclass=file permissive=0

Bug: 32463933
Test: Build a recovery image and apply an OTA package that writes to
      /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq.

Change-Id: Ia90af9dd15e162dd94bcd4722b66aa296e3058c5
2016-11-22 14:03:25 -08:00
Nick Kralevich
0b7506ff53 neverallow some /proc file reads
Lock in the gains we've made so far in restricting access to generically
labeled /proc files. There's more we can do here, but let's avoid
inadvertent regressions.

Test: policy compiles. Only compile time assertions added.
Bug: 26813932
Change-Id: If354c2ddc1c59beed7f0eb4bcbd3f0d9971c3b8a
2016-11-22 13:18:02 -08:00
Nick Kralevich
1d18ef4486 access_vectors: Remove unused permission definitions
am: 11dc03e5a2

Change-Id: Ie2c7f871c47d378cc3b8399e174b229439511452
2016-11-22 01:39:56 +00:00
Nick Kralevich
11dc03e5a2 access_vectors: Remove unused permission definitions
Description stolen from
42a9699a9f

Remove unused permission definitions from SELinux.
Many of these were only ever used in pre-mainline
versions of SELinux, prior to Linux 2.6.0.  Some of them
were used in the legacy network or compat_net=1 checks
that were disabled by default in Linux 2.6.18 and
fully removed in Linux 2.6.30.

Permissions never used in mainline Linux:
file swapon
filesystem transition
tcp_socket { connectto newconn acceptfrom }
node enforce_dest
unix_stream_socket { newconn acceptfrom }

Legacy network checks, removed in 2.6.30:
socket { recv_msg send_msg }
node { tcp_recv tcp_send udp_recv udp_send rawip_recv rawip_send dccp_recv dccp_send }
netif { tcp_recv tcp_send udp_recv udp_send rawip_recv rawip_send dccp_recv dccp_send }

Test: policy compiles and no boot errors (marlin)
Change-Id: Idaef2567666f80db39c3e3cee70e760e1dac73ec
2016-11-21 23:41:18 +00:00
Jorge Lucangeli Obes
2c2ee69500 Merge "Add WITH_DEXPREOPT_PIC to 'with_dexpreopt' SELinux macro."
am: f25e5550a7

Change-Id: I267d30094daf909158f720fa8e7c501e13a5ccc3
2016-11-21 23:28:38 +00:00
Treehugger Robot
f25e5550a7 Merge "Add WITH_DEXPREOPT_PIC to 'with_dexpreopt' SELinux macro." 2016-11-21 23:16:53 +00:00
Jorge Lucangeli Obes
2899434716 Add WITH_DEXPREOPT_PIC to 'with_dexpreopt' SELinux macro.
|WITH_DEXPREOPT_PIC = false| will still cause code to be loaded from
/data.

Bug: 32970029
Test: On HiKey and Marlin:
Test: Add |WITH_DEXPREOPT_PIC = false|, see SELinux denial.
Test: Apply this CL, no SELinux denials.
Change-Id: I0a1d39eeb4d7f75d84c1908b879d9ea1ccffba74
2016-11-21 11:57:08 -05:00
Nick Kralevich
b9566eff33 Collapse urandom_device into random_device
am: 5eadcb8cb1

Change-Id: I79ed60bfb69e16c0e55ff84583e0930a7adf7cb8
2016-11-21 16:41:26 +00:00
Nick Kralevich
f1f6f2ffaa domain_deprecated.te: delete stale permissions
am: f2de07529b

Change-Id: I198f91d03eb87d3fc707b67d50a9a363d94e066a
2016-11-21 16:41:15 +00:00
Nick Kralevich
5eadcb8cb1 Collapse urandom_device into random_device
urandom_device and random_device have the exact same security
properties. Collapse them into one type.

Test: device boots and /dev/urandom is labeled correctly.
Change-Id: I12da30749291bc5e37d99bc9422bb86cb58cec41
2016-11-21 16:37:07 +00:00
Nick Kralevich
f2de07529b domain_deprecated.te: delete stale permissions
auditallows have been in place for quite a while now, and nothing has
triggered. Let's do some cleanup!

Bug: 28760354
Test: device boots and no new denials
Test: SELinux denials collection has seen no instances of these
      permissions
Change-Id: I9293f8d8756c9db6307e344c32cd11b9e0183e7f
2016-11-20 08:34:02 -08:00
Daniel Micay
9ab5a2787a only permit text relocations in untrusted_app
am: dc083f596d

Change-Id: I38a2613d04dc0e59dc9e76dff39ab5ae9a024ae4
2016-11-20 15:16:55 +00:00
Daniel Micay
dc083f596d only permit text relocations in untrusted_app
The other domains either don't have the same backwards compatibility
issues (isolated_app) or are privileged components that are pretty much
part of the platform and can be expected to meet a higher standard.

It would be possible to expose a build option for disabling the ART JIT,
allowing conditional removal of execmem from some of these domains too
(ones not ever using the WebView, until that's always in isolated_app).

Bug: 20013628
Change-Id: Ic22513157fc8b958b2a3d60381be0c07b5252fa5
2016-11-20 15:10:34 +00:00
Jorge Lucangeli Obes
ff63c47d78 Merge "Use with_dexpreopt macro for zygote execute permissions."
am: 1eb00fb625

Change-Id: Iacfd0778591ebcc34f72c82d4ea4fcc3f7777ce7
2016-11-18 21:56:48 +00:00
Jorge Lucangeli Obes
1eb00fb625 Merge "Use with_dexpreopt macro for zygote execute permissions." 2016-11-18 21:52:07 +00:00
dcashman
7d25474624 Move hal_light to attribute.
am: 3319d5ee16

Change-Id: I6cd85d7fb4235cb2adb4eb0f598959cec52108d0
2016-11-18 19:29:36 +00:00
Jorge Lucangeli Obes
84db84e6cd Use with_dexpreopt macro for zygote execute permissions.
When WITH_DEXPREOPT is set, the zygote does not need to execute
dalvikcache_data_file objects.

Bug: 32970029
Test: Add policy line inside macro, build with and without WITH_DEXPREOPT.
Test: HiKey builds, boots, no zygote denials.
Change-Id: I4dace93e8044267232f0f26cfe427fc250d351fb
2016-11-18 14:22:37 -05:00
dcashman
3319d5ee16 Move hal_light to attribute.
HAL policy defines how the platform and a given HAL interact, but not how the
HAL is implemented.  This policy should be represented as an attribute that all
processes implementing the HAL can include.

Bug: 32123421
Test: Builds.
Change-Id: I17e5612c0835773c28e14f09e2ce7bdc3f210c15
2016-11-18 08:40:04 -08:00
Connor O'Brien
f142317a83 Merge "Revert "Move boot_control_hal attribute to hal_boot domain""
am: b44d2c9b7c

Change-Id: Ia43d948ce7b31336d90f188b6fb2578832be1fee
2016-11-18 04:28:34 +00:00
Treehugger Robot
b44d2c9b7c Merge "Revert "Move boot_control_hal attribute to hal_boot domain"" 2016-11-18 04:24:34 +00:00
Connor O'Brien
394ed93d90 Revert "Move boot_control_hal attribute to hal_boot domain"
This reverts commit 1f3294659d.

Bug: 32973182
Change-Id: Ic0277b38b0249710a4f1fc362e777f3880ff096b
2016-11-18 02:43:03 +00:00
Max Bires
a30f39cb58 Merge "Removed a duplicate rule."
am: 590d0e2418

Change-Id: I79e775df50badaf511d6fedc1cca60e39048b5dc
2016-11-17 23:57:38 +00:00
Max Bires
590d0e2418 Merge "Removed a duplicate rule." 2016-11-17 23:46:29 +00:00
Max
ca04f9b3c4 Removed a duplicate rule.
Test: Device boots
Change-Id: I151c5fb6f56850eaa215e1a917ac9ad609dbdd4a
2016-11-17 23:46:15 +00:00
Connor O'Brien
1dedd46d27 Merge "Move boot_control_hal attribute to hal_boot domain"
am: e1df51038e

Change-Id: I796889ba9eea3c4496ac581d5da2d383b08465ab
2016-11-17 19:32:42 +00:00
Connor O'Brien
e1df51038e Merge "Move boot_control_hal attribute to hal_boot domain" 2016-11-17 19:06:42 +00:00
Nick Kralevich
883d1a1893 shell.te: revoke syslog(2) access to shell user
am: c9630dc6a1

Change-Id: I81c7f5b62ad2b057a586148ff6ce4cc7654be98a
2016-11-17 15:33:38 +00:00
Nick Kralevich
c9630dc6a1 shell.te: revoke syslog(2) access to shell user
external/toybox commit a583afc812cf7be74ebab72294c8df485908ff04 started
having dmesg use /dev/kmsg, which is unreadable to the unprivileged
shell user. Revoke syslog(2) to the shell user for consistency.

The kernel dmesg log is a source of kernel pointers, which can leak
kASLR information from the kernel. Restricting access to kernel
information will make attacks against Android more difficult. Having
said that, dmesg information is still available from "adb bugreport", so
this change doesn't completely shutdown kernel info leaks.

This change essentially reverts us to the state we were in between Nov 8
2011 and May 27 2014. During that almost 3 year period, the unprivileged
shell user was unable to access dmesg, and there was only one complaint
during that time.

References:
* https://android.googlesource.com/platform/system/core/+/f9557fb
* https://android.googlesource.com/platform/system/sepolicy/+/f821b5a

TODO: Further unify /dev/kmsg permissions with syslog_read permissions.

Test: policy compiles, no dmesg output
Change-Id: Icfff6f765055bdbbe85f302b781aed2568ef532f
2016-11-16 10:22:51 -08:00
Alex Deymo
1f3294659d Move boot_control_hal attribute to hal_boot domain
Grant boot_control_hal permissions to the hal_boot service;
update_engine and update_verifier can call that service rather
than using those permissions themselves.

Bug: 31864052
Test: `bootctl set-active-boot-slot 1`
Change-Id: I5188bc32e7933d4a0f5135b3246df119d3523d69
2016-11-15 15:12:41 -08:00
Nick Kralevich
bbf21a4ffe Merge "exclude su from app auditallow"
am: 747c69f43c

Change-Id: I780f075beb031516bd4c2ce292c1fd1a2beaa5ac
2016-11-15 22:50:03 +00:00
Nick Kralevich
506cae4729 isolated_app: allow access to pre-opened sdcard FDs
am: c121735f42

Change-Id: I3db269a6629b4f246939acc139e99d274ddd6b81
2016-11-15 22:49:51 +00:00
Treehugger Robot
747c69f43c Merge "exclude su from app auditallow" 2016-11-15 22:40:49 +00:00
Nick Kralevich
e0d5c5323d exclude su from app auditallow
su is an appdomain, and as such, any auditallow statements applicable to
appdomain also apply to su. However, su is never enforced, so generating
SELinux denials for such domains is pointless. Exclude su from
ion_device auditallow rules.

Addresses the following auditallow spam:

  avc: granted { ioctl } for comm="screencap" path="/dev/ion" dev="tmpfs"
  ino=10230 ioctlcmd=4906 scontext=u:r:su:s0
  tcontext=u:object_r:ion_device:s0 tclass=chr_file

Test: policy compiles
Change-Id: I2e783624b9e53ad365669bd6f2d4db40da475a16
2016-11-15 13:17:42 -08:00
Nick Kralevich
c121735f42 isolated_app: allow access to pre-opened sdcard FDs
Allow isolated apps to read/write/append/lock already open sdcard
file descriptors passed to it by normal app processes. isolated_apps are
used by processes like Google drive when handling untrusted content.

Addresses the following denial:

  audit(0.0:1508): avc: denied { read } for
  path="/storage/emulated/0/Download/02-corejava.pdf" dev="fuse" ino=310
  scontext=u:r:isolated_app:s0:c512,c768 tcontext=u:object_r:fuse:s0
  tclass=file permissive=0

This partially reverts the tightening added in
ce4b5eeaee.

Add a TODO to consider removing isolated_apps ability to write or append
to files on the sdcard. This limits the damage that can occur should the
isolated_app process be compromised.

Bug: 32896414
Test: Policy compiles. Rule add only, so no possibility of breakage.
Change-Id: Ia128569608fc9c872c90e6c380106b7c81eb7b6f
2016-11-15 12:58:06 -08:00
Daichi Hirono
00020b8edf Allow apps to search appfuse mount point and open a file on appfuse mount point.
am: 4c7044e0b1

Change-Id: Ifd25505c9c2f679b5ace565f9b26e681c54572e6
2016-11-15 03:11:57 +00:00
Daichi Hirono
4c7044e0b1 Allow apps to search appfuse mount point and open a file on appfuse mount point.
Bug: 29970149
Test: None
Change-Id: I59f49f3bf20d93effde5e1a9a3c1ed64fbecb7a8
2016-11-15 10:22:19 +09:00
Chad Brubaker
5fa5ffe1c8 Merge "Allow ephemeral apps network connections"
am: 41301ab74b

Change-Id: Ibf5f1cc6fdd65d35300afaaf73daa963e18baed1
2016-11-14 22:02:49 +00:00
Connor O'Brien
57a25f9c25 Merge "Allow update_verifier to use boot HIDL HAL"
am: 353244451f

Change-Id: I204db093f2bc787e6a1a137b9dd4e7b998b1f617
2016-11-14 22:02:38 +00:00
Treehugger Robot
41301ab74b Merge "Allow ephemeral apps network connections" 2016-11-14 21:53:15 +00:00
Connor O'Brien
353244451f Merge "Allow update_verifier to use boot HIDL HAL" 2016-11-14 21:53:07 +00:00
Chad Brubaker
4abf491a9e Allow ephemeral apps network connections
Test: Verify that HTTP and HTTPS connections from ephemeral apps do not
cause denials.
Change-Id: I0ce25602906e63ec55d5b5869445f2aec10900cb
2016-11-14 12:24:51 -08:00
Chia-I Wu
cc15b4ce63 Add sepolicy for hwcomposer HAL
am: fb08872a40

Change-Id: I739ce0035d0a0d22987aae2d67ea9553f43efbad
2016-11-14 01:54:33 +00:00
Chia-I Wu
aeb6d5bfcb Add sepolicy for gralloc-alloc HAL
am: dd958e5a21

Change-Id: Iad2857dd8d282353281ca0018c478b74d2f98db9
2016-11-14 01:54:31 +00:00
Chia-I Wu
fb08872a40 Add sepolicy for hwcomposer HAL
Allow SurfaceFlinger to call into IComposer, and vice versa for
IComposerCallback.

Specifically,

hwbinder_use(...) for
avc: denied { call } for scontext=u:r:hal_graphics_composer:s0 tcontext=u:r:hwservicemanager:s0 tclass=binder permissive=1
avc: denied { transfer } for scontext=u:r:hal_graphics_composer:s0 tcontext=u:r:hwservicemanager:s0 tclass=binder permissive=1

binder_call(..., surfaceflinger) for
avc: denied { call } for scontext=u:r:hal_graphics_composer:s0 tcontext=u:r:surfaceflinger:s0 tclass=binder permissive=1

allow ... gpu_device:chr_file rw_file_perms for
avc: denied { read write } for name="kgsl-3d0" dev="tmpfs" ino=14956 scontext=u:r:hal_graphics_composer:s0 tcontext=u:object_r:gpu_device:s0 tclass=chr_file permissive=1
avc: denied { open } for path="/dev/kgsl-3d0" dev="tmpfs" ino=14956 scontext=u:r:hal_graphics_composer:s0 tcontext=u:object_r:gpu_device:s0 tclass=chr_file permissive=1
avc: denied { ioctl } for path="/dev/kgsl-3d0" dev="tmpfs" ino=14956 ioctlcmd=940 scontext=u:r:hal_graphics_composer:s0 tcontext=u:object_r:gpu_device:s0 tclass=chr_file permissive=1

allow ... ion_device:chr_file r_file_perms for
avc: denied { ioctl } for path="/dev/ion" dev="tmpfs" ino=15014 ioctlcmd=4900 scontext=u:r:hal_graphics_composer:s0 tcontext=u:object_r:ion_device:s0 tclass=chr_file permissive=1

allow ... graphics_device ... for
avc: denied { ioctl } for path="/dev/graphics/fb0" dev="tmpfs" ino=15121 ioctlcmd=5380 scontext=u:r:hal_graphics_composer:s0 tcontext=u:object_r:graphics_device:s0 tclass=chr_file permissive=1

allow ... ...:fd use for
avc: denied { use } for path="anon_inode:dmabuf" dev="anon_inodefs" ino=12794 scontext=u:r:hal_graphics_composer:s0 tcontext=u:r:hal_graphics_allocator_service:s0 tclass=fd permissive=1
avc: denied { use } for path="anon_inode:sync_fence" dev="anon_inodefs" ino=12794 scontext=u:r:hal_graphics_composer:s0 tcontext=u:r:bootanim:s0 tclass=fd permissive=1
avc: denied { use } for path="anon_inode:sync_fence" dev="anon_inodefs" ino=12794 scontext=u:r:hal_graphics_composer:s0 tcontext=u:r:surfaceflinger:s0 tclass=fd permissive=1
avc: denied { use } for path="anon_inode:sync_fence" dev="anon_inodefs" ino=12794 scontext=u:r:hal_graphics_composer:s0 tcontext=u:r:platform_app:s0:c512,c768 tclass=fd permissive=1

binder_call(surfaceflinger, ...) for
avc: denied { call } for scontext=u:r:surfaceflinger:s0 tcontext=u:r:hal_graphics_composer:s0 tclass=binder permissive=1
avc: denied { transfer } for scontext=u:r:surfaceflinger:s0 tcontext=u:r:hal_graphics_composer:s0 tclass=binder permissive=1
avc: denied { use } for path="anon_inode:sync_fence" dev="anon_inodefs" ino=12794 ioctlcmd=3e02 scontext=u:r:surfaceflinger:s0 tcontext=u:r:hal_graphics_composer:s0 tclass=fd permissive=1
avc: denied { use } for path="anon_inode:sync_fence" dev="anon_inodefs" ino=12794 scontext=u:r:surfaceflinger:s0 tcontext=u:r:hal_graphics_composer:s0 tclass=fd permissive=1

allow bootanim ...:fd use for
avc: denied { use } for path="anon_inode:sync_fence" dev="anon_inodefs" ino=11947 scontext=u:r:bootanim:s0 tcontext=u:r:hal_graphics_composer:s0 tclass=fd permissive=1

Bug: 32021609
Test: make bootimage
Change-Id: I036cdbebf0c619fef7559f294f1865f381b17588
2016-11-14 01:10:02 +00:00
Chia-I Wu
dd958e5a21 Add sepolicy for gralloc-alloc HAL
Allow SurfaceFlinger to call into IAllocator, and allow everyone to access
IAllocator's fd.

Specifically,

hwbinder_use(...) for
avc: denied { call } for scontext=u:r:hal_graphics_allocator:s0 tcontext=u:r:hwservicemanager:s0 tclass=binder permissive=1
avc: denied { transfer } for scontext=u:r:hal_graphics_allocator:s0 tcontext=u:r:hwservicemanager:s0 tclass=binder permissive=1

allow ... ion_device:chr_file r_file_perms for
avc: denied { read } for name="ion" dev="tmpfs" ino=15014 scontext=u:r:hal_graphics_allocator:s0 tcontext=u:object_r:ion_device:s0 tclass=chr_file permissive=1
avc: denied { open } for path="/dev/ion" dev="tmpfs" ino=15014 scontext=u:r:hal_graphics_allocator:s0 tcontext=u:object_r:ion_device:s0 tclass=chr_file permissive=1
avc: denied { ioctl } for path="/dev/ion" dev="tmpfs" ino=15014 ioctlcmd=4900 scontext=u:r:hal_graphics_allocator:s0 tcontext=u:object_r:ion_device:s0 tclass=chr_file permissive=1

allow ... gpu_device:chr_file rw_file_perms; for
avc: denied { read write } for name="kgsl-3d0" dev="tmpfs" ino=14956 scontext=u:r:hal_graphics_allocator:s0 tcontext=u:object_r:gpu_device:s0 tclass=chr_file permissive=1
avc: denied { open } for path="/dev/kgsl-3d0" dev="tmpfs" ino=14956 scontext=u:r:hal_graphics_allocator:s0 tcontext=u:object_r:gpu_device:s0 tclass=chr_file permissive=1
avc: denied { ioctl } for path="/dev/kgsl-3d0" dev="tmpfs" ino=14956 ioctlcmd=940 scontext=u:r:hal_graphics_allocator:s0 tcontext=u:object_r:gpu_device:s0 tclass=chr_file permissive=1

binder_call(surfaceflinger, ...) for
avc: denied { call } for scontext=u:r:surfaceflinger:s0 tcontext=u:r:hal_graphics_allocator:s0 tclass=binder permissive=1

allow ... ...:fd use for
avc: denied { use } for path="anon_inode:dmabuf" dev="anon_inodefs" ino=12794 scontext=u:r:surfaceflinger:s0 tcontext=u:r:hal_graphics_allocator:s0 tclass=fd permissive=1

Bug: 32021161
Test: make bootimage
Change-Id: Ie7700142313407ac438c43dd1a85544dc4c67f13
2016-11-14 01:09:51 +00:00
Chad Brubaker
7ece155217 Label ephemeral APKs and handle their install/uninstall
am: 6f090f6911

Change-Id: I97d83d29f28fb04500f30bd29c4a316f3bbb7ee0
2016-11-12 00:36:35 +00: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