Commit graph

110 commits

Author SHA1 Message Date
Inseob Kim
23c543c0ed Remove 1000000.0 mapping files
It's a workaround for -with-phones branch and redundant now.

Test: TH
Change-Id: I0ec9e00a8ee1e3c929f33cbba3b8339c7e42b885
2024-05-20 10:23:55 +09:00
Treehugger Robot
150b800c90 Merge "Add selinux_policy_system_soong phony module" into main 2024-04-23 01:14:44 +00:00
Inseob Kim
151562f645 Add selinux_policy_system_soong phony module
selinux_policy_system is in Android.mk. selinux_policy_system_soong is a
phony module in Android.bp for Soong built system images.

Bug: 329208946
Test: m aosp_cf_system_x86_64
Change-Id: If101155c5a706925d52593bab648b878b075f7f2
2024-04-19 10:36:36 +09:00
Inseob Kim
8697fc80fd Add macro for board API level guard
'starting_at_board_api' macro is added to guard system/sepolicy/public
types and attributes. The macro will work only when compiling vendor/odm
sepolicy. When compiling platform sepolicy (system / system_ext /
product), rules will always be included, regardless of board API level.

Policy authors should guard new public types and attributes with this
macro, similar to LLNDK. The new types and attributes will be exposed
since next vFRC release.

Bug: 330671090
Test: manually build with various board API level, see output
Change-Id: I03c601ce8fe1f77c7608dc488317d20276fd2d47
2024-04-19 10:33:38 +09:00
Inseob Kim
ff2018fa84 Fix bpfmt
Bug: N/A
Test: N/A
Flag: NONE trivial format change
Change-Id: I8f6293dcc47a4ead347c4861ba929d4b3042c311
2024-04-17 09:55:49 +09:00
Inseob Kim
4b9929e2fc Finalize prebuilt CTS artifacts
These three files, general_sepolicy.conf / mapping.cil /
plat_sepolicy.cil will be used to test vendor sepolicy's neverallow
rules.

Bug: 330671085
Test: build
Change-Id: I763c9a1e647d614b84c0f7fe3d69affbe64f6153
Merged-In: I763c9a1e647d614b84c0f7fe3d69affbe64f6153
(cherry picked from commit 6f18a17ff8)
2024-04-16 16:18:01 +09:00
Inseob Kim
e41e95e0ea Revert^2 "Add 1000000.0 mapping file temporarily"
82126e9d77

Change-Id: Ia2ef237d9918532f24cd00688ae2bc15196123e9
2024-02-13 02:19:24 +00:00
Ikjoon Jang
82126e9d77 Revert "Add 1000000.0 mapping file temporarily"
Revert submission 2952245-vfrc_as_tot_sepolicy

Reason for revert: DroidMonitor-triggered revert due to breakage https://android-build.corp.google.com/builds/quarterdeck?branch=git_main&target=mainline_modules_arm64-mainline-userdebug&lkgb=11421838&lkbb=11421957&fkbb=11421841, b/324335916

Reverted changes: /q/submissionid:2952245-vfrc_as_tot_sepolicy

Bug: 324335916
Change-Id: I9375f4d467596bc961527216b3f68c0f21016ca3
2024-02-08 02:54:29 +00:00
Inseob Kim
dd3910bbe6 Add 1000000.0 mapping file temporarily
Will be removed once new ToT (202404) propagates.

Bug: 314010177
Test: build and boot
Test: TH
Change-Id: I6913e953aa479eaf0be15ddf9fd8047b00d58fe3
2024-01-17 16:09:35 +09:00
Inseob Kim
6a03f9df6a Remove hack regarding vFRC versioning
Bug: 314010177
Test: TH
Change-Id: Ife9dfcda62ea61b7af6a34d19be2433820237d28
2024-01-05 01:02:18 +00:00
Inseob Kim
3e34b72f9c Change sepolicy version format for vFRC
sepolicy versioning is for system <-> vendor compatibility. This changes
sepolicy version format from sdk version (e.g. 34.0) to vendor api
version (e.g. 202404.0).

Bug: 314010177
Test: build and boot
Change-Id: I2422c416b7fb85af64c8c835497bbecd2e10e2ab
2023-12-19 13:35:38 +09:00
Inseob Kim
3a9d91ce68 Add dev_type test
Files under /dev should have dev_type attribute.

Bug: 303367345
Test: m selinux_policy
Change-Id: Iaa1e39338e2fae32086bd770c6f3ab4b33bb82aa
2023-11-21 16:47:03 +09:00
Inseob Kim
085f22f82d Add macros to flag-guard te and contexts files
This adds two macros which can be used in te files and contexts files.

