Commit Graph

71997 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
Alexander Potapenko 4224e6af27 init.rc: disable creation of bootreceiver tracing instance for kernels >=4.9 and <= 5.4 am: 4edda28b92
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/15994846

Change-Id: Id9689529bf82732e052bd45edcf2f542d58b6bf9
2021-10-06 22:09:07 +00:00
TreeHugger Robot bbd75121ac Merge "Restrict creation of bootreceiver tracing instance to 64-bit systems." into sc-qpr1-dev am: b0cd5f87e8
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/15994475

Change-Id: I81826fce89727ef04033bd19adb2ed68fa6f4470
2021-10-06 18:19:22 +00:00
Alexander Potapenko ed6511f5d4 init: introduce ro.kernel.version property am: e69aea9256
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/15994474

Change-Id: I2e2a67eaf3c44151b7a8fad0c33160bb5e6e6c67
2021-10-06 18:19:21 +00:00
Alexander Potapenko 4edda28b92 init.rc: disable creation of bootreceiver tracing instance for kernels >=4.9 and <= 5.4
The tracing instance takes extra RAM and is not needed on devices running older kernels.

Bug: 194156700
Test: manual on a Pixel device

Signed-off-by: Alexander Potapenko <glider@google.com>
Merged-In: I794062741688ebea0e4bc500723a966f8f646ee1
Change-Id: Ie8614e67a89cea67bed88427820fefdf110713c9
2021-10-06 18:12:46 +00:00
TreeHugger Robot b0cd5f87e8 Merge "Restrict creation of bootreceiver tracing instance to 64-bit systems." into sc-qpr1-dev 2021-10-06 18:06:20 +00:00
Alexander Potapenko b5f93dfa5d Restrict creation of bootreceiver tracing instance to 64-bit systems.
The main users of this instance are KFENCE and MTE-aided KASAN, which are only supported on arm64.
Skip creation of this tracing instance on 32-bit systems to save ~6Mb memory on low-end devices.

Bug: 195089948
Bug: 194719088
Bug: 194156700
Test: manual on Pixel device
Merged-In: Icaf762715fed7a282b1ad738c10bcb45dc848f4d
Change-Id: I61694ce174fa745ef9fd50ca7464b5a9e1d1e011
2021-10-06 16:13:06 +00:00
Alexander Potapenko e69aea9256 init: introduce ro.kernel.version property
This property will hold the major.minor part of the kernel version (e.g. "5.4"), allowing init scripts to act depending on that version, enabling and disabling certain features.

Bug: 194156700
Test: manual on a Pixel device
Signed-off-by: Alexander Potapenko <glider@google.com>
Merged-In: Icec640b8a7150b344d9aa3bc0bdbcdae050c7c45
Change-Id: I5af411e39da600e5e0f6703f3a2a4930d509e29d
2021-10-06 16:12:41 +00:00
Stephen Crane 535c977f69 [automerger skipped] storageproxyd: Retry RPMB request on UNIT ATTENTION am: ab2257ee48 -s ours am: 857115b1ef -s ours
am skip reason: Merged-In Ib970e779365bb396756c114684c7f6e56a737ab1 with SHA-1 d1a212e0d8 is already in history

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

Change-Id: I84a528f7337f3d2b1167c522ae80f460bbe79d45
2021-10-05 19:36:30 +00:00
Stephen Crane 3875ee806c [automerger skipped] storageproxyd: Fix inverted conditional in error checking am: 237679cfca -s ours am: 122048f24c -s ours
am skip reason: Merged-In I3b84188aabe58345a83d2fd57bb8103e730cf365 with SHA-1 dcdac24306 is already in history

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

Change-Id: I51484d6a348e037b6a03bd2d43675030b34bd717
2021-10-05 19:36:29 +00:00
Stephen Crane 39e256cb31 [automerger skipped] [storageproxyd] Dump binary buffers to log instead of stderr am: 77e2af18be -s ours am: c898d12eda -s ours
am skip reason: Merged-In Iecc0d4680420bb92c94be628789093888a2f1941 with SHA-1 f647221827 is already in history

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

Change-Id: I782b7b1e24622e2c4b5fc8174703d8a4108df10c
2021-10-05 19:36:29 +00:00
Stephen Crane 56428d1f7c [automerger skipped] storageproxyd: Add logging of failed RPMB transactions am: bf6e22a318 -s ours am: a2613eace1 -s ours
am skip reason: Merged-In I928ddebcb65aa6c305d3dcab7c64bd19d11a50fa with SHA-1 642d977bc8 is already in history

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

