Commit graph

11648 commits

Author SHA1 Message Date
Jeff Vander Stoep
5f5aa96286 Preserve attributes needed for CTS
Change fb889f23d "Force expand all hal_* attributes" annotated all
hal_* attributes to be expanded to their associated types. However
some of these attributes are used in CTS for neverallow checking.
Mark these attributes to be preserved.

In addition, remove the hacky workaround introduced in oc-dev
for b/62658302 where extraneous neverallow rules were introduced
to prevent unused or negated attributes from being auto-expanded
from policy.

Bug: 62658302
Bug: 63135903
Test: cts-tradefed run cts -m CtsSecurityHostTestCases -t \
    android.cts.security.SELinuxNeverallowRulesTest

    armeabi-v7a CtsSecurityHostTestCases completed in 4s.
    501 passed, 0 failed, 0 not executed
Merged-In: I989def70a16f66e7a18bef1191510793fbe9cb8c
Change-Id: I989def70a16f66e7a18bef1191510793fbe9cb8c
2017-07-05 23:06:35 +00:00
TreeHugger Robot
4f0776560a Merge "DO NOT MERGE ANYWHERE Revert "SEPolicy: Changes for new stack dumping scheme."" into oc-dr1-dev 2017-06-30 18:02:16 +00:00
TreeHugger Robot
243c46cc46 Merge "hal_tetheroffload: Grant permissions" into oc-dr1-dev 2017-06-29 04:26:11 +00:00
Jeff Vander Stoep
e58a8de5e7 hal_tetheroffload: Grant permissions
avc: denied { read write } scontext=u:r:ipacm:s0
tcontext=u:r:system_server:s0 tclass=netlink_netfilter_socket
avc: denied { setopt } scontext=u:r:ipacm:s0
tcontext=u:r:system_server:s0 tclass=netlink_netfilter_socket
avc: denied { getattr } scontext=u:r:ipacm:s0
tcontext=u:r:system_server:s0 tclass=netlink_netfilter_socket
avc: denied { create } for scontext=u:r:system_server:s0
tcontext=u:r:system_server:s0 tclass=netlink_netfilter_socket

Bug: 29337859
Bug: 32163131
Test: adb shell getenforce
Enforcing
adb shell dumpsys connectivity tethering
Tethering:
  ...
  Log:
    ...
    06-28 11:46:58.841 - SET master tether settings: ON
    06-28 11:46:58.857 - [OffloadController] tethering offload started
And logs show some signs of happiness:
    06-28 11:46:58.853   816   947 I IPAHALService: IPACM was provided two FDs (18, 19)
    06-28 11:46:58.853  1200  1571 I zygote64: Looking for service android.hardware.tetheroffload.control@1.0::IOffloadControl/default
Change-Id: I0c63bd2de334b4ca40e54efb9df4ed4904667e21
2017-06-29 04:24:14 +00:00
TreeHugger Robot
ae548746dc Merge "Suppress su access to pdx sockets" into oc-dr1-dev 2017-06-27 22:21:27 +00:00
TreeHugger Robot
7b065f82a7 Merge "dexoptanalyzer: suppress access(2) denial" into oc-dr1-dev 2017-06-27 20:20:15 +00:00
Jeff Vander Stoep
4b7cf4fba1 Suppress su access to pdx sockets
Su runs in permissive mode and denials should be suppressed.

avc: denied { getattr } for scontext=u:r:su:s0
tcontext=u:object_r:pdx_display_client_endpoint_socket:s0
tclass=unix_stream_socket permissive=1
avc: denied { getattr } for scontext=u:r:su:s0
tcontext=u:object_r:pdx_display_manager_endpoint_socket:s0
tclass=unix_stream_socket permissive=1
avc: denied { getattr } for scontext=u:r:su:s0
tcontext=u:object_r:pdx_display_vsync_endpoint_socket:s0
tclass=unix_stream_socket permissive=1
avc: denied { getattr } for scontext=u:r:su:s0
tcontext=u:object_r:pdx_bufferhub_client_endpoint_socket:s0
tclass=unix_stream_socket permissive=1
avc: denied { getattr } for scontext=u:r:su:s0
tcontext=u:object_r:pdx_performance_client_endpoint_socket:s0
tclass=unix_stream_socket permissive=1