* is_flag_enabled(flag_name, codes)
* is_flag_disabled(flag_name, codes)

Also flag-guarding requires to process input files before any
validations. Property contexts test and seapp contexts test are
modified a little to handle that.

Bug: 306563735
Test: build with manual guarding
Change-Id: Ia1c6d00b7aab0da3901c19f16d553153aace018c
2023-11-09 16:05:17 +09:00
Garfield Tan
d8c51f24ce Add prebuilt_sepolicy_srcs filegroup
This allows OEM to get a copy of precompiled SEPolicy. This can be
useful when an OEM needs to bind-mount some of the Android partitions
across the VM boundary to ensure the correct labeling.

Bug: 301629552
Test: Presubmit builds should be enough.
Change-Id: I3339a7abfe2612993ee659fd5492c323aa895999
2023-10-04 17:39:32 -07:00
Thiébaud Weksteen
cc85f22c4d Remove com.android.sepolicy policy
Bug: 297794885
Test: presubmit
Change-Id: I91b1584fe2e13322cd3a0add92887097e190246e
2023-09-19 12:41:52 +10:00
Inseob Kim
5d7423ff3d Build prebuilt policy with Soong
... and remove redundant Makefile codes. This also updates commit hook
as we now only use Soong to build sepolicy.

Bug: 296875906
Test: m selinux_policy
Change-Id: I93f0d222a0c10e31c51c9380780a8927c47d62b1
2023-09-07 16:32:30 +09:00
Inseob Kim
36d9d39e6e Relax freeze_test to check only compatibility
For now, freeze_test compares prebuilts against sources with diff, to
ensure that sources are identical to prebuilts. However, it could be the
case that the branch should be able to build both REL and ToT. In that
case, changes to the sources are inevitable and the freeze test will
fail.

To fix the issue, freeze_test will now only check compatibility. To be
specific, it will check if any public types or attributes are removed.
Contexts files and neverallow rules are not checked, but they may be
added later. Also to support the new freeze_test

- build_files module is changed to use glob (because REL version won't
  be in compat versions list)
- plat_pub_policy modules are added under prebuilts/api (because
  freeze_test needs that)

Bug: 296875906
Test: m selinux_policy
Change-Id: I39c40992965b98664facea3b760d9d6be1f6b87e
2023-09-05 03:37:18 +00:00
Inseob Kim
6c6aa01ae4 Remove code about mixed sepolicy build
There is no one actively using mixed sepolicy build, and it made
sepolicy codes too complicated. As we are deprecating mixed build,
removing such code for cleanup.

Bug: 298305798
Test: boot cuttlefish
Change-Id: I8beedd5a281fa957532deecb857da4e1bb66992a
2023-08-31 16:54:17 +09:00
Inseob Kim
6c6f53b1a8 Use target specific intermediate paths
This won't be harmful and this can help reduce rebuilding sepolicy
artifacts upon lunch target change.

Bug: 279524023
Test: m selinux_policy
Change-Id: I859de6dc0ac1958b44d847159904960bd7f9a0c2
2023-04-27 11:11:48 +09:00
Sandro
3f5c18c213 Rename apex_sepolicy-decompiled.cil target
For symmetry with the apex_sepolicy-33.cil target

Bug: 218672709
Test: atest SeamendcHostTest
Change-Id: Iaec6eb4d5186ed0c7e872ef210ff572655e263b6
2022-09-07 15:04:59 +00:00
Inseob Kim
79fdbeb1ce Reorganize Android.bp files and modules
Test: build and boot
Change-Id: Id8a1a2faecf37de81b91e2669f6afa4cbe91443c
2022-08-17 09:50:22 +09:00
Inseob Kim
6d79030d0c Build mac_permissions.xml with Soong
Bug: 33691272
Test: build and compare
Change-Id: Iacbd5bcf77f0b1c0b5e2c6691efb4c62bc78fdf8
2022-08-17 09:49:35 +09:00
Sandro
143988dedb Add apex_sepolicy targets for running go/seamendc
This is a roll-forward of some of the changes rolled back in
aosp/2170746. I am rolling forward in smaller chunks so that it is
easier to identify and avoid possible breakages.

Bug: 236691128
Test: atest SeamendcHostTest
Change-Id: Ibe451325d471fe04cd52683ba90a22543fa84c7c
2022-08-09 09:33:09 +00:00
Lokesh Gidra
1269a179ac Revert "Move parts of sdk_sandbox from private to apex policy"
Revert "Add java SeamendcHostTest in cts"

