Commit graph

148 commits

Author SHA1 Message Date
Stephen Smalley
6d7c6942de Merge "sepolicy: Define and allow map permission" am: 770214abda am: 90f46dd922 am: 5724715380
am: 090a64a5d5

Change-Id: Ifc68054ff2ba4333b9d73adda6db37f533a78989
2017-07-13 17:12:31 +00:00
Stephen Smalley
090a64a5d5 Merge "sepolicy: Define and allow map permission" am: 770214abda am: 90f46dd922
am: 5724715380

Change-Id: Iadf138fc64bad940308cb01b3a3b8159b8b33704
2017-07-13 17:09:30 +00:00
Stephen Smalley
90f46dd922 Merge "sepolicy: Define and allow map permission"
am: 770214abda

Change-Id: I253dad49662831625a17162b18f013e0b4a87af4
2017-07-13 17:04:02 +00: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
Robert Benea
93166cefce resolve merge conflicts of 0040d6f0 to master
Test: I solemnly swear I tested this conflict resolution.
Change-Id: Icf1e8ad95c40f497c731fa03dfd09d8b2c132aca
2017-07-11 12:55:12 -07:00
Stephen Smalley
4397f08288 sepolicy: Define and allow map permission
Kernel commit 3ba4bf5f1e2c ("selinux: add a map permission check for mmap")
added a map permission check on mmap so that we can
distinguish memory mapped access (since it has different implications
for revocation).  The purpose of a separate map permission check on
mmap(2) is to permit policy to prohibit memory mapping of specific files
for which we need to ensure that every access is revalidated, particularly
useful for scenarios where we expect the file to be relabeled at runtime
in order to reflect state changes (e.g. cross-domain solution, assured
pipeline without data copying).  The kernel commit is anticipated to
be included in Linux 4.13.

This change defines map permission for the Android policy.  It mirrors
the definition in the kernel classmap by adding it to the common
definitions for files and sockets.  This will break compatibility for
kernels that predate the dynamic class/perm mapping support (< 2.6.33);
on such kernels, one would instead need to add map permission
to the end of each file and socket access vector.

This change also adds map permission to the global macro definitions for
file permissions, thereby allowing it in any allow rule that uses these
macros, and to specific rules allowing mapping of files from /system
and executable types. This should cover most cases where it is needed,
although it may still need to be added to specific allow rules when the
global macros are not used.

Test: Policy builds

Change-Id: Iab3ccd2b6587618e68ecab58218838749fe5e7f5
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2017-07-10 16:31:23 -04:00
Jeff Vander Stoep
d006aea03f Merge "Preserve attributes needed for CTS" into oc-dr1-dev
am: 1eff641730

Change-Id: I095df5cbd680d495fac54186ab16e2287d454c3a
2017-07-06 16:38:13 +00:00
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
Jeff Vander Stoep
bf8ed096e3 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
Change-Id: I989def70a16f66e7a18bef1191510793fbe9cb8c
2017-07-05 16:04:44 -07:00
TreeHugger Robot
724e825a62 Merge "cas: add CAS hal and switch to use hwservice" 2017-06-28 20:37:18 +00: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
Dan Cashman
9ba4e8f80c Merge "Add extraneous neverallow rule to enforce attribute inclusion." into oc-dev am: b5aeaf6dfa am: 6f94efafd8
am: 3b2bf73db6

Change-Id: I666e91ca83ad916b04c325d4f75570d550fc0c61
2017-06-16 21:13:14 +00:00
Dan Cashman
3b2bf73db6 Merge "Add extraneous neverallow rule to enforce attribute inclusion." into oc-dev am: b5aeaf6dfa
am: 6f94efafd8

Change-Id: I1aceeeb61ca9e558dd32b3ef33e07b6a551387e6
2017-06-16 20:51:50 +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
Dan Cashman
6f94efafd8 Merge "Add extraneous neverallow rule to enforce attribute inclusion." into oc-dev
am: b5aeaf6dfa

Change-Id: Ibcf17f7bbea4923abc5d1713227568bb35c6674b
2017-06-16 20:45:50 +00:00
Chong Zhang
78e595deab cas: add CAS hal and switch to use hwservice
bug: 22804304

Change-Id: I7162905d698943d127aa52804396e4765498d028
2017-06-16 13:28:36 -07: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
Tim Murray
86cb521502 sepolicy: fix support for lmkd
Allow lmkd to access /dev/memcg once again.

Test: lmkd can access memcg
bug 36588803

Change-Id: I47b4e79260bcd2967d85d8151c83e624d432f409
2017-06-13 21:07:53 -07:00
Andrew Scull
b17b763711 Allow bootctl HAL to access misc block device. am: b0d59450ae
am: 7c4f46b5c1

Change-Id: I88aa64b8847456f66310d632ee86929a76dfaf7b
2017-06-01 18:59:29 +00:00
Andrew Scull
7c4f46b5c1 Allow bootctl HAL to access misc block device.
am: b0d59450ae

