Commit Graph

72159 Commits

Author SHA1 Message Date
Android Build Coastguard Worker 25d994b1ce Merge cherrypicks of [16718400] into sc-d2-release.
Change-Id: I199c886a26c85b51d769f9f3006bd60054df2e3b
2022-01-26 07:26:59 +00:00
Akilesh Kailash f53f371806 init: Wait for snapuserd before starting second stage
This is a race between init process and bionic libc initialization of
snapuserd.

init->fork() ----------------> SecondStageMain() -> PropertyInit()
       |
       |
       v
      execveat ---> __libc_init_common() -> __system_properties_init()
     (snapuserd)

When init process calls PropertyInit(), /dev/__properties__ directory
is created. When bionic libc of snapuserd daemon invokes __system_properties_init
_after_ init process PropertyInit() function is invoked, libc will
try to initialize the property by reading
/system/etc/selinux/plat_property_contexts. Since any reads on /system
has to be served by snapuserd, this specific read from libc cannot be
serviced leading to deadlock.

Reproduce the race by inducing a sleep of 1500ms just before execveat()
so that init process calls PropertyInit() before bionic libc
initialization. This leads to deadlock
immediately and with additional kernel instrumentation with debug
logs confirms the failure:

======================================================
init: Relaunched snapuserd with pid: 428
ext4_file_open: SNAPUSERD: path /system/etc/selinux/plat_property_contexts - Pid: 428 comm 8
ext4_file_read_iter: SNAPUSERD for path: /system/etc/selinux/plat_property_contexts pid: 428 comm 8

[   25.418043][  T428]  ext4_file_read_iter+0x3dc/0x3e0
[   25.423000][  T428]  vfs_read+0x2e0/0x354
[   25.426986][  T428]  ksys_read+0x7c/0xec
[   25.430894][  T428]  __arm64_sys_read+0x20/0x30
[   25.435419][  T428]  el0_svc_common.llvm.17612735770287389485+0xd0/0x1e0
[   25.442095][  T428]  do_el0_svc+0x28/0xa0
[   25.446100][  T428]  el0_svc+0x14/0x24
[   25.449825][  T428]  el0_sync_handler+0x88/0xec
[   25.454343][  T428]  el0_sync+0x1c0/0x200

=====================================================

Fix:

Before starting init second stage, we will wait
for snapuserd daemon to be up and running. We do a simple probe by
reading system partition. This read will eventually be serviced by
daemon confirming that daemon is up and running. Furthermore,
we are still in the kernel domain and sepolicy has not been enforced yet.
Thus, access to these device mapper block devices are ok even though
we may see audit logs.

Note that daemon will re-initialize the __system_property_init()
as part of WaitForSocket() call. This is subtle but important; since
bionic libc initialized had failed silently, it is important
that this re-initialization is done.

Bug: 207298357
Test: Induce the failure by explicitly delaying the call of execveat().
      With fix, no issues observed.
      Tested incremental OTA on pixel ~15 times.

Ignore-AOSP-First: cherry-pick from AOSP
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: I86c2de977de052bfe9dcdc002dcbd9026601d0f3
(cherry picked from commit 65f3d09445699910947fd73b35979121b2bf07fb)
Merged-In:I86c2de977de052bfe9dcdc002dcbd9026601d0f3
2022-01-26 07:25:58 +00:00
Android Build Coastguard Worker 73d1c56fba Snap for 8099527 from ae5fe46ece to sc-d2-release
Change-Id: Ia9e50c1c4db7dc8065607105143a451ec741b327
2022-01-21 00:14:03 +00:00
Wei Wang ae5fe46ece Merge changes Id79f9e10,Ia91d8839 into sc-v2-dev
* changes:
  libprocessgroup: Use WriteStringToFd for WriteFileAction
  libprocessgroup: Prevent error spam when tests disable all cpus in a cpuset
2022-01-20 17:29:34 +00:00
Android Build Coastguard Worker 9ba4a5d053 Snap for 8084085 from 71429a9738 to sc-d2-release
Change-Id: I81ebaf462d235ba97290760b1e72e007bb581b4a
2022-01-15 22:09:32 +00:00
Kalesh Singh 71429a9738 Add group ID for reading tracefs
Add AID_READTRACEFS and mount tracefs with gid=AID_READTRACEFS

