Commit graph

43 commits

Author SHA1 Message Date
Bowgo Tsai
0177004c7f Revert "Build userdebug_plat_sepolicy.cil with Android.bp"
This reverts commit 57b64bd282.

Because it breaks the usage of boot-debug.img and
vendor_boot-debug.img.

Bug: 185970130
Bug: 185990198
Test: make bootimage_debug
Change-Id: I2c7c4f9954540a9be301b3ed0a6c2f0af2019803
2021-04-22 09:55:21 +08:00
Inseob Kim
57b64bd282 Build userdebug_plat_sepolicy.cil with Android.bp
Bug: 33691272
Test: build and see $OUT/debug_ramdisk
Change-Id: I7994857a3dd4e54f2c2d35ff8e362ecae93ea7a2
2021-04-14 15:54:26 +09:00
Yi-Yo Chiang
a22511269f Change $(ver).compat.cil from prebuilt_etc to se_compat_cil
Use the new se_compat_cil module type to install compatibility cil
files.

Bug: 183362912
Test: Presubmit; Noop in terms of build artifact.
Change-Id: I5275e9ce524185ce2d228133763456df43834093
2021-04-13 02:58:21 +08:00
Yi-Yo Chiang
8be93c00b1 Add system_ext_$(ver).compat.cil
These are the system_ext counterpart of $(ver).compat.cil. They would
contain device specific compat rules that compliment $(ver).compat.cil,
which are the platform specific compat rules.

Bug: 183362912
Test: Add a $(ver).compat.cil under SYSTEM_EXT_PRIVATE_SEPOLICY_DIR and
  verify the file is installed under /system_ext/etc/selinux/mapping/
Change-Id: I2fb9b10bb3bcf112e33f504964fb705e3b63782b
2021-04-13 02:58:21 +08:00
Inseob Kim
39fbcf7c96 Add plat_vendor tag to se_build_files for microdroid
plat_vendor tag consists of vendor available policies in system/sepolicy
directory, and is for minimized vendor policies.

Bug: 33691272
Test: boot microdroid
Change-Id: Icb3c1be02ee41b526d7d95f0053e56bf8b34f49d
2021-04-05 09:50:47 +00:00
Inseob Kim
50375ce708 Migrate micordroid genrules to selinux module
Bug: 33691272
Test: boot microdroid, see selinux works
Change-Id: Ic360604edb1b75e94d06a7961ea60ea46a34aa68
2021-03-30 13:14:27 +09:00
Inseob Kim
039175bcfe Migrate mapping files to Android.bp
Bug: 33691272
Test: boot cf && boot microdroid && see precompiled sepolicy works
Change-Id: I92c9cb873506d24b335cc0fd489269df216280be
2021-03-25 07:42:52 +00:00
Inseob Kim
002d9262fa Update TODO bug number
Test: N/A
Change-Id: Ie0bece3d965274a1639365ad00323cfce4458d4b
2021-03-24 17:10:44 +09:00
Inseob Kim
a49e724038 Reland "Build platform side policy with Soong"
This reverts commit d869d02758.

Reason for revert: fixed breakage

The breakage was due to the difference between plat_sepolicy.conf and
microdroid_vendor_sepolicy.conf. Now vendor_sepolicy.conf is built with
se_policy_conf module, so it is synced with plat_sepolicy.conf

Test: boot microdroid with and without SANITIZE_TARGET=address
Change-Id: Ia7d79f5a1eba323b23682d2322a61159dd170441
2021-03-22 13:40:13 +09:00
Inseob Kim
d869d02758 Revert "Build platform side policy with Soong"
This reverts commit 7629e86053.

Reason for revert: broke build

Change-Id: I97dc1ea78901cab62404780e7ee096ad45c0b21b
2021-03-19 07:04:51 +00:00
Inseob Kim
7629e86053 Build platform side policy with Soong
This replaces the following policy files with Android.bp modules:

  - reqd_policy_mask.cil
  - plat_sepolicy.cil
  - system_ext_sepolicy.cil
  - product_sepolicy.cil
  - plat_pub_policy.cil
  - system_ext_pub_policy.cil
  - pub_policy.cil
  - general_sepolicy.conf (for CTS)