Bug: 35197529
Test: policy builds
Change-Id: Ia643c6e776e5e5bd473d857d523c3be91d32c40a
2017-06-26 16:33:14 -07:00
Jeff Vander Stoep
575e627081 dexoptanalyzer: suppress access(2) denial
A legitimate call to access(2) is generating a denial. Use the
audit_access permission to suppress the denial on just the access()
call.

avc: denied { write } for name="verified_jars"
scontext=u:r:dexoptanalyzer:s0
tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir

Bug: 62597207
Test: build policy
Test: The following cmd succeeds but no longer generates a denial
    adb shell cmd package compile -r bg-dexopt --secondary-dex \
    com.google.android.googlequicksearchbox

Change-Id: I7d03df2754c24c039bce11426bf8f317232f5e5f
2017-06-26 15:08:37 -07:00
Jeff Vander Stoep
a128aca6c9 Add another extraneous neverallow rule to force attribute inclusion
am: c75aa50d5d

Change-Id: I39eecd67a97de193d53ab298a1ef3e8443bb9391
2017-06-26 22:00:37 +00:00
Jeff Vander Stoep
c75aa50d5d Add another extraneous neverallow rule to force attribute inclusion
Due to the massively increased number of attributes in SELinux policy
as part of the treble changes, we have had to remove attributes from
policy for performance reasons.  Unfortunately, some attributes are
required to be in policy to ensure that our neverallow rules are being
properly enforced.  Usually this is not a problem, since neverallow rules
indicate that an attribute should be kept, but this is not currently the
case when the attribute is part of a negation in a group.

This is particularly problematic with treble since some attributes may
exist for HALs that have no implementation, and thus no types.  In
particular, this has caused an issue with the neverallows added in our
macros.  Add an extraneous neverallow rule to each of those auto-generated
neverallow rules to make sure that they are not removed from policy, until
the policy compiler is fixed to avoid this.  Also add corresponding rules
for other types which have been removed due to no corresponding rules.

Bug: 62658302
Bug: 62999603
Test: Build Marlin policy.
Test: verify attribute exists in policy using sepolicy-analyze.
    sepolicy-analyze $OUT/vendor/etc/selinux/precompiled_sepolicy \
    attribute hal_tetheroffload_server
Test: CTS neverallow tests pass.
    cts-tradefed run cts -m CtsSecurityHostTestCases -t \
    android.cts.security.SELinuxNeverallowRulesTest
Change-Id: I62596ba8198ffdcbb4315df639a834e4becaf249
2017-06-26 10:32:18 -07:00
TreeHugger Robot
25578a3096 Merge "system_server is a client of configstore" into oc-dr1-dev 2017-06-23 21:32:13 +00:00
Jeff Vander Stoep
23e0a7f23a system_server is a client of configstore
avc:  denied  { find } for
interface=android.hardware.configstore::ISurfaceFlingerConfigs
scontext=u:r:system_server:s0
tcontext=u:object_r:hal_configstore_ISurfaceFlingerConfigs:s0
tclass=hwservice_manager permissive=0

Bug: 35197529
Test: Device boots without this denial
Change-Id: Ia43bc5879e03a1f2056e373b17cc6533636f98b1
2017-06-23 11:20:20 -07:00
Narayan Kamath
034f5840a2 DO NOT MERGE ANYWHERE Revert "SEPolicy: Changes for new stack dumping scheme."
NOTE: This change is marked dnma because we don't want it on
oc-dr1-dev-plus-aosp or any other downstream branch. Moreover,
oc-dr1-dev-plus-aosp is the only outgoing merger from oc-dr1-dev for
this project.

This reverts commit 11bfcc1e96.

Bug: 62908344
Test: make
Change-Id: Ide61829cf99f15777c46f657a0e140d594f88243
2017-06-23 17:36:26 +01:00
Sandeep Patil
ed27bec522 Merge "Revert "Annotate rild with socket_between_core_and_vendor_violators"" into oc-dev
am: 0e0ed156ea