Change-Id: I637187d82ca9028e23f9abee191fe418450fea06
2021-10-05 19:36:28 +00:00
Stephen Crane 934043d87e [automerger skipped] storageproxyd: Add file handle param to debug buffer print am: 4ee811ee46 -s ours am: d10e28fc29 -s ours
am skip reason: Merged-In Iade322a21312a676b3599bddafdfc43b599617ea with SHA-1 3bb483b196 is already in history

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

Change-Id: Ia0454c9c8939b5626367db01bd2a8b5198a7f659
2021-10-05 19:36:27 +00:00
Stephen Crane 857115b1ef [automerger skipped] storageproxyd: Retry RPMB request on UNIT ATTENTION am: ab2257ee48 -s ours
am skip reason: Merged-In Ib970e779365bb396756c114684c7f6e56a737ab1 with SHA-1 d1a212e0d8 is already in history

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

Change-Id: I665ffb3d37b5fa4c1eeb61b5ddf249f2c754f27a
2021-10-05 19:22:00 +00:00
Stephen Crane 122048f24c [automerger skipped] storageproxyd: Fix inverted conditional in error checking am: 237679cfca -s ours
am skip reason: Merged-In I3b84188aabe58345a83d2fd57bb8103e730cf365 with SHA-1 dcdac24306 is already in history

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

Change-Id: I7b4344764e66de4a2848dec9319c6e3abc89751e
2021-10-05 19:21:59 +00:00
Stephen Crane c898d12eda [automerger skipped] [storageproxyd] Dump binary buffers to log instead of stderr am: 77e2af18be -s ours
am skip reason: Merged-In Iecc0d4680420bb92c94be628789093888a2f1941 with SHA-1 f647221827 is already in history

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

Change-Id: I55e606476410febd80dbad2662f6f75c3521d239
2021-10-05 19:21:59 +00:00
Stephen Crane a2613eace1 [automerger skipped] storageproxyd: Add logging of failed RPMB transactions am: bf6e22a318 -s ours
am skip reason: Merged-In I928ddebcb65aa6c305d3dcab7c64bd19d11a50fa with SHA-1 642d977bc8 is already in history

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

Change-Id: Ifa30cff385ebaf558bde531b0bbc2777f9fbdd4b
2021-10-05 19:21:58 +00:00
Stephen Crane d10e28fc29 [automerger skipped] storageproxyd: Add file handle param to debug buffer print am: 4ee811ee46 -s ours
am skip reason: Merged-In Iade322a21312a676b3599bddafdfc43b599617ea with SHA-1 3bb483b196 is already in history

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

Change-Id: I3e4dc6d20f02fcfcb5118adc7c21caa1fde4df06
2021-10-05 19:21:58 +00:00
Stephen Crane ab2257ee48 storageproxyd: Retry RPMB request on UNIT ATTENTION
Attempts a retry of the intial write or read when an RPMB command
triggers a UNIT ATTENTION condition. This causes the UA status to be
reset and hopefully result in a successful command. This runs the risk
of retrying a successful write, but we wouldn't have been able to get
the RPMB response after that write anyway due to the UA condition.

Test: m storageproxyd
Bug: 194712579
Change-Id: Ib970e779365bb396756c114684c7f6e56a737ab1
Merged-In: Ib970e779365bb396756c114684c7f6e56a737ab1
(cherry picked from commit a9085181afaa80ac8b4cfb82a6762e336b1e2500)
2021-10-05 09:56:43 -07:00
Stephen Crane 237679cfca storageproxyd: Fix inverted conditional in error checking
check_scci_sense (now renamed unexpected_scsi_sense) was supposed to
return false iff the sense data was valid and did not contain an error.
This return value was inverted. Invert the return values and rename the
function to clarify its role.

Test: m storageproxyd
Bug: 195544379
Change-Id: I3b84188aabe58345a83d2fd57bb8103e730cf365
Merged-In: I3b84188aabe58345a83d2fd57bb8103e730cf365
2021-10-05 09:56:34 -07:00
Stephen Crane 77e2af18be [storageproxyd] Dump binary buffers to log instead of stderr
Rewrites the buffer logging to print to the Android log instead of
stderr. The storageproxyd service is started by init and stderr is not
logged anywhere. Because we want to log sense data errors under normal
operation, we need to log to logcat instead of stderr.