Revert submission 2111065-seamendc

Reason for revert: b/240731742, b/240462388 and b/240463116
Reverted Changes:
I3ce2845f2:Move parts of sdk_sandbox from private to apex pol...
I0c10106e2:Add java SeamendcHostTest in cts

Test: revert cl
Change-Id: If9981796694b22b7cbfe1368cd815889c741e69d
2022-08-03 14:24:04 +00:00
sandrom
e6971f1330 Move parts of sdk_sandbox from private to apex policy
Bug: 236691128
Test: atest SeamendcHostTest

Change-Id: I3ce2845f259afb29b80e2d9b446aa94e64ef8902
2022-07-27 13:39:06 +00:00
Inseob Kim
4ae05118c1 Add 33.0 mapping files
Steps taken to produce the mapping files:

0. Add 33.0 prebuilts to prebuilts/api/33.0/.

1. Add the following Android.bp modules.

    33.0.board.compat.map
    33.0.board.compat.cil
    33.0.board.ignore.map
    plat_33.0.cil
    system_ext_33.0.cil
    product_33.0.cil
    33.0.ignore.cil
    system_ext_33.0.ignore.cil
    product_33.0.ignore.cil
    33.0.compat.cil
    system_ext_33.0.compat.cil

2. Touch the following three files.

    private/compat/33.0/33.0.cil
    private/compat/33.0/33.0.compat.cil
    private/compat/33.0/33.0.ignore.cil

3. Add 33.0 to PLATFORM_SEPOLICY_COMPAT_VERSIONS on
build/make/core/config.mk. Note that we don't update
sepolicy_major_vers to 33, but just update compat versions.

4. Run the following command.

    $ source build/make/rbesetup.sh && lunch aosp_arm64-userdebug
    $ m sepolicy_generate_compat
    $ sepolicy_generate_compat --branch=tm-dev \
        --build latest --target-version 33.0 \
        --latest-version 32.0

This change also enables treble_sepolicy_tests_33.0 and installs
33.0.cil mapping file onto the device.

Test: m treble_sepolicy_tests_33.0
Test: m 33.0_compat_test
Test: m slinux_policy
Change-Id: Ie969ff0372ff1268776165cee5cb5b07d303453c
2022-05-02 14:12:28 +09:00
Inseob Kim
4196403c36 Replace se_filegroup to se_build_files
se_build_files is a replacement for se_filegroup module. se_build_files
can be used with the normal Soong convention ":module_name{.tag}" by
implementing android.OutputFileProducer. It's better than implementing
ad-hoc logics across various modules, which is the case for se_filegroup
module.

Test: build and boot
Change-Id: Ic0e34549601eb043145e433055f5a030eaf4347e
2022-04-23 01:47:40 +09:00
Inseob Kim
c7596c4e61 Build vndservice_contexts with Android.bp
Bug: 33691272
Test: boot a device which uses vndservice_contexts
Change-Id: I28c36b74d4176954099f3b7e80a4869b7c44640f
2022-03-02 17:26:44 +09:00
Inseob Kim
61257ca545 Move sepolicy_test to Android.bp
Bug: 33691272
Test: m selinux_policy triggers sepolicy_test
Change-Id: I1618c2a35b3ce9d747db3955788427dc422fd532
2022-03-02 17:25:52 +09:00
Inseob Kim
eec3919969 Add new goal for compat file generator
To generate compat files, we need the following files.

- base_plat_sepolicy: to get all types
- base_plat_pub_policy.cil: to get public types
- {ver}_plat_sepolicy: to get old types

This creates a new dist goal, base-sepolicy-files-for-mapping, to
conveniently generate and gather desired files under out/dist.

Bug: 214336258
Test: build/soong/soong_ui.bash --make-mode dist \
      base-sepolicy-files-for-mapping \
      TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug
Change-Id: I2f210ab47be777cd91346d635f75064845821144
2022-01-21 19:36:37 +09:00
Treehugger Robot
175f50137e Merge "Support for APEX updatable sepolicy" 2022-01-11 13:49:24 +00:00
Jeff Vander Stoep
f9348b5509 Support for APEX updatable sepolicy
Builds:
 - sepolicy_test - file that init mounts in /dev/selinux to demonstrate
   that updatable sepolicy is loaded.
 - apex_sepolicy.cil - Initially includes a rule allowing shell
   to read sepolicy_test.
 - apex_file_contexts - Initially includes mapping of
    /dev/selinux/sepolicy_test.
 - apex_sepolicy.sha256. Used by init to determine of
    precompiled_sepolicy can be used.
 - apex_service_contexts - Currently empty.
 - apex_property_contexts - Currently empty.
 - apex_seapp_contexts - Currently empty.