Change-Id: I8ec0c46355507e8c1a7d10c53805eb350ebbe6a5
2017-06-22 00:38:43 +00:00
TreeHugger Robot
0e0ed156ea Merge "Revert "Annotate rild with socket_between_core_and_vendor_violators"" into oc-dev 2017-06-22 00:35:08 +00:00
Jeff Vander Stoep
d9301ac6fa Merge "Exempt tetheroffload hal from network socket restrictions" into oc-dev
am: 6351c374c2

Change-Id: I6e661aa37702c36e9003dcf41dbed4b754122c87
2017-06-21 23:32:08 +00:00
TreeHugger Robot
6351c374c2 Merge "Exempt tetheroffload hal from network socket restrictions" into oc-dev 2017-06-21 23:26:22 +00:00
Sandeep Patil
3a9391152f Revert "Annotate rild with socket_between_core_and_vendor_violators"
This reverts commit 57e9946fb7.

Bug: 62616897
Test: choosecombo 1 aosp_arm64_ab userdebug; m -j 80 The build should
    not break.

Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-06-21 15:30:56 -07:00
Dan Cashman
044d20729b Remove neverallow preventing hwservice access for apps.
am: 3e307a4de5

Change-Id: Ic144d924948d7b8e73939806d761d27337dbebef
2017-06-21 21:38:19 +00:00
Jeff Vander Stoep
d75a2c0cc8 Exempt tetheroffload hal from network socket restrictions
The tetheroffload hal must be able to use network sockets as part of
its job.

Bug: 62870833
Test: neverallow-only change builds.
Change-Id: I630b36340796a5ecb5db08e732b0978dd82835c7
2017-06-21 12:46:21 -07:00
Dan Cashman
3e307a4de5 Remove neverallow preventing hwservice access for apps.
Same-process HALs are forbidden except for very specific HALs that have
been provided and whitelisted by AOSP.  As a result, a vendor extension
HAL may have a need to be accessed by untrusted_app.  This is still
discouraged, and the existing AOSP hwservices are still forbidden, but
remove the blanket prohibition.  Also indicate that this is temporary,
and that partners should expect to get exceptions to the rule into AOSP
in the future.

Bug: 62806062
Test: neverallow-only change builds.  Verify new attribute is in policy.
Change-Id: I6d3e659147d509a3503c2c9e0b6bb9016cc75832
2017-06-21 12:30:36 -07:00
Yabin Cui
eb5542a178 Allow run-as to read/write unix_stream_sockets created by adbd.
am: 330d447778

Change-Id: I6569c282114ceb09471d94cfa178535ab315c966
2017-06-20 22:56:12 +00:00
Yabin Cui
330d447778 Allow run-as to read/write unix_stream_sockets created by adbd.
This is to Allow commands like `adb shell run-as ...`.

Bug: http://b/62358246
Test: run commands manually.
Change-Id: I7bb6c79a6e27ff1224a80c6ddeffb7f27f492bb2
(cherry picked from commit 1847a38b4a)
2017-06-20 13:50:54 -07:00
Tom Cherry
0e6a3d87e9 Merge "Add getpgid to system_service and init" into oc-dr1-dev 2017-06-19 20:38:37 +00:00
Tom Cherry
d5f0aba025 Add getpgid to system_service and init
In libprocessgroup, we want to only send signals once to processes,
particularly for SIGTERM.  We must send the signal both to all
processes within a POSIX process group and a cgroup.  To ensure that
we do not duplicate the signals being sent, we check the processes in
the cgroup to see if they're in the POSIX process groups that we're
killing.  If they are, we skip sending a second signal.  This requires
getpgid permissions, hence this SELinux change.

