Commit graph

59198 commits

Author SHA1 Message Date
Ruchir Rastogi
e712eed24c Support atom-level annotations within AStatsEvent
Refactors implementation details to allow for atom-level annotations.
This CL does not change the API surface. addBoolAnnotation and
addInt32Annotation work for both atom-level and proto field annotations.

Test: bit libstatssocket_test:*
Bug: 151158794
Change-Id: I2c340b201aeb3bcddd5cfde171b7c4df1d8d69a4
2020-03-12 15:21:26 -07:00
Automerger Merge Worker
666dd4ff16 Merge "init.rc: disable kernel module autoloading" am: e7f014da9c am: 0cef47636d
Change-Id: Ibb060632ead44b8d098c6c1c2db557b08ac5b99d
2020-03-12 21:49:48 +00:00
Automerger Merge Worker
35cb5cc14a Merge "init.rc: disable kernel module autoloading" am: e7f014da9c am: 0cef47636d
Change-Id: Ia597709b939a6a1699e364c448430b646a1dcd5e
2020-03-12 21:49:39 +00:00
Automerger Merge Worker
0cef47636d Merge "init.rc: disable kernel module autoloading" am: e7f014da9c
Change-Id: I2b83cdd3d121a3633a26157a4087f9a56f195121
2020-03-12 21:39:22 +00:00
Eric Biggers
b6545b80a0 init.rc: disable kernel module autoloading
There is a longstanding bug where file-based encryption causes spurious
SELinux denials of module_request because it uses the kernel's crypto
API, and the crypto API tries to autoload kernel modules.

While this sometimes indicate missing kconfig options, it can still
happen even if all needed kconfig options are enabled.  This is because
a crypto algorithm can be a composition like "hmac(sha512)", and the
crypto API will first look for the full composition before it
instantiates it using the components like "hmac" and "sha512".  But
often an implementation of the full composition doesn't exist.

However, as far as I can tell, Android doesn't actually use kernel
module autoloading at all.  First, Android never changes
/proc/sys/kernel/modprobe from the default of "/sbin/modprobe", yet this
isn't where modprobe is located on Android.  Android's SELinux policy
contains a neverallow rule that ensures that only init (not even
vendor_init) can write to this setting, so vendors can't be changing it.

Vendors could potentially be setting CONFIG_STATIC_USERMODEHELPER_PATH,
which overrides the path of all usermode helpers including modprobe.
But this is a relatively new kconfig option, available only in
android-4.14 and later.  Also, for a vendor to actually do this they'd
also need to extend the SELinux policy with a domain_auto_trans rule to
allow their usermode helper to be executed by the kernel.

Android does increasingly use kernel modules, and GKI (Generic Kernel
Image) will require them.  However, the modules are actually inserted by
userspace by 'init', not autoloaded.

It's possible to disable kernel module autoloading completely by setting
/proc/sys/kernel/modprobe to an empty string.  So, let's do that.

This prevents lots of spurious SELinux denials, and allows removing
unnecessary rules to allow or dontaudit the module_request permission.