Bug: 199914227
Test: Build, boot, ls -laZ /dev/selinux/sepolicy_test
Change-Id: I6aa625dda5235c6e7a0cfff777a9e15606084c12
2022-01-11 12:52:09 +01:00
Inseob Kim
2dac267dae Migrate seapp_contexts to Android.bp
Bug: 33691272
Test: build and boot
Test: atest SELinuxHostTest#testValidSeappContexts
Change-Id: I86f9d010d1628f9756cc152b4ee74dea1b9ff955
2021-12-29 17:54:57 +09:00
Inseob Kim
5bbcd68dcc Build recovery policy with Android.bp
Bug: 33691272
Test: enter recovery mode
Change-Id: Ifc38ed99e6615431d81ade76ec10ea4d34fbbf90
2021-12-28 17:51:51 +09:00
Inseob Kim
0de7fcc33a Migrate neverallow tests to Android.bp
A new module type se_neverallow_test is added, to migrate
sepolicy_neverallow modules. se_neverallow_test is affected by
SELINUX_IGNORE_NEVERALLOWS.

Bug: 33691272
Test: m selinux_policy
Test: intentionally create neverallow violations and m selinux_policy
Change-Id: I1582353f99f064ff78f3c547a0c13f2b772d54df
2021-12-28 10:23:22 +09:00
Inseob Kim
baee4a2cb6 Split compat and contexts part in Android.bp
Because Android.bp is getting bigger and bigger.

Test: build and boot
Test: set OVERRIDE_TARGET_FLATTEN_APEX=true and build
Change-Id: I397ce084bfbc98449d177dd553ff73fdfbdddcaf
2021-12-23 21:36:56 +09:00
Inseob Kim
6d3d5a6daf Fix contexts modules to use android:"path"
For now, contexts modules have been using se_filegroup modules, which
makes the build system logic unnecessarily complex. This change
refactors it to se_build_files modules and normal `android:"path"`
logic.

Test: build and boot
Change-Id: I52e557e2dc8300186869a97fddfd3a74183473f7
2021-12-23 21:36:27 +09:00
Inseob Kim
d144fa0333 Fix precompiled_sepolicy neverallow flag
Because we should ignore neverallow when SELINUX_IGNORE_NEVERALLOWS is
true.

Test: add a fake rule and build with/without SELINUX_IGNORE_NEVERALLOWS
Change-Id: I7811f5cef2243dae5b5de1154a36ab167871dc4f
2021-12-21 20:38:44 +09:00
Inseob Kim
3ac62fe9f6 Build vendor/odm sepolicies with Android.bp
The following files are built with Android.bp:
- vendor_sepolicy.cil
- odm_sepolicy.cil
- prebuilt_sepolicy

Also, prebuilt_policy.mk is removed as it's now redundant.

Bug: 33691272
Test: build and compare artifacts
Test: build with rvc-dev sepolicy
Change-Id: I7bf79c9c85c63cd942b36f7cf5ddda1860626c0b
2021-12-20 21:16:39 +09:00
Inseob Kim
7cb20812b2 Use se_build_files for technical_debt.cil
It's a no-op for now, but it will be used when migrating vendor sepolicy
to Android.bp.

Bug: 33691272
Test: build and boot
Change-Id: Ie0015d31e4929e7bd3316505bfd6d338a5e9eada
2021-12-16 16:52:14 +09:00
Inseob Kim
0a707fadb2 Refactor Android.bp build modules for readability
When we compile sepolicy files into a cil file, we first gather all
sepolicy files to create a conf file, and then convert the conf file to
a cil file with checkpolicy. The problem is that checkpolicy is
sensitive to the input order; the conf file should contain statements in
a specific order: classes, initial_sid, access vectors, macros, mls,
etc.

This restriction has made Android.bp migration difficult, and we had to
create a magical module called "se_build_files" to correctly include
source files in the designated order. It works, but significant
readability problem has happened. For example, when we write
":se_build_files{.system_ext_public}", how can we easily figure out that
the tag actually includes plat public + system_ext public + reqd mask,
without taking a look at the build system code?