Also microdroid's system policy now uses above.

Bug: 33691272
Bug: 178993690
Test: policy files stay same
Test: boot normal device and microdroid, see sepolicy works
Test: build CtsSecurityHostTestCases
Change-Id: I908a33badee04fbbdadc6780aab52e989923ba57
2021-03-18 19:54:35 +09:00
Inseob Kim
619e4a7a82 Add se_build_files module
se_build_files module globs given srcs from sepolicy directories and
acts as a filegroup with the following tags, which can be used to build
system side policy files.

- plat
- plat_public
- system_ext
- system_ext_public
- product
- product_public
- reqd_mask

se_build_files module acts like the build_policy macro in Android.mk.
Normal genrule module can't easily handle that, because both file order
and directory order matter.

Support for vendor/odm is to be added in the future.

Bug: 33691272
Test: inspect se_build_files with above tags and compare it to ninja
Change-Id: Id7c57b01c78fc14ac5e8eeeb074a6fc21d271e84
2021-03-16 10:22:09 +09:00
Jiyong Park
cc9a09953b Fix a build error reguarding build_sepolicy
build_sepolicy internally uses other tools like checkpolicy and
version_policy. The dependencies are used to be found under
out/host/linux-x86/bin. But that assumption doesn't hold when soong
tried to sandbox command invocations. This change fixes the problem by
setting --android_host_path to the directory where build_sepolicy is
sandboxed and also by adding the internal dependeicies to the `tools`
property so that they are copied to the sandbox directory.

Bug: N/A
Test: choosecombo into aosp_x86_64 and run
m out/soong/.intermediates/system/sepolicy/microdroid_vendor_sepolicy.cil_gen/gen/vendor_sepolicy.cil

Change-Id: I28ae1f9013439f3ca1196b3816e0388ced5246e1
2021-03-04 00:02:15 +09:00
Jiyong Park
d89564e95d Reland "Build sepolicy files for microdroid_vendor"
This reverts commit 2c2c1f7c00.

Reason for revert: reland with a forward fix
Test: m on aosp_x86_64

Change-Id: I5c89ebeda88ca65286dff1e64841c2ada8634d34
2021-03-04 00:02:04 +09:00
Adrian Roos
2c2c1f7c00 Revert "Build sepolicy files for microdroid_vendor"
Revert submission 1609095-microdroid_vendor

Reason for revert: Breaks aosp_x86_64-userdebug build
Reverted Changes:
I82a66a00a:Add microdroid_vendor
I88eec6e1f:Build sepolicy files for microdroid_vendor

Bug: 180986662
Fixes: 181756343
Change-Id: Ie390d17ee99bae83fb98baaa3c3a1ca8d95c3919
2021-03-03 14:02:56 +00:00
Jiyong Park
db7a475f65 Build sepolicy files for microdroid_vendor
microdroid_vendor is the vendor.img for microdroid. We need
microdroid_vendor.img and sepolicy files in it because init demands the
files during the boot process. Since microdroid_vendor.img is a Soong
module, the sepolicy files in it should be built with Soong as well.

Note that, these Soong modules are configured only for microdroid. In
the future, we will generalize this so that ordinary Android can use
the Soong-build sepolicy files.

Bug: 180986662
Test: m microdroid_vendor
Change-Id: I88eec6e1fbf687301366d5c814265131c8d3fdbb
2021-02-26 21:52:13 +09:00
Inseob Kim
e35b49bd16 Add cil files to Android.bp for microdroid
Contexts files, plat_sepolicy.cil, and 10000.0.cil are needed to boot.
This adds cil files to microdroid. But cil files are temporary and only
for testing. We'll need to migrate real cil files to Android.bp.