Bug: 209513178
Bug: 214061655
Test: adb shell ls -l /sys/kernel/tracing/events
Change-Id: Ibbfdf8a4b771bd7520ecbaaf15a1153d6bf0e599
Merged-In: Ibbfdf8a4b771bd7520ecbaaf15a1153d6bf0e599
2022-01-14 18:50:40 +00:00
Android Build Coastguard Worker 633cc31823 Snap for 8060779 from 739f4f5f60 to sc-d2-release
Change-Id: I91799dceabd0976d8ec80632af6e84be2fa0ec7b
2022-01-11 00:09:22 +00:00
David Anderson 739f4f5f60 libsnapshot: Fix CHECK failure during second phase merge
This CHECK prevents a release build from resuming a two-phase merge if
the merge initially failed in the first pass.

Bug: 213031779
Bug: 213253413
Bug: 193549218
Ignore-AOSP-First: cherry-pick from AOSP
Test: vts_libsnapshot_test
Test: update_engine_unittests
Change-Id: I8bf00e3016546ef7039bb0b18eb977cc3dc1066a
Merged-In: I8bf00e3016546ef7039bb0b18eb977cc3dc1066a
2022-01-07 02:36:11 +00:00
Android Build Coastguard Worker 0c7166362a Snap for 8050481 from 654bb5225b to sc-d2-release
Change-Id: I12339c67ba35bca911326f5677bc16fca950d792
2022-01-07 00:08:53 +00:00
David Anderson 6834fe66d7 libsnapshot: Propagate merge phase across merge failures.
If a merge fails we write a new snapshot status indicating that the merge
failed. If this happens to occur during the second merge phase, we fail
to propagate the phase counter to the new status. This means the merge
is unlikely to make progress and succeed later.

Bug: 213031779
Bug: 213253413
Bug: 193549218
Ignore-AOSP-First: cherry-pick from AOSP
Test: inject transient failure into CheckMergeConsistency, apply OTA,
      reboot and complete merge.
Change-Id: I31fdae6bde48e3a71b6f3fcc663541257f7ebd8f
Merged-In: I31fdae6bde48e3a71b6f3fcc663541257f7ebd8f
2022-01-05 23:47:11 +00:00
Nikita Ioffe 654bb5225b Deflake libdm#CreateEmptyDevice test
Judging from local experiments, it looks like device-mapper doesn't
always generate a uevent after DM_DEV_CREATE ioctl.

Test: presubmit
Bug: 193462349
Change-Id: I8a74375631b20c14a32a41dbaf38380ebc0078e6
Merged-In: I8a74375631b20c14a32a41dbaf38380ebc0078e6
2022-01-04 05:48:59 +00:00
Android Build Coastguard Worker 099d020e0f Snap for 8026873 from ea376a5c0f to sc-d2-release
Change-Id: I055a55bf363d566663b1ade1e0d9b0273d0bce3b
2021-12-24 00:08:48 +00:00
Alexander Potapenko ea376a5c0f init.rc: disable creation of bootreceiver tracing instance for kernels >=4.9 and <= 5.4 am: 17b1c428d4 am: 9c75c6983a
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/15981481

Change-Id: I07e546548847d5741000cf1fc58bd22a01c9774d
2021-12-23 11:21:18 +00:00
Alexander Potapenko c920992f94 [automerger skipped] Restrict creation of bootreceiver tracing instance to 64-bit systems. am: c81fec7d8e -s ours am: 4edf845185 -s ours
am skip reason: skipped by user glider

Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/15981480

Change-Id: I27cc0ad3f6074fd2376bceafa002dcdb1147e588
2021-12-23 11:21:17 +00:00
Alexander Potapenko 528b0f6700 init: introduce ro.kernel.version property am: 1c496e94e0 am: 2d64b0cafc
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/15981479

Change-Id: I4a9c0c38b7015a770fea5a9ad518e2e17a799042
2021-12-23 11:21:15 +00:00
Alexander Potapenko 9c75c6983a init.rc: disable creation of bootreceiver tracing instance for kernels >=4.9 and <= 5.4 am: 17b1c428d4
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/15981481

Change-Id: Ied7cd88b05e75b7aa5e3333a55cd5524c78ec427
2021-12-23 11:03:53 +00:00
Alexander Potapenko 4edf845185 [automerger skipped] Restrict creation of bootreceiver tracing instance to 64-bit systems. am: c81fec7d8e -s ours
am skip reason: skipped by user glider

Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/15981480

Change-Id: I090ea8262ddfc1da119b3dbf2e61c32bf67a6c9b
2021-12-23 11:03:53 +00:00
Alexander Potapenko 2d64b0cafc init: introduce ro.kernel.version property am: 1c496e94e0
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/15981479