Note: when the kernel doesn't have CONFIG_ANDROID_BINDERFS enabled, this
change exposes a kernel bug that causes a WARNING in get_fs_type().  To
avoid this WARNING, a kernel fix should be applied too -- currently
under discussion upstream
(https://lkml.kernel.org/r/20200310223731.126894-1-ebiggers@kernel.org).

Bug: 130424539
Bug: 132409186
Bug: 144399145
Bug: 146477240
Bug: 148005188
Bug: 149542343

Test: Tested on cuttlefish and coral:

    - Checked that /proc/sys/kernel/modprobe contains /sbin/modprobe
      before this change, and the empty string after.

    - Checked that if all SELinux rules for module_request are removed,
      there are SELinux denials for module_request before this change
      but none after.

    - Ran lsmod both before and after and verified that the list is the
      same, i.e. checked that this change doesn't break how Android
      actually loads kernel modules.

Change-Id: I4132fe1a491e7b789311afcf693c1f6493fb9dc5
Merged-In: I4132fe1a491e7b789311afcf693c1f6493fb9dc5
2020-03-12 14:20:40 -07:00
Eric Biggers
e7f014da9c Merge "init.rc: disable kernel module autoloading" 2020-03-12 21:19:38 +00:00
Automerger Merge Worker
5300de0e3b Merge "Add OptimizeSourceCopyOperation" am: 6ae132fd10 am: a5876cd674
Change-Id: I1aff0f2bfce2db0de4e452f7faad3452eac89e24
2020-03-12 21:19:18 +00:00
Automerger Merge Worker
ae9361daa3 Merge "Add OptimizeSourceCopyOperation" am: 6ae132fd10 am: a5876cd674
Change-Id: I9802cfccc3dc4ff7df86513a593676d4262a769b
2020-03-12 21:19:02 +00:00
Automerger Merge Worker
a5876cd674 Merge "Add OptimizeSourceCopyOperation" am: 6ae132fd10
Change-Id: Ib571e6e82731ad7cf9a4c8cedf3329470ed12853
2020-03-12 21:04:40 +00:00
Yifan Hong
6ae132fd10 Merge "Add OptimizeSourceCopyOperation" 2020-03-12 20:44:24 +00:00
Automerger Merge Worker
44f87ca91e Merge "Remove mips pixelflinger." am: 86f83cf41e am: e7524d43a5
Change-Id: Ib22f8fb638dfde889a5d06eb63a459ff0bbff345
2020-03-12 19:15:49 +00:00
Automerger Merge Worker
f1317fcc3a [automerger skipped] Merge "Remove mips pixelflinger." am: 86f83cf41e am: e7524d43a5 -s ours
am skip reason: Change-Id I7e743da2b6f142884b3c41fd60550a381df51d54 with SHA-1 2ba869b770 is in history

Change-Id: I80bb05568f92afe6553e28764f326e3b418b3163
2020-03-12 19:15:46 +00:00
Automerger Merge Worker
e7524d43a5 Merge "Remove mips pixelflinger." am: 86f83cf41e
Change-Id: Ie848b0f6edff90f1f393e255efe93c78c9636a0d
2020-03-12 18:58:21 +00:00
Elliott Hughes
86f83cf41e Merge "Remove mips pixelflinger." 2020-03-12 18:43:12 +00:00
Tom Cherry
6085cd5a64 liblog: move LOG_ID_DEFAULT into the log_id enum
As requested during the API review.

Bug: 150898477
Test: liblog and libbase unit tests
Change-Id: Id67203bbfbc3e116b6b6efd40428afe48203dcfc
2020-03-12 11:14:19 -07:00
Tom Cherry
f1a975bece liblog: use int32_t and uint32_t for new NDK APIs
As requested during the API review.

Bug: 150898477
Test: liblog and libbase unit tests
Change-Id: I0c1dd57f7499e432bb881e1da1beb55f1ff7de05
2020-03-12 11:11:24 -07:00
Yifan Hong
d8a38e7c23 Add OptimizeSourceCopyOperation
... so that an operation can be skipped partially. For example, if
an operation contains blocks:
    563412 -> 123456
... then optimized operation is:
    5612 -> 1256

Test: update_engine_unittests
Test: apply incremental OTA
Bug: 148623880

In an experiment, this reduces CoW size of an incremental update
package by 200MB (out of 700MB).

Change-Id: I86ca23fd589ddbc84c81318283b5f4e71782a759
Merged-In: I86ca23fd589ddbc84c81318283b5f4e71782a759
2020-03-12 10:00:12 -07:00
Tom Cherry
227ac56454 liblog: fix header guards ordering
__ANDROID_API__ isn't defined on host, so this check will fail due to
-Wundef.  The || is short circuited through, so we can check for host
first and only have the right side of the || evaluated for device
builds.

Bug: 150898477
Bug: 151255209
Test: build
Change-Id: I2e0bc055ac0c7ba8262875801cdaed9cc30d2cef
2020-03-12 09:37:05 -07:00
Automerger Merge Worker
8e89ceea35 [automerger skipped] Merge "don't include liblog to APEXes" into rvc-dev am: c2a354be68 -s ours
am skip reason: Change-Id I5aab863cb12b8767b6979255c247000a59355b0e with SHA-1 95b6f45b0e is in history

Change-Id: Ic47ec107843393cef9aebb15f3a2b85715de3f62
2020-03-12 04:28:44 +00:00
Jiyong Park
c2a354be68 Merge "don't include liblog to APEXes" into rvc-dev 2020-03-12 04:10:15 +00:00
Automerger Merge Worker
63df3489fb Merge "libfs_mgr_binder: Cleanup GetGsiService()" am: 133df17ea1 am: 30f22b376f
Change-Id: I8ff416e909f67fb2d65585ef14c44d648693365c
2020-03-12 04:09:21 +00:00
Automerger Merge Worker
1b1fd6f0db Merge "libfs_mgr_binder: Cleanup GetGsiService()" am: 133df17ea1 am: 30f22b376f
Change-Id: I903c979eb97778b0314b13a19c04af9d272a1251
2020-03-12 04:09:13 +00:00
Automerger Merge Worker
30f22b376f Merge "libfs_mgr_binder: Cleanup GetGsiService()" am: 133df17ea1
Change-Id: Ibb4c01a854c8c762e93188be7ff7d66d7894e1e9
2020-03-12 03:56:21 +00:00
Treehugger Robot
133df17ea1 Merge "libfs_mgr_binder: Cleanup GetGsiService()" 2020-03-12 03:37:52 +00:00
Automerger Merge Worker
3ecceb2499 Merge "Make libselinux a stub library" am: b407502c98 am: 9281e97450
Change-Id: I733908648878ac8032fe61a79fed9b4b2fe35c71
2020-03-12 03:31:16 +00:00
Automerger Merge Worker
18ee520e93 Merge "Make libselinux a stub library" am: b407502c98 am: 9281e97450
Change-Id: Ica4f4de8425f84eb6efb1321df1f5f78e3393464
2020-03-12 03:31:03 +00:00
Automerger Merge Worker
9281e97450 Merge "Make libselinux a stub library" am: b407502c98
Change-Id: I7145d1c9cfc35b40bdeb4dfa402cc953e4cd1985
2020-03-12 03:09:59 +00:00
Treehugger Robot
b407502c98 Merge "Make libselinux a stub library" 2020-03-12 02:57:14 +00:00
Automerger Merge Worker
8b56249119 Merge "adbd: make libadbd_services cc_library again." into rvc-dev am: 575d8c2c9e
Change-Id: Ib71d2210d244aa7c05fab931a5db1fe086979752
2020-03-12 02:21:16 +00:00
TreeHugger Robot
575d8c2c9e Merge "adbd: make libadbd_services cc_library again." into rvc-dev 2020-03-12 02:06:09 +00:00
Automerger Merge Worker
5dc6290c24 Merge "adb: Avoid a couple std::string constructions" am: 2442e64416 am: c2d303231d
Change-Id: I768760f4439b5403025bb3a91a8acedcf6fd4d47
2020-03-12 00:41:33 +00:00
Automerger Merge Worker
4204750feb Merge "adb: Avoid a couple std::string constructions" am: 2442e64416 am: c2d303231d
Change-Id: Ifb0bee9433670c8e9bb91f9e94fcc231b051157f
2020-03-12 00:40:30 +00:00
Automerger Merge Worker
c2d303231d Merge "adb: Avoid a couple std::string constructions" am: 2442e64416
Change-Id: I6e89af8ee9133c03978f3fa543c0b777a5080402
2020-03-12 00:25:53 +00:00
Jiyong Park
3ffdad0cb5 Make libselinux a stub library
libselinux is currently being copied to APEXes. This is risky because
the library is not designed to be portable; part of it is tied to the
specific version of the Android that it was developed for.

This change fixes the problem by declaring that the library supports
a stub with the list of C APIs that are included in the stub. Then there
is only one copy of libselinux in /system/lib and other APEXes use the
copy by dynamically linking to it.

Also, adbd no longer statically links to it, because doing so brings
libselinux in it.

Bug: 151053366
Test: m com.android.adbd. It doesn't include libselinux in it.
Test: m com.android.adbd-deps-info. then inspect
out/soong/com.android.adbd-deps-info.txt. The dependency to libselinux
is shown as '(external)'.

Change-Id: If418cbe3abdeacb759d59052e6dca4c2067678dd
2020-03-12 00:02:18 +00:00
Automerger Merge Worker
50e25c5ca5 [automerger skipped] Merge "Revert "Stop & Resume property service when switching to bootstrap namespace"" into rvc-dev am: 293786f941 -s ours
am skip reason: Change-Id I2e11b782fcd2b7baded133a841fdcf519f702b84 with SHA-1 459ca0be74 is in history

Change-Id: I9fa67a5331b9c1bafb9715d4bd39492be60636ae
2020-03-11 23:35:29 +00:00
Treehugger Robot
2442e64416 Merge "adb: Avoid a couple std::string constructions" 2020-03-11 23:29:40 +00:00
Tom Cherry
293786f941 Merge "Revert "Stop & Resume property service when switching to bootstrap namespace"" into rvc-dev 2020-03-11 23:25:52 +00:00
Josh Gao
d1ee5085f3 adbd: make libadbd_services cc_library again.
For currently unknown reasons, sideloading is broken with
libadbd_services as a cc_library_static.

Partial revert of commit a9b62d5452.

Bug: http://b/151056300
Test: xunchang@ tested manually
Change-Id: Iaffad9c476ba0adcffc5db512ba4a7ee0fb5cb22
(cherry picked from commit 7f8a37c8c7)
2020-03-11 23:18:41 +00:00
Automerger Merge Worker
51373f979c Merge "fs_mgr_get_mounted_entry_for_userdata: handle logical partitions" am: 34ae0c58d2 am: 203a724070
Change-Id: I8a393cfc36366eb26ed99f7130426ef16e955003
2020-03-11 22:04:01 +00:00
Automerger Merge Worker
757974ee45 [automerger skipped] Merge "fs_mgr_get_mounted_entry_for_userdata: handle logical partitions" am: 34ae0c58d2 am: 203a724070 -s ours
am skip reason: Change-Id I1bb3e64ae92d56de905b4f7f1997b7499b101b0f with SHA-1 f495fe798b is in history

Change-Id: I229aeaa482a15419f522c2460f0f87708a23de7f
2020-03-11 22:03:40 +00:00
Automerger Merge Worker
203a724070 Merge "fs_mgr_get_mounted_entry_for_userdata: handle logical partitions" am: 34ae0c58d2
Change-Id: I37ddf7e2da1291bc9f042f675bb19e480ec1020a
2020-03-11 21:53:28 +00:00
Nikita Ioffe
34ae0c58d2 Merge "fs_mgr_get_mounted_entry_for_userdata: handle logical partitions" 2020-03-11 21:29:31 +00:00
Automerger Merge Worker
083c83c1e1 Merge "run ext4 tools in first_stage_ramdisk" am: 8aeada63f2 am: 441f9aa043
Change-Id: I0d4cf2af208ed13c23385b71add0346de3a57a8b
2020-03-11 20:41:48 +00:00
Automerger Merge Worker
d6a7cc73ce Merge "run ext4 tools in first_stage_ramdisk" am: 8aeada63f2 am: 441f9aa043
Change-Id: I9e167632225f59006a1b0d46641da9417fbbcc66
2020-03-11 20:40:36 +00:00
Automerger Merge Worker
441f9aa043 Merge "run ext4 tools in first_stage_ramdisk" am: 8aeada63f2
Change-Id: Ice6ac1eeab966e4162fa3efbfcc47d757b1b3817
2020-03-11 20:29:16 +00:00
Automerger Merge Worker
1bfce05829 Merge "run ext4 tools in first_stage_ramdisk" into rvc-dev am: 26471f7470
Change-Id: I67edb8c26d62cc1b8a259e1a897c0f28e6a89ad3
2020-03-11 20:12:18 +00:00
Automerger Merge Worker
5eb1d36d87 Merge "fs_mgr_get_mounted_entry_for_userdata: handle logical partitions" into rvc-dev am: ccb0608a32
Change-Id: I3db58f6e096b934c7d5e9b05959e40a29451c46e
2020-03-11 20:08:57 +00:00
Jaegeuk Kim
26471f7470 Merge "run ext4 tools in first_stage_ramdisk" into rvc-dev 2020-03-11 20:05:22 +00:00
Treehugger Robot
8aeada63f2 Merge "run ext4 tools in first_stage_ramdisk" 2020-03-11 20:04:50 +00:00
Nikita Ioffe
17824f0590 fs_mgr_get_mounted_entry_for_userdata: handle logical partitions
In case of GSI on DSU, /data is mounted on the following stack:
userdata -> userdata_gsi -> actual block device, and fstab returned from
ReadDefaultFstab() function will say that /data should be
mounted onto userdata_gsi. This configuration wasn't supported.

To support it, fs_mgr_get_mounted_entry_for_userdata now unwinds the
dm-device stack /data is mounted onto, and for each entry in fstab
resolves corresponding block device (in case of logical partitions by
asking DeviceMapper to resolve name -> path, and for other cases by
reading a symlink), and then checking whenever resolved block device
belongs to the unwinded stack.

Test: on both normal boot & DSU
Test: atest CtsUserspaceRebootHostSideTestCases
Test: atest CtsFsMgrTestCases
Bug: 148612148
Change-Id: I1bb3e64ae92d56de905b4f7f1997b7499b101b0f
Merged-In: I1bb3e64ae92d56de905b4f7f1997b7499b101b0f
(cherry picked from commit f495fe798b)
2020-03-11 19:21:37 +00:00