Commit graph

43960 commits

Author SHA1 Message Date
Thiébaud Weksteen
3a102a13f3 Validate private/file_contexts against plat_file_contexts_test
This tests the original private/file_contexts and not the built version
(as it may contain the overlay files or asan entries). This ensures that
all the rules in the base files are used.

Another test will be later added to validate the built version (but
without requiring that all rules are used).

Bug: 299839280
Test: mm
Change-Id: I5efdde3c7f5211472cd9a0cf8def243aef640825
2023-10-23 16:10:28 +11:00
Thiébaud Weksteen
29104da749 Add test entries for /metadata/repair-mode
Bug: 299839280
Test: mm
Change-Id: I2df9a3d65d622149ea9d5df9d4a6ff1e20071cae
2023-10-23 16:10:28 +11:00
Thiébaud Weksteen
b6e7430dad Accept test_data attribute for file_contexts_test
If file_contexts_test is given a test_data attribute, it will use
`checkfc -t` to validate the file_context against it, instead of using
the policy. Both options are mutually exclusive.

Bug: 299839280
Test: m
Change-Id: I3f541e0d0bb5d03ed146e27d67bc811cda3164b1
2023-10-23 16:10:18 +11:00
Thiébaud Weksteen
a8bcaec228 Merge changes I3a6f9db9,Ifb4453d0,I33d88b42 into main
* changes:
  Refactor contextsTestModule
  Fix private/file_contexts entry order
  checkfc: validate that all rules are matching
2023-10-23 04:06:09 +00:00
Thiébaud Weksteen
f66e1460b1 Merge "Create sepolicy for allowing system_server rw in /metadata/repair-mode" into main 2023-10-23 04:05:46 +00:00
Rhed Jao
ebe1316695 Create sepolicy for allowing system_server rw in /metadata/repair-mode
Bug: 277561275
Test: ls -all -Z /metadata/repair-mode
Change-Id: Ie27b6ef377bb3503e87fbc5bb2446bc0de396123
2023-10-23 13:38:38 +11:00
Treehugger Robot
ea39eb6636 Merge "Add a sysprop to specify game default frame rate" into main 2023-10-23 01:12:53 +00:00
Thiébaud Weksteen
a69e14f342 Refactor contextsTestModule
Keep the type of context and decides on the flags within
GenerateAndroidBuildActions. This is a no-op but will help supporting
other options for checkfc.

Bug: 299839280
Test: mm
Change-Id: I3a6f9db9d890e0a0ccb3eca37c01b2977fa2e2d1
2023-10-23 11:21:58 +11:00
Thiébaud Weksteen
9c2a967114 Fix private/file_contexts entry order
Add test entries for property_service_for_system and virtual_camera.

Re-order file_contexts so that /data/vendor/tombstones/wifi and
/data/misc/perfetto-traces/bugreport are labelled correctly.

Bug: 299839280
Test: checkfc -t ./private/file_contexts ./contexts/plat_file_contexts_test pass
Change-Id: Ifb4453d02327b5cf678e6a4cd927b5df0960086b
2023-10-23 10:51:11 +11:00
Thiébaud Weksteen
09021255b6 checkfc: validate that all rules are matching
For the file backend, libselinux keeps track of which rules has matched.
Set up the callback and capture any log message from selinux_stats. If,
at least one rule has not been used, exit with the status code 1.

Bug: 299839280
Test: checkfc -t ./private/file_contexts ./tests/plat_file_contexts_test
Change-Id: I33d88b4234756cd13e29c5c8c081d97b6590810e
2023-10-23 10:51:11 +11:00
Li Li
87fa0f9f77 Merge "Allow system server read binderfs stats" into main 2023-10-20 23:57:19 +00:00
Wonsik Kim
c1ed17561c Merge "property_context: add Codec2 HAL selection property" into main 2023-10-20 23:08:29 +00:00
Li Li
0b3f585a63 Allow system server read binderfs stats
When receiving the binder transaction errors reported by Android
applications, AMS needs a way to verify that information. Currently
Linux kernel doesn't provide such an API. Use binderfs instead until
kernel binder driver adds that functionality in the future.

Bug: 199336863
Test: send binder calls to frozen apps and check logcat
Test: take bugreport and check binder stats logs
Change-Id: I3bab3d4f35616b4a7b99d6ac6dc79fb86e7f28d4
2023-10-20 13:22:24 -07:00
Vadim Caen
2892de504d Merge "Add sepolicy entry for read only virtual camera property" into main 2023-10-20 12:21:25 +00:00
Alan Stokes
faa538dbfc Suppress a denial on VM boot
The denial is correct, but is causing test failures. However it
appears to be harmless and VMs are operating just fine.