Bug: 178993690
Test: boot microdroid
Change-Id: I711b1db39c11d88bc1f9defeff5799e6f24756ab
2021-02-22 14:36:25 +09:00
Bob Badour
601ebb43a3 [LSC] Add LOCAL_LICENSE_KINDS to system/sepolicy
Added SPDX-license-identifier-Apache-2.0 to:
  build/Android.bp
  build/soong/Android.bp
  tests/Android.bp
  tools/Android.bp

Added SPDX-license-identifier-Apache-2.0 legacy_unencumbered to:
  Android.bp
  Android.mk
  compat.mk
  contexts_tests.mk
  mac_permissions.mk
  seapp_contexts.mk
  treble_sepolicy_tests_for_release.mk

Added legacy_unencumbered to:
  apex/Android.bp
  tools/sepolicy-analyze/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: I1ab286543ef1bdcb494cf74f2b35e35a08225d28
2021-02-05 01:28:24 -08:00
Janis Danisevskis
c40681f1b5 Add libselinux keystore_key backend.
We add a new back end for SELinux based keystore2_key namespaces.
This patch adds the rump policy and build system infrastructure
for installing keystore2_key context files on the target devices.

Bug: 158500146
Bug: 159466840
Test: None
Change-Id: I423c9e68ad259926e4a315d052dfda97fa502106
Merged-In: I423c9e68ad259926e4a315d052dfda97fa502106
2020-08-05 16:11:48 +00:00
Inseob Kim
ace36abec5 Add 30.0 mapping files
Steps taken to produce the mapping files:

1. Add prebuilts/api/30.0/plat_pub_versioned.cil from the
/vendor/etc/selinux/plat_pub_versioned.cil file built on rvc-dev with
lunch target aosp_arm64-eng. Add prebuilts/api/30.0/vendor_sepolicy.cil
as an empty file.

2. Add new file private/compat/30.0/30.0.cil by doing the following:
- copy /system/etc/selinux/mapping/30.0.cil from rvc-dev aosp_arm64-eng
device to private/compat/30.0/30.0.cil
- remove all attribute declaration statement (typeattribute ...) and
sort lines alphabetically
- some selinux types were added/renamed/deleted w.r.t 30 sepolicy.
Find all such types using treble_sepolicy_tests_30.0 test.
- for all these types figure out where to map them by looking at
29.0.[ignore.]cil files and add approprite entries to 30.0.[ignore.]cil.

This change also enables treble_sepolicy_tests_30.0 and installs
30.0.cil mapping file onto the device.

Bug: 153661471
Test: m treble_sepolicy_tests_30.0
Test: m 30.0_compat_test
Test: m selinux_policy
Change-Id: I6dfae41fbd5f245119ede540d2c321688d6e7929
2020-05-11 04:32:00 +00:00
yangbill
3e3453776f Adding file group for vts_treble_sys_prop_test.
Bug: 147720376
Test: m vts_treble_sys_prop_test
Change-Id: I81a0e21a989dd89f8c37adf5a5c739ca0bdfbac0
2020-04-22 12:43:22 +08:00
Tri Vo
6117855015 sepolicy: support /system_ext and /product mapping files
Install mapping files in SYSTEM_EXT_PRIVATE_POLICY and
PRODUCT_PRIVATE_POLICY into /system_ext and /product respectively.

Bug: 141084341
Test: boot taimen
Test: system mapping files are unchanged
Test: create mapping files in device/google/wahoo/sepolicy/ and check
that they are correctly expanded and installed.
Change-Id: I4d251c957b30a16df71eec47c871e24e5fc773a4
2019-10-11 12:32:12 -07:00
Bowgo Tsai
9823116355 Separate system_ext_service_contexts out of system sepolicy.
Bug: 137712473
Test: boot crosshatch
Change-Id: If483e7a99dc07f082dd0ecd0162a54140a3267de
2019-09-26 21:29:30 +08:00
Bowgo Tsai
1864cd02fc Separate system_ext_property_contexts out of system sepolicy.
Bug: 137712473
Test: boot crosshatch
Change-Id: I27db30edfd9948675793fdfec19081288f8017eb
2019-09-26 21:29:22 +08:00
Bowgo Tsai
241d36eedd Separate system_ext_hwservice_contexts out of system sepolicy.
Bug: 137712473
Test: boot crosshatch
Change-Id: Ic5774da74e200b9d7699ac2240a12e7616dc512a
2019-09-26 21:29:15 +08:00
Bowgo Tsai
86a048d4df Separate system_ext_file_contexts out of system sepolicy.
Bug: 137712473
Test: boot crosshatch
Change-Id: I09f63771d08ad18fb41fca801dd587b086be58c7
2019-09-26 21:28:07 +08:00
Tri Vo
e381deb759 sepolicy: fix 28.0.ignore.cil build
29.0.ignore.cil/29.0.cil should be expanded into
28.0.ignore.cil/28.0.cil, so that there is no need to duplicate changes
in both places.