Change-Id: I5f18d4e1e19d01c865ae40ae8e3368d67a3627e0
2021-12-23 11:03:51 +00:00
Android Build Coastguard Worker 8d527a0e74 Snap for 8010657 from cf4b15e61f to sc-d2-release
Change-Id: I41469556840e108112bf7cd7e1ca9ecb47b0aaaa
2021-12-17 00:08:52 +00:00
Wei Wang cf4b15e61f libprocessgroup: fall back to cpuset in get_sched_policy
Since vendor has a way to override the group cpu/schedtune setup, we
cannot assume the group will always return valid data. This CL let
get_sched_policy to fallback to cpuset if no valid data found in
cpu/schedtune cgroup. In longer term, we should find a way to cache the
group or app's process state in framework other than relying on reading
cgroup back.

Test: /data/nativetest64/libcutils_test/libcutils_test
Bug: 210066228
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: I8b4396365a7fc2d93e3a22746195585c140eef3c
2021-12-14 10:57:05 -08:00
Android Build Coastguard Worker e8ca1f8b0e Snap for 7995257 from a2c0b86ad0 to sc-d2-release
Change-Id: Id7613acc197a4c4ecb63dde40018e90311c81fa2
2021-12-14 00:09:05 +00:00
Wei Wang a2c0b86ad0 Merge "libutils: do not follow process's group" into sc-v2-dev 2021-12-13 18:02:28 +00:00
Rick Yiu e808841d72 libprocessgroup: Use WriteStringToFd for WriteFileAction
Using WriteStringToFile will hold kernfs_mutex which is a big lock,
so use WriteStringToFd instead. Besides, also support fd cache for it.

Bug: 206970384
Test: build pass
Change-Id: Id79f9e1095f52079393c58edb9a4d526f4cc6b5e
Merged-In: Id79f9e1095f52079393c58edb9a4d526f4cc6b5e
2021-12-12 13:22:07 +08:00
Suren Baghdasaryan ae42d601d0 libprocessgroup: Prevent error spam when tests disable all cpus in a cpuset
UserLifecycleTests test disables all Little cores in the course of the
test, which causes attempts to add a process into /dev/cpuset/restricted
cpuset cgroup to fail with ENOSPC error code, indicating that a process
is joining a cpuset cgroup with no online cpus. Current libprocessgroup
implementation will log an error on each such occurrence, which spams
the logs and makes it hard to analyze test results. Because this
situation does not happen in production environment (we do not offline
cpus), we can prevent flooding the logs by identifying this case,
logging an appropriate error one time and ignore all later similar errors.

Bug: 158766131
Test: adb shell "echo 0 > /sys/devices/system/cpu/cpu[0-3]/online"
Test: start some apps, observe libprocessgroup errors in the logcat
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ia91d8839d86787569c255481bde077be51c43d93
Merged-In: Ia91d8839d86787569c255481bde077be51c43d93
2021-12-12 13:19:42 +08:00
Android Build Coastguard Worker 164026a310 Snap for 7989966 from d1dbabbd4e to sc-d2-release
Change-Id: Iea24c40c7c87ef2bd7a3c8a7a7bfc9fac8740eb7
2021-12-11 02:08:48 +00:00
Yi-yo Chiang d1dbabbd4e Merge "Add /system_ext/etc/selinux/ to the debug policy search path for GSI" into sc-v2-dev 2021-12-10 04:05:11 +00:00
Wei Wang d2b270c063 libutils: do not follow process's group
1) App doesn't have cgroup access and there is no purpose of reading cgroup
for app. For system_server it should be known in foreground group. So
there is no benefit of reading group.

2) Reading cgroup in apps can also cause contention for other cgroup
operations.

3) vendor can change cgroup setting and get_sched_policy may return
incorrect information for get_sched_policy_profile_name.

Test: Boot
Bug: 210011562
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: I8e8c8b346984781c56ec93c0616121f7d5c99fe5
2021-12-10 02:53:08 +00:00
Android Build Coastguard Worker 206bbbd524 Snap for 7963886 from 4375229588 to sc-d2-release
Change-Id: Ia556bf64147d7ec8dff4c8daed025392e9cc06ca
2021-12-03 00:10:08 +00:00
Akilesh Kailash 4375229588 snapuserd: Address alignment fault on 32-bit systems
When the scratch space is mmap'ed, the metadata buffer
will be un-aligned. This may lead to alignment fault
on 32-bit systems. Address this by temporarily copying
it to buffer.