avc: denied { getpgid } for pid=797 comm="ActivityManager" scontext=u:r:system_server:s0 tcontext=u:r:untrusted_app_25:s0:c512,c768 tclass=process permissive=1
avc: denied { getpgid } for pid=797 comm="ActivityManager" scontext=u:r:system_server:s0 tcontext=u:r:untrusted_app_25:s0:c512,c768 tclass=process permissive=1
avc: denied { getpgid } for pid=797 comm="ActivityManager" scontext=u:r:system_server:s0 tcontext=u:r:system_app:s0 tclass=process permissive=1
avc: denied { getpgid } for pid=797 comm="ActivityManager" scontext=u:r:system_server:s0 tcontext=u:r:system_app:s0 tclass=process permissive=1
avc: denied { getpgid } for pid=1 comm="init" scontext=u:r:init:s0 tcontext=u:r:zygote:s0 tclass=process permissive=1
avc: denied { getpgid } for pid=1 comm="init" scontext=u:r:init:s0 tcontext=u:r:zygote:s0 tclass=process permissive=1
avc: denied { getpgid } for pid=1 comm="init" scontext=u:r:init:s0 tcontext=u:r:system_server:s0 tclass=process permissive=1
avc: denied { getpgid } for pid=1 comm="init" scontext=u:r:init:s0 tcontext=u:r:system_server:s0 tclass=process permissive=1

Bug: 37853905
Bug: 62418791
Test: Boot, kill zygote, reboot
Change-Id: Ib6c265dbaac8833c47145ae28fb6594ca8545570
(cherry picked from commit c59eb4d853)
2017-06-19 11:26:48 -07:00
TreeHugger Robot
1468f85f33 Merge "Suppress safetynet denials" into oc-dr1-dev 2017-06-16 22:17:53 +00:00
Daniel Rosenberg
39c4f76ba6 Merge "Add rules for vfat for sdcardfs" into oc-dev
am: 58d0d1e4af

Change-Id: I1a2207be3509ec5bc7797b906e15da16099190ad
2017-06-16 22:04:07 +00:00
TreeHugger Robot
58d0d1e4af Merge "Add rules for vfat for sdcardfs" into oc-dev 2017-06-16 21:53:42 +00:00
Dan Cashman
2f2fd36539 Merge "Add extraneous neverallow rule to enforce attribute inclusion." into oc-dev
am: b5aeaf6dfa

Change-Id: Ib0ac9cf10c7cb9fd2462e0036307e2552d19b93b
2017-06-16 20:46:00 +00:00
TreeHugger Robot
d4faa3ced0 Merge "DO NOT MERGE. Restore property to match oc-dev." into oc-dr1-dev 2017-06-16 20:42:33 +00:00
TreeHugger Robot
b5aeaf6dfa Merge "Add extraneous neverallow rule to enforce attribute inclusion." into oc-dev 2017-06-16 20:37:52 +00:00
Daniel Rosenberg
260a4485f3 Add rules for vfat for sdcardfs
This adds parellel rules to the ones added for media_rw_data_file
to allow apps to access vfat under sdcardfs. This should be reverted
if sdcardfs is modified to alter the secontext it used for access to
the lower filesystem

Change-Id: Idb123206ed2fac3ead88b0c1ed0b66952597ac65
Bug: 62584229
Test: Run android.appsecurity.cts.ExternalStorageHostTest with
      an external card formated as vfat
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2017-06-16 19:47:33 +00:00
Dan Cashman
939b50ff61 Add extraneous neverallow rule to enforce attribute inclusion.
Due to the massively increased number of attributes in SELinux policy
as part of the treble changes, we have had to remove attributes from
policy for performance reasons.  Unfortunately, some attributes are
required to be in policy to ensure that our neverallow rules are being
properly enforced.  Usually this is not a problem, since neverallow rules
indicate that an attribute should be kept, but this is not currently the
case when the attribute is part of a negation in a group.

This is particularly problematic with treble since some attributes may
exist for HALs that have no implementation, and thus no types.  In
particular, this has caused an issue with the neverallows added in our
macros.  Add an extraneous neverallow rule to each of those auto-generated
neverallow rules to make sure that they are not removed from policy, until
the policy compiler is fixed to avoid this.  Also add corresponding rules
for other types which have been removed due to no corresponding rules.