Test: adding a type to 29.0.ignore.cil/29.0.cil only doesn't trigger a
build error.
Change-Id: I543c0fc5e3749211e5bede81aabb0b520435a510
2019-06-12 15:56:05 -07:00
Tri Vo
50aa029f4b Reland "Add 29.0 mapping files"
Steps taken to produce the mapping files:

1. Add prebuilts/api/29.0/[plat_pub_versioned.cil|vendor_sepolicy.cil]
plat_pub_versioned.cil contains all public attributes and types from Q
Leave vendor_sepolicy.cil is empty.

2. Add new file private/compat/29.0/29.0.cil by doing the following:
- copy /system/etc/selinux/mapping/29.0.cil from pi-dev aosp_arm64-eng
device to private/compat/29.0/29.0.cil
- remove all attribute declaration statement (typeattribute ...) and
sort lines alphabetically
- some selinux types were added/renamed/deleted w.r.t 29 sepolicy.
Find all such types using treble_sepolicy_tests_29.0 test.
- for all these types figure out where to map them by looking at
28.0.[ignore.]cil files and add approprite entries to 29.0.[ignore.]cil.

This change also enables treble_sepolicy_tests_29.0 and installs
29.0.cil mapping file onto the device.

Bug: 133155528
Bug: 133196056
Test: m treble_sepolicy_tests_29.0
Test: m 29.0_compat_test
Test: m selinux_policy
Change-Id: I9e83e9bf118c8b8f8fcf84d5c0dcb6eb588e0d55
2019-06-01 17:20:34 -07:00
Tri Vo
8043136f7f Revert "Add 29.0 mapping files"
This reverts commit 5702e9d758.

Reason for revert: breaks build

Change-Id: I2a1772545ec4aae8723ecce93c9bf9d49e905986
2019-05-29 01:10:07 +00:00
Tri Vo
5702e9d758 Add 29.0 mapping files
Steps taken to produce the mapping files:

1. Add prebuilts/api/29.0/[plat_pub_versioned.cil|vendor_sepolicy.cil]
plat_pub_versioned.cil contains all public attributes and types from Q
Leave vendor_sepolicy.cil is empty.

2. Add new file private/compat/29.0/29.0.cil by doing the following:
- copy /system/etc/selinux/mapping/29.0.cil from pi-dev aosp_arm64-eng
device to private/compat/29.0/29.0.cil
- remove all attribute declaration statement (typeattribute ...) and
sort lines alphabetically
- some selinux types were added/renamed/deleted w.r.t 29 sepolicy.
Find all such types using treble_sepolicy_tests_29.0 test.
- for all these types figure out where to map them by looking at
28.0.[ignore.]cil files and add approprite entries to 29.0.[ignore.]cil.

This change also enables treble_sepolicy_tests_29.0 and installs
29.0.cil mapping file onto the device.

Bug: 133155528
Bug: 133196056
Test: m treble_sepolicy_tests_29.0
Test: m 29.0_compat_test
Test: m selinux_policy
Change-Id: I59f6251e9baa6527a358dec024e9fae62388db2b
2019-05-26 14:28:40 -07:00
Jeff Vander Stoep
564e292ae6 Add mechanism for granting permissions to old vendor images
This addresses Treble backwards compat issues introduced in
aosp/793958 and aosp/783669.