Test: Define RPMB_DEBUG, build for qemu-trusty, run, inspect logcat
Bug: 195544379
Change-Id: Iecc0d4680420bb92c94be628789093888a2f1941
Merged-In: Iecc0d4680420bb92c94be628789093888a2f1941
2021-10-05 09:55:10 -07:00
Stephen Crane bf6e22a318 storageproxyd: Add logging of failed RPMB transactions
Adds parsing and logging of SCSI errors from SG_IO calls for RPMB. Does
not alter behavior of the RPMB proxy in response to these errors.

Test: m storageproxyd
Bug: 195544379
Change-Id: I928ddebcb65aa6c305d3dcab7c64bd19d11a50fa
Merged-In: I928ddebcb65aa6c305d3dcab7c64bd19d11a50fa
2021-10-05 09:55:03 -07:00
Stephen Crane 4ee811ee46 storageproxyd: Add file handle param to debug buffer print
Adds a file handle parameter to the debug print_buf function to allow
printing to either stdout or stderr.

Test: m storageproxyd
Bug: 195544379
Change-Id: Iade322a21312a676b3599bddafdfc43b599617ea
Merged-In: Iade322a21312a676b3599bddafdfc43b599617ea
(cherry picked from commit 3bb483b196)
2021-10-05 09:54:58 -07:00
Stephen Crane fdcfe7d643 storageproxyd: Retry RPMB request on UNIT ATTENTION am: d1a212e0d8
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/15972861

Change-Id: Ibdcf151f12cbed45879140bcce4eac72ebf75b18
2021-10-04 23:35:09 +00:00
Stephen Crane d1a212e0d8 storageproxyd: Retry RPMB request on UNIT ATTENTION
Attempts a retry of the intial write or read when an RPMB command
triggers a UNIT ATTENTION condition. This causes the UA status to be
reset and hopefully result in a successful command. This runs the risk
of retrying a successful write, but we wouldn't have been able to get
the RPMB response after that write anyway due to the UA condition.

Test: m storageproxyd
Bug: 194712579
Change-Id: Ib970e779365bb396756c114684c7f6e56a737ab1
Merged-In: Ib970e779365bb396756c114684c7f6e56a737ab1
(cherry picked from commit a9085181afaa80ac8b4cfb82a6762e336b1e2500)
2021-10-04 18:50:24 +00:00
Stephen Crane 89d67fb45c storageproxyd: Fix inverted conditional in error checking am: dcdac24306
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/15910108

Change-Id: I9401a7e321fb7def9bae76fed54e89a17bfcddc6
2021-09-25 17:14:54 +00:00
Stephen Crane dcdac24306 storageproxyd: Fix inverted conditional in error checking
check_scci_sense (now renamed unexpected_scsi_sense) was supposed to
return false iff the sense data was valid and did not contain an error.
This return value was inverted. Invert the return values and rename the
function to clarify its role.

Test: m storageproxyd
Bug: 195544379
Change-Id: I3b84188aabe58345a83d2fd57bb8103e730cf365
Merged-In: I3b84188aabe58345a83d2fd57bb8103e730cf365
2021-09-24 14:35:04 -07:00
Stephen Crane 878af40b53 Merge changes Iecc0d468,I928ddebc,Iade322a2 into sc-qpr1-dev am: 1d9e35c5bf
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/15840709

Change-Id: I1d2efafb1d84581bb72359f3fa411a596a057f57
2021-09-17 23:33:43 +00:00
Stephen Crane 151adfd2ce storageproxyd: Add logging of failed RPMB transactions am: 642d977bc8
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/15789187

Change-Id: I2e54d68b2f34880050f5e8eaba6871409a8a315f
2021-09-17 23:33:43 +00:00
Stephen Crane 7e23887bf2 storageproxyd: Add file handle param to debug buffer print am: 3bb483b196
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/15787946

Change-Id: I4c8edb5e565776803cabc21efbedfcb9786a8172
2021-09-17 23:33:42 +00:00
Stephen Crane 1d9e35c5bf Merge changes Iecc0d468,I928ddebc,Iade322a2 into sc-qpr1-dev
* changes:
  [storageproxyd] Dump binary buffers to log instead of stderr
  storageproxyd: Add logging of failed RPMB transactions
  storageproxyd: Add file handle param to debug buffer print
2021-09-17 23:17:52 +00:00
Akilesh Kailash c9a4c17a1a Merge changes I779184f1,I241ee11d into sc-qpr1-dev am: d6383199e8
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/15825056

Change-Id: I1eb2a86623258bf10081f908bfc3b6187b244e93
2021-09-17 18:33:14 +00:00