Change-Id: If85613b84aecf43b0519bb933d925eb1829e3d5e
2017-06-01 18:39:31 +00:00
Andrew Scull
b0d59450ae Allow bootctl HAL to access misc block device.
This is sometimes used for communication with the bootloader.

Bug: 62052545
Test: Build
Change-Id: I3ae37793407719e55ab0830129aa569c9018f7da
2017-05-31 16:00:28 +01: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
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
14847b075b Merge "SELinux policies for PDX services" into oc-dev
am: 7e6176400b

Change-Id: Idefee5498a277bd5b507e648ff41bdc02aa0d752
2017-05-11 18:33:26 +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
Nick Kralevich
aa365288ef system_server: drop dalvikcache_data_file execute.
With build/core eaa9d88cf, system_server should not be loading code
from /data.

https://bugs.chromium.org/p/project-zero/issues/detail?id=955

Bug: 37214733
Bug: 31780877
Test: Device boots and no obvious problems.
Test: No collected SELinux denials for build-server generated builds.
Change-Id: I37b1e9e6c4555c937730ab491b6c38801b38ad38
2017-05-04 08:54:58 -07:00
Jeff Vander Stoep
ea9d1b1f68 Merge "Add default label and mapping for vendor services" into oc-dev
am: 74a96734a9

Change-Id: Id1a20ebb9c2bd1dfa6edcb11354bcb3e525e3f04
2017-04-29 18:09:52 +00:00
TreeHugger Robot
74a96734a9 Merge "Add default label and mapping for vendor services" into oc-dev 2017-04-29 18:05:30 +00:00
TreeHugger Robot
02bbb402e0 Merge "Add default label and mapping for vendor services" 2017-04-28 22:30:52 +00:00
Jeff Vander Stoep
082eae4e51 Add default label and mapping for vendor services
Adding the default label/mapping is important because:
1.  Lookups of services without an selinux label should generate
    a denial.
2.  In permissive mode, lookups of a service without a label should be
    be allowed, without the default label service manager disallows
    access.
3.  We can neverallow use of the default label.

Bug: 37762790
Test: Build and flash policy onto Marlin with unlabeled vendor services.
    Add/find of unlabeled vendor services generate a denial.

Change-Id: I66531deedc3f9b79616f5d0681c87ed66aca5b80
(cherry picked from commit 639a2b842c)
2017-04-28 14:56:57 -07:00
Jeff Vander Stoep
639a2b842c Add default label and mapping for vendor services
Adding the default label/mapping is important because:
1.  Lookups of services without an selinux label should generate
    a denial.
2.  In permissive mode, lookups of a service without a label should be
    be allowed, without the default label service manager disallows
    access.
3.  We can neverallow use of the default label.

Bug: 37762790
Test: Build and flash policy onto Marlin with unlabeled vendor services.
    Add/find of unlabeled vendor services generate a denial.

Change-Id: I66531deedc3f9b79616f5d0681c87ed66aca5b80
2017-04-28 14:00:10 -07:00
Jaekyun Seok
a8c23ee1ee Merge "Allow installd to read vendor_overlay_file" into oc-dev am: 9829506c25
am: 59be4ad535

Change-Id: I67c7b07a91f117870b104bc917206fda9423715f
2017-04-26 22:16:29 +00:00
Jaekyun Seok
59be4ad535 Merge "Allow installd to read vendor_overlay_file" into oc-dev
am: 9829506c25

Change-Id: I7a05cbb58ebbe4d23c9fc13ef429b444301a912e
2017-04-26 22:04:31 +00:00
TreeHugger Robot
9829506c25 Merge "Allow installd to read vendor_overlay_file" into oc-dev 2017-04-26 21:50:16 +00:00
Nick Kralevich
0671abc35f Merge "relax fuse_device neverallow rules" into oc-dev am: c78db706d4
am: 7acd15174a

Change-Id: Ib7b56576f037048614998e655b0b6a9ca5f71a02
2017-04-26 21:44:09 +00:00
Nick Kralevich
7acd15174a Merge "relax fuse_device neverallow rules" into oc-dev
am: c78db706d4

Change-Id: I7b866f588980ebb068629e326155976629bf2223
2017-04-26 21:23:03 +00:00
TreeHugger Robot
c78db706d4 Merge "relax fuse_device neverallow rules" into oc-dev 2017-04-26 21:12:56 +00:00
Nick Kralevich
45766d4178 relax fuse_device neverallow rules
The fuse_device neverallow rules are too aggressive and are inhibiting
certain vendor customizations. Relax the /dev/fuse neverallow rules so
that they better reflect the security invariants we want to uphold.

Bug: 37496487
Test: policy compiles.
Change-Id: Ie73b0ba7c76446afc2a7a23ebed1275c977d932d
2017-04-26 11:43:40 -07:00
Daniel Nicoara
3818e4f528 Merge "Remove rules blocking vrcore_app to connect to VR HWC and VirtualTouchpad" into oc-dev am: a5647da327
am: 8784e1e738