Bug: 122874820
Test: build/flash blueline with pi-dev vendor and generic_ab system
    images.
Test: adb pull /sys/fs/selinux/policy;
    sesearch policy --allowx -s vendordomain -t dev_type

Change-Id: Ic2b304472bb88051e03740dc387834056aba641a
2019-05-06 12:32:51 -07:00
Inseob Kim
b554e594ca Build contexts files with Soong
This is to migrate sepolicy Makefiles into Soong. For the first part,
file_contexts, hwservice_contexts, property_contexts, and
service_contexts are migrated. Build-time tests for contexts files are
still in Makefile; they will also be done with Soong after porting the
module sepolicy.

The motivation of migrating is based on generating property_contexts
dynamically: if we were to amend contexts files at build time in the
future, it would be nicer to manage them in Soong. To do that, building
contexts files with Soong can be very helpful.

Bug: 127949646
Bug: 129377144
Test: 1) Build blueline-userdebug, flash, and boot.
Test: 2) Build blueline-userdebug with TARGET_FLATTEN_APEX=true, flash,
and boot.
Test: 3) Build aosp_arm-userdebug.

Change-Id: I576f6f20686f6f2121204f76657274696d652121
2019-04-25 09:59:28 +09:00
Jeff Vander Stoep
ecd288f41d Android.bp: set sepolicy version for use by init
Init needs to be aware of the policy version defined in sepolicy
for on-device compilation.

Bug: 124499219
Test: build and boot a device. Try both precompiled and on-device
compiled policy.

Change-Id: Iba861aeb4566405aedcbe3c2bad48e1e50126370
2019-03-14 17:49:14 +00:00
Jinguang Dong
e012569944 load selinux mapping ignore file in BOARD_PLAT_PRIVATE_SEPOLICY_DIR
Now it can only load selinux mapping ignore file in system/sepolicy/private,
But for google's partners, we want to add selinux mapping ignore file in BOARD_PLAT_PRIVATE_SEPOLICY_DIR.

Test: it can load load selinux mapping ignore file in BOARD_PLAT_PRIVATE_SEPOLICY_DIR
Change-Id: I983422c21fe027fcb17c175357a26845eb977669
2019-03-05 17:23:24 +08:00
Tri Vo
438684b39f Only maintain maps between current and previous selinux versions.
New maintenance scheme for mapping files:
Say, V is the current SELinux platform version, then at any point in time we
only maintain (V->V-1) mapping. (V->V-n) map is constructed from top (V->V-n+1)
and bottom (V-n+1->V-n) without changes to previously maintained mapping files.

Caveats:
- 26.0.cil doesn't technically represent 27.0->26.0 map, but rather
current->26.0. We'll fully migrate to the scheme with future releases.

Bug: 67510052
Test: adding new public type only requires changing the latest compat map
Change-Id: Iab5564e887ef2c8004cb493505dd56c6220c61f8
2018-10-02 15:10:13 -07:00
Jae Shin
1fa9634896 Add mapping files for 28.0.[ignore.]cil
Steps taken to produce the mapping files:

1. Add prebuilts/api/28.0/[plat_pub_versioned.cil|vendor_sepolicy.cil]
from the /vendor/etc/selinux/[plat_pub_versioned.cil|vendor_sepolicy.cil]
files built on pi-dev with lunch target aosp_arm64-eng

2. Add new file private/compat/28.0/28.0.cil by doing the following:
- copy /system/etc/selinux/mapping/28.0.cil from pi-dev aosp_arm64-eng
device to private/compat/28.0/28.0.cil
- remove all attribute declaration statement (typeattribute ...) and
sort lines alphabetically
- some selinux types were added/renamed/deleted w.r.t 28 sepolicy.
Find all such types using treble_sepolicy_tests_28.0 test.
- for all these types figure out where to map them by looking at
27.0.[ignore.]cil files and add approprite entries to 28.0.[ignore.]cil.

This change also enables treble_sepolicy_tests_28.0 and install 28.0.cil
mapping onto the device.