Suppress it until the correct policy is ready.

Bug: 306516077
Test: atest MicrodroidHostTests
Change-Id: I5d8545add4927c2521c3d4e9dc2b5bedb91c0f45
2023-10-20 10:59:52 +01:00
Andy Yu
bdcf0bd5de Add a sysprop to specify game default frame rate
Introduce a new sysprop
`ro.surface_flinger.game_default_frame_rate_override`
to set the default frame rate for games.

Bug: 286084594
Change-Id: Ifdbf5bc9621976a0583df49eb9531de1c423385b
Test: N/A
2023-10-19 22:43:32 +00:00
Vadim Caen
1b11440f56 Add sepolicy entry for read only virtual camera property
Test: N/A
Bug: b/270352264
Change-Id: I7ee2873eadf7eba3f0f5eda340c88b6f6995ff3d
2023-10-19 22:17:18 +02:00
Treehugger Robot
c5509a8ea0 Merge "Policy for virtual_camera native service" into main 2023-10-18 15:55:42 +00:00
Bruno BELANYI
2cc14046c1 Merge "Define SurfaceFlinger HDR priming opt-in sysprop" into main 2023-10-18 09:46:36 +00:00
Thiébaud Weksteen
293b3bcce7 Track access from platform_app to system_data_file
avc: denied { search } for comm="ll.splashworker" name="10" dev="dm-69" ino=4225 scontext=u:r:platform_app:s0:c512,c768 tcontext=u:object_r:system_data_file:s0:c522,c768 tclass=dir permissive=0 app=com.android.systemui

Test: boot and check logs
Bug: 306090533
Bug: 303581276
Change-Id: I9a3ebe68e471a36a601054c7130c474aed8bb183
2023-10-18 17:36:36 +11:00
Wonsik Kim
c6decd4a8d property_context: add Codec2 HAL selection property
Bug: 251850069
Test: run the example service and verify the selection works
Change-Id: I8b56e1f716a9dc06019232cd2c5061ccaa1951d0
2023-10-17 14:13:37 -07:00
Eric Biggers
f53eb06fd3 Merge changes Ie6c7b17a,I35d9ea22 into main
* changes:
  Stop granting permission to get_state of keystore2
  Stop granting permissions on keystore_key class
2023-10-17 18:02:44 +00:00
Thiébaud Weksteen
06a5f9ad21 Merge "Add checkfc mode to validate file_contexts against test data" into main 2023-10-17 08:25:45 +00:00
Thiébaud Weksteen
9a924ba875 Add checkfc mode to validate file_contexts against test data
A new mode for checkfc is introduced (-t) which takes a file_contexts
and a test data file. Each line in the test data file contains a path
and the expected type. checkfc loads the file_contexts and repeatedly
calls selabel_lookup(3) to verify that the computed type is as expected.

This mode can be used to confirm that any modification to file_contexts
or its build process is benign.

A test data file (plat_file_contexts_test) is added. This file was
manually created based on private/file_contexts. Each static path was
copied as-is. Each regular expression was expanded into a couple of
entries. For instance, /dev/adf[0-9]* generated /dev/adf, /dev/adf0 and
/dev/adf123.

libselinux keeps track of which specification is being hit when using
selabel_lookup. When calling selabel_stats(3), the file backend will
output a warning if a specification has not been used. This can be
leveraged to ensure that each rule is at least hit once. This property
will be leveraged in a follow-up change (by running the test as part of
the build process), to ensure that the plat_file_contexts_test file
remains up-to-date (that is, when an entry is added to
private/file_contexts, the build will fail unless a test is also added
to plat_file_contexts_test to exercice the specification/regular
expression).