This change refactors the se_build_files module and se_policy_conf
module, so we can easily see the desginated files for each module, just
like we did in the Android.mk. se_policy_conf module now stably sorts
source files in an order which will make checkpolicy happy.
se_build_files module is also refactored, so one tag can represent
exactly one set of policy files, rather than doing magical works behind
the scene. For example, system_ext public policy module is changed from:

se_policy_conf {
    name: "system_ext_pub_policy.conf",
    // se_build_files automatically adds plat public and reqd mask
    srcs: [":se_build_files{.system_ext_public}"],
}

to:

se_policy_conf {
    name: "system_ext_pub_policy.conf",
    // se_policy_conf automatically sorts the input files
    srcs: [
        ":se_build_files{.plat_public}",
        ":se_build_files{.system_ext_public}",
        ":se_build_files{.reqd_mask}",
    ],
}

Bug: 209933272
Test: build and diff before/after
Change-Id: I97a76ed910645c1607d913fd646c27e87af0afd3
2021-12-10 00:31:53 +09:00
Inseob Kim
9dc6d70044 Remove 26.0 and 27.0 compat support
Treble doesn't support T system + O vendor, so removing 26.0 (N) and
27.0 (O) prebuilts and compat files.

Bug: 207815515
Test: build
Change-Id: I98d5972221a8e77f3c45fc48ff50bb2b8eb94275
2021-12-02 10:22:10 +09:00
Inseob Kim
bee558e4bb Add 32.0 mapping files
Steps taken to produce the mapping files:

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

When adding plat_pub_versioned.cil, leave only type and typeattribute
statements, removing the other statements: allow, neverallow, role, etc.

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

This change also enables treble_sepolicy_tests_32.0 and installs
32.0.cil mapping file onto the device.

Bug: 206330997
Test: m treble_sepolicy_tests_32.0
Test: m 32.0_compat_test
Test: m selinux_policy
Change-Id: I8b2991e64e2f531ce12db7aaacad955e4e8ed687
2021-12-01 10:58:25 +09:00
Yuntao Xu
42e732c861 Split property/file/service contexts modules
1. Splitted plat_property_contexts, plat_file_contexts, and
plat_service_contexts so they can be included by the
CtsSecurityHostTestCases module.

2. Add temporary seapp_contexts Soong module, which are needed by the
CtsSecurityHostTestCases, and makefile_goal is an interim solution before
migrating both of them to Soong.

Bug: 194096505
Test: m CtsSecurityHostTestCases
Change-Id: I99ba55b1a89f196b3c8504e623b65960a9262165
2021-11-19 18:23:12 +09:00
Vova Sharaienko
919fa4f9fc Merge "Revert "Split property and file contexts modules"" 2021-11-18 17:56:09 +00:00
Vova Sharaienko
bec08097c9 Revert "Split property and file contexts modules"
Revert "Convert security/Android.mk to Android.bp"

Revert "Add seapp_contexts to allowlist of makefile goal"

Revert submission 1795972-Convert security/Android.mk to Android.bp

Reason for revert: http://b/206976319 Broken build 7928060 on aosp-master on sdk_arm64-sdk
Reverted Changes:
I0e0e7f677:Split property and file contexts modules
I5596d6f00:Add seapp_contexts to allowlist of makefile goal
If685e5ccc:Convert security/Android.mk to Android.bp

Change-Id: Ibbca0a17886d15b3fd7ecaf974a06df7107fd9aa
2021-11-18 17:29:01 +00:00
Yuntao Xu
1b76673577 Merge "Split property and file contexts modules" 2021-11-18 17:05:46 +00:00
Yifan Hong
28f9b97646 Merge changes from topic "servicemanager-recovery"
* changes:
  servicemanager: recovery write to kmsg.
  Add recovery service_contexts files.
2021-11-18 04:39:15 +00:00
Yifan Hong
d6b2901748 Add recovery service_contexts files.
This allows binder services to run in recovery.

Test: build them
Bug: 170338625
Change-Id: If8580c3fc1b3add87178365c58288126e61345b4
2021-11-16 20:54:17 -08:00
Yi-Yo Chiang
2c18965e27 Treblelize bug_map: split bug_map to multiple partitions
* plat_bug_map: Platform-specific bug_map definitions.
* system_ext_bug_map: Product-specific bug_map definitions.
* vendor_bug_map: SOC-specific bug_map definitions.

Bug: 177977370
Test: Boot and check auditd logs
Change-Id: I6f26b421acfd060e8abb8e4e812c0f422cc6757b
2021-11-08 22:44:34 +08:00