Bug: 72458734
Test: m selinux_policy
Change-Id: I90e17c0b43af436da4b62c16179c198b5c74002c
2018-07-18 20:08:38 -07:00
Tri Vo
84e247abeb Soong module for selinux files including board-specific directories.
se_filegroup is used to export selinux files from board-specific
directories (e.g. device/google/wahoo/sepolicy).

Use se_filegroup module to export partner extension of compatibility
mapping to build logic in system/sepolicy.

Bug: 33691272
Bug: 74669108
Test: .cil mapping files can be correctly added from vendor directory.
Change-Id: Iaa2a95d0e326cb03a478fc12c1a14ba40e57e117
2018-05-08 11:28:47 -07:00
Tri Vo
a5cfd3e537 Soong module selinux compat maps
And migrate 26.0.cil and 27.0.cil build targets from Android.mk to
Android.bp

Bug: 33691272
Test: 26.0.cil and 27.0.cil mapping files on the device are unchanged.
Change-Id: Id0ea45c149e096996bc0657615ea98915df3c9e1
2018-05-08 11:28:47 -07:00
Tri Vo
594488f8b0 Build sepolicy tools with Android.bp.
Bug: 33691272
Test: make clean && mmma system/sepolicy
Change-Id: I6bbd6271c375338e7d24cd6089c6f826080c98b6
2018-05-07 12:51:54 -07:00
Bowgo Tsai
741a70a058 Using a python script to build sepolicy
Current sepolicy CIL files are built by several command-line tools
in Android.mk. This change extracts some of the build logic into a
python script to relief the effort in Android.mk.

The first command is `build_sepolicy build_cil`. It's possible to add
more sub-commands under the build_sepolicy script in the future.

Bug: 64240127
Test: build bullhead/taimen
Change-Id: Ie0ae4fc5256a550c72954cde5d5dd213a22d159a
2018-02-05 18:22:12 +08:00
Bowgo Tsai
d0cbb90509 Revert "Using a python script to build sepolicy"
This reverts commit 3506ad3f31.
Fix angler/bullhead boot failure.

Bug: 72787689
Test: build
2018-02-02 08:00:38 +08:00
Bowgo Tsai
3506ad3f31 Using a python script to build sepolicy
Current sepolicy CIL files are built by several command-line tools
in Android.mk. This change extracts some of the build logic into a
python script to relief the effort in Android.mk.

The first command is `build_sepolicy build_cil`. It's possible to add
more sub-commands under the build_sepolicy script in the future.

Bug: 64240127
Test: build and boot a device
Test: checks the content of $OUT/vendor/etc/selinux/vendor_sepolicy.cil
      is the same as before
Change-Id: I0b64f1088f413172e97b579b4f7799fa392762df
2018-01-31 14:37:47 +08:00
Jeff Vander Stoep
bdfc0301a1 Verify correct application of labels and attributes
With project Treble, we're relying heavily on attributes for
permission inheritance and enforcement of separation between
platform and vendor components.

We neead tests that verify those attributes are correctly applied.
This change adds the framework for those tests including a wrapper
around libsepol for loading and querying policy, and a python module
for running tests on policy and file_contexts.

Included with the testing framework is a test asserting that the
coredomain attribute is only applied to core processes. This
verification is done using the following rules:
1. Domain's entrypoint is on /system - coredomain
2. Domain's entrypoint is on /vendor - not coredomain
3. Domain belongs to a whitelist of known coredomains - coredomain

In a subsequent commit these tests will be applied at build time.
However, I first need to fix existing Treble violations exposed by
this test. These tests will also be applied during CTS.

Test: LD_PRELOAD=$ANDROID_HOST_OUT/lib64/libsepolwrap.so python \
    treble.py -p $OUT/vendor/etc/selinux/precompiled_sepolicy \
    -f $OUT/vendor/etc/selinux/nonplat_file_contexts \
    -f $OUT/system/etc/selinux/plat_file_contexts
Bug: 37008075
Change-Id: I7825f5c2909a5801deaccf2bef2bfd227adb0ae9
(cherry picked from commit 0366afdf14)
2017-06-05 08:09:05 -07:00