Test: m checkfc && checkfc -t ./private/file_contexts ./tests/plat_file_contexts_test
Bug: 299839280
Change-Id: Ibf56859a16bd17e1f878ce7b0570b2aead79c7e0
2023-10-17 15:43:06 +11:00
Eric Biggers
d7fe10be98 Stop granting permission to get_state of keystore2
The get_state permission of the "keystore2" class only guarded the
Binder API IKeystoreMaintenance#getState() served by keystore2.  That
API has been removed because it was unused
(https://r.android.com/2768246).  Therefore, stop granting the get_state
permission.

Don't actually remove the permission from private/access_vectors.  That
would break the build because it's referenced by rules in prebuilts/.

Bug: 296464083
Test: atest CtsKeystoreTestCases
Change-Id: Ie6c7b17a8652f86a75d48c134a6e71a634d63772
2023-10-16 22:22:57 +00:00
Eric Biggers
cc5cb431ee Stop granting permissions on keystore_key class
When keystore was replaced with keystore2 in Android 12, the SELinux
class of keystore keys was changed from keystore_key to keystore2_key.
However, the rules that granted access to keystore_key were never
removed.  This CL removes them, as they are no longer needed.

Don't actually remove the class and its permissions from
private/security_classes and private/access_vectors.  That would break
the build because they're referenced by rules in prebuilts/.

Bug: 171305684
Test: atest CtsKeystoreTestCases
Flag: exempt, removing obsolete code
Change-Id: I35d9ea22c0d069049a892def15a18696c4f287a3
2023-10-16 22:22:54 +00:00
Treehugger Robot
d05c1e4943 Merge "Update hal_evs_default policy" into main 2023-10-16 22:18:18 +00:00
Treehugger Robot
f604b91706 Merge "Allow artd to reopen its own memfd." into main 2023-10-16 21:01:44 +00:00
Roshan Pius
13b56467fa Merge "sepolicy: Rename NFC apex package name" into main 2023-10-16 18:31:02 +00:00
Bruno BELANYI
d350de16ae Define SurfaceFlinger HDR priming opt-in sysprop
Bug: 295257834
Test: manual - check that the sysprop can be defined after applying
Change-Id: I3be32ba76cf97d50c56f2dde0aeafb937b530508
2023-10-16 16:27:54 +00:00
Thiébaud Weksteen
51cc740ca8 Ignore access from priv_app to wifi_config_prop
Bug: 303581276
Bug: 291197167
Bug: 208360714
Bug: 208919128
Test: presubmit
Change-Id: Ia0750d39d7c1d666f2f5d58f4c16169b5348d32f
2023-10-16 11:00:24 +11:00
Jiakai Zhang
4d70f0bf4b Allow artd to reopen its own memfd.
Bug: 257532944
Test: atest CtsCompilationTestCases
Change-Id: I6e2a04fe2b9145aebd7db4d6a0d1ac560eddb66b
2023-10-13 18:26:56 +00:00
Dennis Shen
72da88530f Merge "add next_boot_prop SELinux context to store staged sys prop" into main 2023-10-13 18:22:56 +00:00
Roshan Pius
b013422f8f sepolicy: Rename NFC apex package name
To avoid clash with existing com.android.nfc package of NFC app.

Bug: 303286040
Test: Compiles
Merged-In: I1474146312b7131ac847aad23e1a71e24351d750
Change-Id: I1474146312b7131ac847aad23e1a71e24351d750
2023-10-13 18:04:49 +00:00
Vadim Caen
f6e88ec70a Policy for virtual_camera native service
Change-Id: Id0c582f9259ffd056b22f111d7e81bc061c2371d
2023-10-13 16:42:11 +02:00
Changyeon Jo
561930c06b Update hal_evs_default policy
- Allow to access writable graphics properties.
- Allow to perform binder IPC.

Bug: 303581276
Test: m -j selinux_policy
Change-Id: I02c8ccd416172e5f6c17eff6573137dd4a8147c7
2023-10-12 20:31:07 +00:00
Dennis Shen
bb028e3e9a add next_boot_prop SELinux context to store staged sys prop
Bug: b/300111812
Change-Id: I02f1ba586fb6dfec90ae1ff6d4bb6518f294c5d7
Merged-In: I02f1ba586fb6dfec90ae1ff6d4bb6518f294c5d7
2023-10-12 16:12:30 +00:00
Jiakai Zhang
b6a3360ea3 Merge "Allow profman to read from memfd created by artd." into main 2023-10-12 14:59:38 +00:00
Jiakai Zhang
8ff6c55fc4 Allow profman to read from memfd created by artd.
Bug: 257532944

Change-Id: I13a953c533b1789eb06158a5ffa227fa986870fc
2023-10-12 13:48:00 +00:00
Maciej Żenczykowski
b5114387a0 Merge "tethering apex - label netbpfload" into main 2023-10-11 17:03:34 +00:00
Alex Buynytskyy
d328cfccee Merge "Fix sepolicy finalization build error" into main 2023-10-11 15:31:43 +00:00
Inseob Kim
9ca80edf2a Fix sepolicy finalization build error
Bug: 304532197
Test: manually run finalization script
Change-Id: I62caa28b45940753c11cb6d44c1270a4637c120a
2023-10-11 22:58:45 +09:00
Maciej Żenczykowski
6b7fe0b63e tethering apex - label netbpfload
We may want to use a dedicated selinux context
for this in the future, but in the mean time we
need this.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ib3ed06efc4d2e3a621f187543fad4ab1a84027ec
2023-10-11 03:49:23 -07:00
Treehugger Robot
57056e5249 Merge "Fix context for mapping/xx.yy.compat.cil files" into main 2023-10-11 03:18:57 +00:00
Maciej Żenczykowski
834447d058 file_contexts: remove btfloader, add netbpfload
btfloader is dead.  bpfloader is being split in twain.
(it will eventually get it's own context, but for now this works)

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I7577e777545a0fa77a6467fb425aefc99a6e68d0
2023-10-09 18:46:07 +00:00
Daniele Di Proietto
c9b8e1b2b0 Merge "tracing: SELinux access to a couple of more binder events" into main 2023-10-09 10:23:06 +00:00
Vladimir Komsiyski
6e07de8088 Merge "Policy for virtualdevice_native service." into main 2023-10-06 14:20:09 +00:00
Vladimir Komsiyski
31facf0677 Policy for virtualdevice_native service.
A parallel implementation of certain VDM APIs that need to
be exposed to native framework code.

Similar to package_native_service.

Not meant to be used directly by apps but should still be
available in the client process via the corresponding native
manager (e.g. SensorManager).

Starting the service: ag/24955732
Testing the service: ag/24955733

Bug: 303535376
Change-Id: I90bb4837438de5cb964d0b560585b085cc8eabef
Test: manual
2023-10-06 12:52:42 +00:00
Thiébaud Weksteen
6bf1581f1c Fix context for mapping/xx.yy.compat.cil files
The current file_contexts regular expression did not include the
.compat part of the policy.

Before:
  # ls -alZ /system/etc/selinux/mapping
  drwxr-xr-x 2 root root u:object_r:system_file:s0       332 2009-01-01 00:00 .
  drwxr-xr-x 3 root root u:object_r:system_file:s0       376 2009-01-01 00:00 ..
  -rw-r--r-- 1 root root u:object_r:sepolicy_file:s0  224062 2009-01-01 00:00 10000.0.cil
  -rw-r--r-- 1 root root u:object_r:sepolicy_file:s0  112668 2009-01-01 00:00 29.0.cil
  -rw-r--r-- 1 root root u:object_r:system_file:s0      1003 2009-01-01 00:00 29.0.compat.cil
  -rw-r--r-- 1 root root u:object_r:sepolicy_file:s0  125916 2009-01-01 00:00 30.0.cil
  -rw-r--r-- 1 root root u:object_r:system_file:s0      1059 2009-01-01 00:00 30.0.compat.cil
After:
  # ls -alZ /system/etc/selinux/mapping
  drwxr-xr-x 2 root root u:object_r:system_file:s0       332 2023-10-06 03:40 .
  drwxr-xr-x 3 root root u:object_r:system_file:s0       376 2023-10-06 03:40 ..
  -rw-r--r-- 1 root root u:object_r:sepolicy_file:s0  224062 2023-10-04 22:58 10000.0.cil
  -rw-r--r-- 1 root root u:object_r:sepolicy_file:s0  112668 2023-10-04 22:58 29.0.cil
  -rw-r--r-- 1 root root u:object_r:sepolicy_file:s0    1003 2023-09-06 01:51 29.0.compat.cil
  -rw-r--r-- 1 root root u:object_r:sepolicy_file:s0  125916 2023-10-04 22:58 30.0.cil
  -rw-r--r-- 1 root root u:object_r:sepolicy_file:s0    1059 2023-09-06 01:51 30.0.compat.cil

Test: boot cf & inspect new labels
Bug: 299839280
Change-Id: Ic833ccf59a6c75b0757df9de6e3fed0992839c74
2023-10-06 15:20:35 +11:00
Xin Li
d1b58121a5 Merge Android 14
Bug: 298295554
Merged-In: I3339a7abfe2612993ee659fd5492c323aa895999
Change-Id: Iced16bd9ddd92f0fbd2e7729c1be3d1da77e3e46
2023-10-05 15:45:28 -07:00