Bug: 62591065
Bug: 62658302
Test: Attributes present in policy and CTS passes.  sepolicy-analyze also
works on platform-only policy.
Change-Id: Ic3fc034cdbd04a94167f8240cf562297e8d7c762
2017-06-16 11:19:53 -07:00
Sandeep Patil
97a4c1c9ca Merge changes from topic 'fix-neverallow-violation' into oc-dev
am: 3692b3189e

Change-Id: I8affb6f117f842ebdf083ec24083e190dde0082a
2017-06-16 17:22:46 +00:00
Sandeep Patil
516d855524 radio: disalllow radio and rild socket for treble devices
am: d3381cd9e6

Change-Id: I33215b5c9d894823f3928742a8712ef42d803156
2017-06-16 17:22:42 +00:00
Sandeep Patil
3692b3189e Merge changes from topic 'fix-neverallow-violation' into oc-dev
* changes:
  build: run neverallow checks on platform sepolicy
  radio: disalllow radio and rild socket for treble devices
2017-06-16 17:14:31 +00:00
Dan Cashman
9d448b915d DO NOT MERGE. Restore property to match oc-dev.
CTS checks to make sure that the _contexts files on a device have
a superset of the AOSP entries.  This was removed due to concurrent
master and DR development.  Restore the entry to allow CTS to pass.

Bug: 38241921
Bug: 62348859
Test: Policy builds and is identical to oc-dev for prop ctxts.
Change-Id: I87ccbee7aadee57b8e46ede73280810362b618c0
2017-06-15 15:07:48 -07:00
Jeff Vander Stoep
6e88ebf4b9 Suppress safetynet denials
Clean up ~50 denials such as:
avc: denied { getattr } for comm="highpool[2]" path="/system/bin/bufferhubd" dev="dm-0" ino=1029 scontext=u:r:priv_app:s0:c522,c768 tcontext=u:object_r:bufferhubd_exec:s0 tclass=file
avc: denied { getattr } for comm="highpool[3]" path="/system/bin/cppreopts.sh" dev="dm-0" ino=2166 scontext=u:r:priv_app:s0:c512,c768 tcontext=u:object_r:cppreopts_exec:s0 tclass=file
avc: denied { getattr } for comm="CTION_IDLE_MODE" path="/system/bin/fsck.f2fs" dev="dm-0" ino=1055 scontext=u:r:priv_app:s0:c522,c768 tcontext=u:object_r:fsck_exec:s0 tclass=file

Bug: 62602225
Bug: 62485981
Test: build policy
Change-Id: I5fbc84fb6c97c325344ac95ffb09fb0cfcb90b95
2017-06-15 13:17:56 -07:00
Carmen Jackson
d651e0b79b Add debug selinux permission to write saved_cmdlines_size.
am: e9381d5e01

Change-Id: I784011fc804dd43f431be62804761b100846dfbf
2017-06-14 23:35:38 +00:00
Carmen Jackson
e9381d5e01 Add debug selinux permission to write saved_cmdlines_size.
Now that we're expected to use this when taking traces, we need to add
this permission so that Traceur can also access this file.

Test: Used Traceur and saw the traces appear in the bugreports
directory, as expected.
Bug: 62493544

Change-Id: Ib4304176abbb51e2e3b45c566ff14574e1cfaa82
Merged-In: I464b0df30fabfc5f1c7cd7430e53e8d04bfacb53
(this merged-in is not the same change; it's a conflicting change in
master)
2017-06-14 14:12:43 -07:00
Sandeep Patil
cfb6f35231 build: run neverallow checks on platform sepolicy
This will prevent us from breaking our own neverallow rules
in the platform sepolicy regardless of vendor policy adding
exceptions to the neverallow rules using "*_violators" attributes

Bug: 62616897
Bug: 62343727

Test: Build policy for sailfish
Test: Build policy with radio to rild socket rule enabled for all
      and ensure the build fails

Change-Id: Ic66ec3e10c76a7c9a17669e0d3deb3a1c7b00809
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-06-14 10:01:34 -07:00
Sandeep Patil
d3381cd9e6 radio: disalllow radio and rild socket for treble devices
This violates the socket comms ban between coredomain (radio) and
non coredomain (rild) in the platform policy.