Change-Id: Ie065c69ad1c0b97265d9cb1f520902fc19d27f6c
2017-04-26 18:24:21 +00:00
Daniel Nicoara
8784e1e738 Merge "Remove rules blocking vrcore_app to connect to VR HWC and VirtualTouchpad" into oc-dev
am: a5647da327

Change-Id: I502e43626fd430da68f2a149704dafac024b3cc9
2017-04-26 18:05:11 +00:00
TreeHugger Robot
a5647da327 Merge "Remove rules blocking vrcore_app to connect to VR HWC and VirtualTouchpad" into oc-dev 2017-04-26 17:53:36 +00:00
Alex Klyubin
95c431d425 Merge "Assert ban on framework <-> vendor comms over VndBinder" into oc-dev am: a9d7b895da
am: cdcfb552ee

Change-Id: Ifdcd2bb2bb5bc8168951dcb0039ee7e543984015
2017-04-26 04:54:52 +00:00
Alex Klyubin
cdcfb552ee Merge "Assert ban on framework <-> vendor comms over VndBinder" into oc-dev
am: a9d7b895da

Change-Id: I040a1874e3a08510d9b7c9a107a149845dd1976c
2017-04-26 04:51:44 +00:00
Alex Klyubin
00657834b8 Assert ban on framework <-> vendor comms over VndBinder
This adds neverallow rules which enforce the prohibition on
communication between framework and vendor components over VendorBinder.
This prohibition is similar in spirit to the one for Binder
communications.

Most changes consist of adding neverallow rules, which do not affect
runtime behavior. The only change which does affect runtime behavior
is the change which takes away the right of servicemanager domain to
transfer Binder tokens to hwservicemanager and vndservicemanager. This
grant was there by accident (because it was overly broad) and is not
expected to be needed: servicemanager, hwservicemanager, and
vndservicemanager are not supposed to be communicating with each
other.

P. S. The new neverallow rules in app_neverallows.te are covered by
the new rules in domain.te. The rules were nevertheless added to
app_neverallows.te for consistency with other *Binder rules there.

Test: mmm system/sepolicy
Bug: 37663632
Change-Id: I7c2ae23924bf0f2fed3f1e3a8d4d603129286329
2017-04-25 14:15:52 -07:00
Alex Klyubin
18152ddc4f Assert apps can access only approved HwBinder services am: 2a7f4fb069
am: 7b021be44b

Change-Id: I0e93aecc3b40a3d00bfdea354fe9a4987b28fabb
2017-04-24 22:57:22 +00:00
Alex Klyubin
7b021be44b Assert apps can access only approved HwBinder services
am: 2a7f4fb069

Change-Id: Ia77557e2ef5aa124cb0d4a9e5f05300005a97bfd
2017-04-24 21:06:22 +00:00
Alex Klyubin
2a7f4fb069 Assert apps can access only approved HwBinder services
App domains which host arbitrary code must not have access to
arbitrary HwBinder services. Such access unnecessarily increases the
attack surface. The reason is twofold:
1. HwBinder servers do not perform client authentication because HIDL
   currently does not expose caller UID information and, even if it
   did, many HwBinder services either operate at a layer below that of
   apps (e.g., HALs) or must not rely on app identity for
   authorization. Thus, to be safe, the default assumption is that
   a HwBinder service treats all its clients as equally authorized to
   perform operations offered by the service.
2. HAL servers (a subset of HwBinder services) contain code with
   higher incidence rate of security issues than system/core
   components and have access to lower layes of the stack (all the way
   down to hardware) thus increasing opportunities for bypassing the
   Android security model.

HwBinder services offered by core components (as opposed to vendor
components) are considered safer because of point #2 above.

Always same-process aka always-passthrough HwBinder services are
considered safe for access by these apps. This is because these HALs
by definition do not offer any additional access beyond what its
client already as, because these services run in the process of the
client.

This commit thus introduces these two categories of HwBinder services
in neverallow rules.

Test: mmm system/sepolicy -- this does not change on-device policy
Bug: 34454312
Change-Id: I4f5f4dd10b3fc3bb9d262dda532d4a23dcdf061d
2017-04-24 10:15:31 -07:00
Alex Klyubin
fa57d41538 Tighten isolated_app -> *Binder policy
* isolated_app is no longer permitted to access /dev/hwbinder -- this
  was granted by mistake.
* There are now neverallows which enforce that isolated_app can't
  access HwBinder and VendorBinder.
* There are now neverallows which enforce that isolated_app can't add
  Binder and VendorBinder services to servicemanager and
  vndservicemanager.

Test: mmm system/sepolicy
Bug: 34454312
Change-Id: I8ba90a0dcb6a9fccd8f50c78cbd2409381376f7a
2017-04-21 18:09:01 -07:00