No perf impact as this code path is not in I/O path
and the copy is a for the size of metadata buffer which
is 8k.

Bug: 206426215
Test: Full and Incremental OTA on pixel
1: Compile snapuserd as 32 bit and reproduced the bug on pixel.
2: With fix - OTA applied successfully.
3: Reboot the device when merge was in-flight as the fix is primarily
in that path.
4: Verify merge completion and data integrity post merge.

Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: Icd4a21d6a61f1ab36e65994c06a4d049a2ee741c
Merged-In: I63c0d862057ebf138c9d1696a942030e30598739
2021-12-01 20:37:56 +00:00
Yi-Yo Chiang 1c1e267afc Add /system_ext/etc/selinux/ to the debug policy search path for GSI
This change only *adds* /system_ext/etc/selinux to the debug policy
search path, and does not change any preconditions to load the debug
policy. The device still needs to be bootloader-unlocked and has the
debug ramdisk flashed to be able to use the debug policy. The only thing
changed is that now the debug policy can be loaded from /system_ext or
/debug_ramdisk when system partition is compliance testing GSI.

The debug policy in the boot ramdisk may be outdated if the system
partition is flashed with a image built from a different revision.
This happens frequently when running the compliance testing VTS, where
the device is flashed with (A) GSI and (B) device vendor image & debug
boot image, and (A) and (B) are built from different git revisions.

To address this, we install a copy of the debug policy under
/system_ext, so that the version desync between (A) & (B) wouldn't be a
problem anymore because (A) no longer relies on the debug policy file
from (B).

Bug: 188067818
Test: Flash RQ2A.201207.001 bramble-user with debug ramdisk & flash
  gsi_arm64-user from master, device can boot and `adb root` works
Change-Id: I4d6235c73472e4d97619b2230292e6a0bc4b3e05
Merged-In: I4d6235c73472e4d97619b2230292e6a0bc4b3e05
(cherry picked from commit 650b29d2349253a0dd6000564ccb2c19b51352db)
2021-11-24 14:38:07 +08:00
Android Build Coastguard Worker dda092a884 Snap for 7906314 from 4f95599b96 to sc-d2-release
Change-Id: Iaa99f216a409e8ece99e19935000e730c47b1fde
2021-11-12 00:16:03 +00:00
Suren Baghdasaryan 4f95599b96 llkd: Disable in userdebug builds by default
While llkd helps in discovering issues in apps which leave zombies, it
creates issues for dogfooders when apps are killed. Disable it by
default.

Bug: 202411543
Test: boot and check llkd not running
Test: `setprop ro.llk.enable true` enables llkd
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: If93bf9e981eaa3921a9da5f3160db26c4fe17e66
Merged-In: If93bf9e981eaa3921a9da5f3160db26c4fe17e66
2021-11-11 01:45:06 +00:00
Android Build Coastguard Worker 472032df09 Snap for 7856912 from 921307851b to sc-d2-release
Change-Id: I33eba0ad0b965754b4e70296736916d929fb24e9
2021-10-26 23:11:10 +00:00
TreeHugger Robot 921307851b Merge "init.rc: Create a new group for dex2oat" into sc-v2-dev 2021-10-26 07:09:28 +00:00
Rick Yiu 567dd77c81 init.rc: Create a new group for dex2oat
Create a new group for dex2oat in cpu cgroup, which is dedicated for
dex2oat processes. Also modify task profiles for this change.

Bug: 201223712
Test: dex2oat group created
Change-Id: Ic61f4b8a64d01c03549b680970805e12b9ce4fcc
Merged-In: Ic61f4b8a64d01c03549b680970805e12b9ce4fcc
2021-10-22 22:22:28 +08:00
Android Build Coastguard Worker e217c7784c Snap for 7824833 from 77b37c9f87 to sc-d2-release
Change-Id: I5a9ab1c0cb775a8a9591fe83bc57545c191bb453
2021-10-14 23:09:30 +00:00
Thurston Dang 77b37c9f87 storageproxyd: discard writes when checkpointing, if necessary am: 98e7f427e8
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/16049468