Bug: 62616897
Bug: 62343727

Test: Build and boot sailfish

Change-Id: I48303bbd8b6eb62c120a551d0f584b9733fc2d43
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-06-14 09:42:21 -07:00
Jeff Vander Stoep
5c38368896 Build split file_contexts for recovery
am: b236eb6ca2

Change-Id: I87eb8bad11fc9c011289b8d97219835a08d18cd1
2017-06-13 18:00:06 +00:00
Jeff Vander Stoep
b236eb6ca2 Build split file_contexts for recovery
[    7.674739] selinux: selinux_android_file_context: Error getting
file context handle (No such file or directory)

Bug: 62564629
Test: build and flash marlin. Successfully switch between regular
    and recovery modes

Change-Id: I0f871f8842d95322c844fb7b13ad1b4b42578e35
2017-06-13 15:38:55 +00:00
Jeff Vander Stoep
aee782caf7 Move non-treble devices to split file_contexts
am: 7a68c5ae4c

Change-Id: Ic9f658984340b255114bb0f8d505fa6774f1cb04
2017-06-12 22:14:28 +00:00
Jeff Vander Stoep
7a68c5ae4c Move non-treble devices to split file_contexts
This change is primarily to fix CTS which checks file ordering of
file_contexts. Having two separate means of loading file_contexts
has resulted in ordering variations.

Previously the binary file_contexts was preferred since it
loaded faster. However with the move to libpcre2, there is no
difference in loading time between text and binary file_contexts.
This leaves us with build system complexity with no benefit.
Thus removing this unnecessary difference between devices.

Bug: 38502071
Test: build and boot non-Treble Bullhead, run CTS tests below
Test: build and boot Treble Marlin, run CTS tests below
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
Test: cts-tradefed run singleCommand cts --skip-device-info \
    --skip-preconditions --skip-connectivity-check --abi arm64-v8a \
    --module CtsSecurityHostTestCases \
    -t android.security.cts.SELinuxHostTest#testValidFileContexts
Change-Id: I088b3aeafaaab320f6658feb058a1fb89cbb65e1
2017-06-10 15:14:10 +00:00
Jeff Vander Stoep
f965a0a176 Move non-treble devices to split file_contexts
This change is primarily to fix CTS which checks file ordering of
file_contexts. Having two separate means of loading file_contexts
has resulted in ordering variations.

Previously the binary file_contexts was preferred since it
loaded faster. However with the move to libpcre2, there is no
difference in loading time between text and binary file_contexts.
This leaves us with build system complexity with no benefit.
Thus removing this unnecessary difference between devices.

Bug: 38502071
Test: build and boot non-Treble Bullhead, run CTS tests below
Test: build and boot Treble Marlin, run CTS tests below
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
Test: cts-tradefed run singleCommand cts --skip-device-info \
    --skip-preconditions --skip-connectivity-check --abi arm64-v8a \
    --module CtsSecurityHostTestCases \
    -t android.security.cts.SELinuxHostTest#testValidFileContexts
Change-Id: I088b3aeafaaab320f6658feb058a1fb89cbb65e1
2017-06-10 14:30:57 +00:00
Jerry Zhang
6aa9869a41 Merge "Revert "Split mediaprovider from priv_app."" into oc-dr1-dev 2017-06-10 00:03:13 +00:00
Dan Cashman
96c619c826 DO NOT MERGE. Revert "Enable the TimeZoneManagerService"
This reverts commit 50889ce0eb.

Bug: 62427402
Test: Build and boot.
Change-Id: I32eae7997c901981d3228b61f33322a7c2c84301
2017-06-08 14:43:40 -07:00
Jerry Zhang
cb5129f9de Revert "Split mediaprovider from priv_app."
This reverts commit c147b592b8.

The new domain changed neverallows, breaking CTS compatability.
Revert the domain now, with the intention to re-add for the next
release.

Bug: 62102757
Test: domain is set to priv_app
Change-Id: I907ff7c513cd642a306e3eaed3937352ced90005
2017-06-07 18:20:20 -07:00