Change-Id: I8b0d1da6d516313b5e672bc3a6c0ea8075e01c17
2021-10-14 00:47:08 +00:00
Android Build Coastguard Worker 353f9d0729 Snap for 7821078 from cb1fabeff6 to sc-d2-release
Change-Id: Id8c6ea1c0b9322ea84197d6703fd066ac017870a
2021-10-13 23:10:12 +00:00
Thurston Dang 98e7f427e8 storageproxyd: discard writes when checkpointing, if necessary
If a checkpointing operation is in progress, discard any write operations
that are flagged as STORAGE_MSG_FLAG_PRE_COMMIT_CHECKPOINT. In tandem
with trusty-side changes that set the flag appropriately, this avoids
the awkward case where the checkpoint is rolled back, which potentially
leads to inconsistency between the data and the superblock.

Based on Stephen's CL/1845477 "Add helper to check checkpoint state of
mounts".

Original change: https://android-review.googlesource.com/c/platform/system/core/+/1850058

Test: m storageproxyd
Bug: 194313068
Change-Id: I0924084f7f0b20018cbb71f5153469c8a686e262
Merged-In: I0924084f7f0b20018cbb71f5153469c8a686e262
(cherry picked from commit 34404f4ab1326eb179f889201dcfd04eb6002d0e)
2021-10-13 19:35:18 +00:00
Alexander Potapenko cb1fabeff6 Revert "Revert "init.rc: disable creation of bootreceiver tracing instance for kernels >=4.9 and <= 5.4"" am: 0e28aeb786
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/16045538

Change-Id: I144596dbd34448300b027b7890c1929344aa89b5
2021-10-13 17:46:52 +00:00
Alexander Potapenko 0e28aeb786 Revert "Revert "init.rc: disable creation of bootreceiver tracing instance for kernels >=4.9 and <= 5.4""
This reverts commit 220f604ca5.

Reason for revert: from bug 202436407 it looks like the initial revert wasn't needed.

Change-Id: I81dba47ee4bc55da2d4c5212dfc1b6200719b8be
2021-10-13 15:54:34 +00:00
Android Build Coastguard Worker 4e2d4852ad Snap for 7809322 from 4dc0b4e1cb to sc-d2-release
Change-Id: I9a597470580a9cd7310299e38c59ae442e4a9314
2021-10-09 21:09:22 +00:00
Android Build Coastguard Worker f15ba4e604 Snap for 7806961 from f8c43a23be to sc-d2-release
Change-Id: I221be30d139b1ee4320e6573bb0b52b00e72daa3
2021-10-09 01:08:47 +00:00
Wei Wang 4dc0b4e1cb Merge "libutils: use system_background for low prio tasks in framework" into sc-qpr1-dev am: ecaf9ef70a
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/15946148

Change-Id: I2094d7af01deb3ca3c8acd52da54e0849a8c0c73
2021-10-08 21:26:33 +00:00
Wei Wang 52dc14cece task_profiles: add ServicePerformance to legacy device policy am: 276ba2c75b
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/15998087

Change-Id: Iac66ba0d501e34679fefd259d3d1ee0306050d28
2021-10-08 21:26:32 +00:00
Wei Wang ecaf9ef70a Merge "libutils: use system_background for low prio tasks in framework" into sc-qpr1-dev 2021-10-08 21:14:04 +00:00
Wei Wang 276ba2c75b task_profiles: add ServicePerformance to legacy device policy
Since we are adding SCHED_SP_SYSTEM into framework, the policy is needed
on older releases as well.

Bug: 201428466
Test: Build
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: I0784820bfec84fd8ef98f2feb2caee084d0a14a2
Merged-In: I0784820bfec84fd8ef98f2feb2caee084d0a14a2
2021-10-08 21:13:54 +00:00
Chiayu Pei f8c43a23be Revert "init.rc: disable creation of bootreceiver tracing instance for kernels >=4.9 and <= 5.4" am: 220f604ca5
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/16013258

Change-Id: Ifc9e3b5176bfc16b39800fe95abbb629372dfa42
2021-10-08 11:33:32 +00:00
Chiayu Pei 220f604ca5 Revert "init.rc: disable creation of bootreceiver tracing instance for kernels >=4.9 and <= 5.4"
This reverts commit 4edda28b92.

Reason for revert: b/202436407

Change-Id: I4cdbdb756b9fc61bb6f5ff61335fec7d541ec6a2
2021-10-08 04:26:55 +00:00
Wei Wang 7ee4980dc2 libutils: use system_background for low prio tasks in framework
Bug: 201428466
Test: Build and boot check system_server's sched group
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: Iffc47fdaf3ef8fba6eb01a12cf534a0393e3e91c
Merged-In: Iffc47fdaf3ef8fba6eb01a12cf534a0393e3e91c
2021-10-07 17:58:44 +00:00