Commit graph

72808 commits

Author SHA1 Message Date
Konstantin Vyshetsky
81cc119eff fastbootd: allow passage of flags to open partition
Allow caller to pass additional flags when opening a partition. Obsolete
usage of boolean read, and make previous callers use O_RDONLY instead.
Explicitly OR (O_EXCL | O_CLOEXEC | O_BINARY) to keep existing design
working as is.

Test: flash locally and reach home screen
Bug: 205151372
Signed-off-by: Konstantin Vyshetsky <vkon@google.com>
Change-Id: I48fbca459a17fcf0b0926ab339585e3bd8e31e35
2021-11-04 12:05:48 -07:00
Treehugger Robot
52a2135180 Merge "cutils: only support safe list iteration." 2021-11-04 17:40:21 +00:00
Yifan Hong
95e2f7ffc8 Merge changes from topic "charger-vendor"
* changes:
  charger: vendor charger use resources from /vendor
  charger: make libhealthd_charger_ui vendor_available.
  libsuspend: vendor_available.
2021-11-03 18:53:33 +00:00
Elliott Hughes
6fa2e48db9 cutils: only support safe list iteration.
We've had two use-after-frees in the last month from this nonsense...

Bug: http://b/204925347
Test: treehugger
Change-Id: I5e1485253224e38ca51a7a077dbe65d19e39f817
2021-11-03 10:26:36 -07:00
Yi-Yo Chiang
ad0f69c5a6 Merge "libfiemap: array boundary check for fiemap.fm_extents[]" 2021-11-03 06:52:02 +00:00
Akilesh Kailash
3a1ddf5555 Merge "Revert "snapuserd: Add unit test for test merge code path"" 2021-11-03 03:21:53 +00:00
Akilesh Kailash
7ad63b4c77 Revert "snapuserd: Add unit test for test merge code path"
This reverts commit 1cc9818642.

Reason for revert: Failing build - There is a dependency with https://r.android.com/c/1843772/3

Change-Id: Iccac56cf4c7012d8732b4338eb7055e1b2451e3b
2021-11-03 02:19:00 +00:00
Akilesh Kailash
5b7d571b87 Merge "snapuserd: Add unit test for test merge code path" 2021-11-03 01:55:19 +00:00
Akilesh Kailash
1cc9818642 snapuserd: Add unit test for test merge code path
Most of the test cases are similar to dm-snapshot-merge.

Additional test cases have been added primarily to test
I/O's in parallel with merge.

Bug: 193863397
Test: snapuserd_test
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: If7fede1be6d678c8665e1f9369fd3c69f5d3c4df
2021-11-03 01:54:53 +00:00
Akilesh Kailash
1765610fa4 Merge changes I25fb5fce,I86cffff6,I031eb1a1,Ie40633c0,I08562b89
* changes:
  snapuserd: Sort REPLACE ops for batch merge
  snapuserd: API to query snapshot and merge status
  snapuserd: Wire up API's for Initiating and tracking Merge
  snapuserd: I/O requests which are not block aligned.
  snapuserd: Service I/O requests from dm-user
2021-11-03 01:45:03 +00:00
Yifan Hong
ac748369bb charger: vendor charger use resources from /vendor
For the vendor variant of libhealthd_mode_charger, read resources
from /vendor. The core variant continues to read resources from
/product, /system, and /res.

Test: run charger from /vendor manually
Bug: 203246116
Change-Id: Ia9df1d081a51783409b5dbd3e3d4719efc3cb6a7
2021-11-02 13:52:40 -07:00
Yifan Hong
e3ffd1bfc2 charger: make libhealthd_charger_ui vendor_available.
This is a prerequisite to move charger to vendor partition.

Because vendor domains can't read ro.charger.*, they are all assumed
to be the default value. They aren't set in the ecosystem anyway,
so it is time to deprecate them.

Test: builds
Bug: 203246116
Change-Id: I0b17e62ab3ac5a89df091333fd9f24e33bdfd49a
2021-11-02 13:52:40 -07:00
Yifan Hong
b200c60221 libsuspend: vendor_available.
This is needed by charger in vendor.

Test: builds
Bug: 203246116
Change-Id: I55c5cace9dcd7b2fd475d61234bd469428b4caac
2021-11-02 13:52:40 -07:00
Yifan Hong
9cef8ea99a Merge changes from topic "charger-aidl"
* changes:
  charger: Add API to replace ro.charger.enable_suspend
  charger: separate UI and HAL access.
2021-11-02 17:58:30 +00:00
Akilesh Kailash
2ba8eea489 snapuserd: Sort REPLACE ops for batch merge
Since we will be iterating forward for user-space
merge, we need to sort the blocks in increasing order
so that blocks can be batch merged if contiguous.

For dm-snapshot merging, we will continue to sort
in decreasing order.

Bug: 193863397
Test: Snapuserd_test
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: I25fb5fce054f716a2ad0dddc0d0c3afef18bc7ad
2021-11-02 08:09:38 +00:00
Akilesh Kailash
b94353cae0 snapuserd: API to query snapshot and merge status
Add new API to query the snapshot and merge status.
This will be used by libsnapshot.

Bug: 193863443
Test: Full OTA on CF
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: I86cffff6a979e2e2bf1d8d1a1770e209eeb4a47d
2021-11-02 07:34:36 +00:00
Akilesh Kailash
ff590a806c snapuserd: Wire up API's for Initiating and tracking Merge
Add new client API's for initiating and tracking merge.
These API's will be used by libsnapshot.

Track the merge completion in the server by walking through
all the partitions. Each worker thread will update the
merge completion as and when number of COW operations
are completed. Server will gather all the completions
of each partition and average it out. This is in sync
with the current merge completion tracking for dm-snapshot.

As a side effect, move the snapuserd_server.h/cpp files to
dm-snapshot-merge directory as it will only be a maintaining
code.

Bug: 193863443
Test: Snapuserd_test
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: I031eb1a11b0f426aafbed3d39d85b0c22b9030fb
2021-11-02 07:32:09 +00:00
Akilesh Kailash
8abe050eb5 snapuserd: I/O requests which are not block aligned.
If the I/O request is for a sector which is not block
aligned, then we will not find the mapping directly
to a COW op as each op is block aligned. Thus, we
handle them by chopping the I/O request and processing
the unaligned data. Furthermore, if the request
doesn't map to any of the COW ops, then route the
I/O to the base device.

Bug: 196929997
Test: Full OTA on CF - during boot up, we get an I/O request
to read superblock on system partition which is not block aligned.

Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: Ie40633c0c6bc0c87b681c051c74c0ac787e34d9c
2021-11-02 07:17:23 +00:00
Akilesh Kailash
be46ca7ff3 snapuserd: Service I/O requests from dm-user
Now that merging is done in user-space and
partitions are mounted off dm-user directly,
daemon will have to serve every I/O request.

Daemon has to handle this wherein we need to
check if the given I/O request block has been
modified in the OTA. Furthermore, if merge is
in-progress, we will have to synchronize with
the merge thread before servicing the I/O.

If the I/O request maps to a REPLACE or ZERO op,
we will just read the data from COW device.

If the I/O request maps to a COPY or XOR op,
the worker thread will have to synchronize
with the merge thread and if the merge is
in progress, fetch the data directly from RA buffer.

This patch handles I/O requests only if the
sectors are 4k aligned.

Bug: 196929997
Test: snapuserd_test

Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: I08562b8927e1c22dd9d9ef160e873280854eac99
2021-11-02 07:08:30 +00:00
Yi-Yo Chiang
0f62506139 libfiemap: array boundary check for fiemap.fm_extents[]
Ensure we have at least one element before we try to access the last
element. Else the array index of the last element may underflow,
0ull - 1 == ~0ull == UINT64_MAX.

Bug: 204536075
Test: atest fiemap_writer_test
Change-Id: Ic390d108bf789cfe136fb5dfe2983f3c7d6f7e48
2021-11-02 11:38:31 +08:00
Shaju Mathew
cab12f8ae2 Merge "Addressing error-code propagation for remount service." 2021-11-02 02:11:57 +00:00
Shaju Mathew
7e5451a6ab Addressing error-code propagation for remount service.
Bug: 201596822

Test: Local test (isolated to host)

$ adb -s 8BDAY00CM6 root
adbd is already running as root
$ adb -s 8BDAY00CM6 remount
Disabling verity for /system
Using overlayfs for /system
Disabling verity for /system_ext
Using overlayfs for /system_ext
Disabling verity for /vendor
Using overlayfs for /vendor
Disabling verity for /product
Using overlayfs for /product
remount succeeded.. now reboot device for settings refresh
$ echo $?
0
$ adb -s 8BDAY00CM6 unroot
restarting adbd as non root
$ adb -s 8BDAY00CM6 remount
Not running as root. Try "adb root" first.
remount failed
$ echo $?
3

Signed-off-by: Shaju Mathew <shaju@google.com>
Change-Id: I8e6d0735d2da0ed58cae867db2e4736abb86d351
2021-11-01 18:05:45 -07:00
David Anderson
51f36da47a Merge "libfiemap: Only call FS_IOC_FIEMAP once." 2021-11-01 22:55:45 +00:00
David Anderson
de2ec0b427 libfiemap: Only call FS_IOC_FIEMAP once.
The kernel can return different compatible ranges on each call, depending on
how it decides to merge contiguous extents in the results. To avoid the
complexity of requerying the ioctl, just do one query up to the maximum
allowed extent size.

Bug: 204536075
Test: install DSU on cuttlefish
      fiemap_test
Change-Id: I4d569e3e6feed14c91a5f500296623888060dcad
2021-11-01 13:44:56 -07:00
Yifan Hong
8e55134f43 charger: Add API to replace ro.charger.enable_suspend
The system property is set by vendor partition but owned by platform,
hence vendor domains can't read this value. Add an API in
ChargerConfigurationInterface so that HAL implementations can override
its value.

Other ro.charger.* sysprops are unused, hence no APIs are created for
them.

Test: manual
Bug: 203246116

Change-Id: I583c21e58ed3d912b156e253d6a4b46a0378f11e
2021-11-01 12:38:56 -07:00
Yifan Hong
b5d7033dcc charger: separate UI and HAL access.
Abstract all the HIDL-ness from charger so an AIDL HAL
can later replace the HIDL HAL.

Created libhealthd_charger_ui that is responsible for
UI stuff in charger. Then libhealthd_charger is now the
charger library backed by HIDL HAL.

Bug: 170338625
Bug: 203246116

Test: charger_test

Change-Id: I193bb76afa18b3367f24796ac53b1760650e8683
2021-11-01 12:38:56 -07:00
David Drysdale
a86af7c9b1 Merge "KeyMint: don't mix Binder and std shared pointers" 2021-11-01 06:35:12 +00:00
Maciej Żenczykowski
04a1bf7c0b Merge "Fix 32-bit userspace on 64-bit kernel quota2 compatibility." 2021-10-30 20:04:29 +00:00
Christopher Ferris
e88e9922d5 Merge "Update for libunwindstack shared_ptr MapInfos." 2021-10-30 01:13:53 +00:00
Colin Cross
143ba0d31c Merge "Use HOST_OUT_EXECUTABLES instead of SOONG_HOST_OUT_EXECUTABLES" 2021-10-29 22:35:55 +00:00
Tianjie Xu
f1c8904e95 Merge "Fix unittest that checks build id" 2021-10-29 22:15:35 +00:00
Tianjie
c8cf2a4155 Fix unittest that checks build id
Should check ro.build.id instead of the ro.boot.build.id. The former
is a component of the build fingerprint.

Bug: 204507710
Test: run CtsInitTestCases
Change-Id: Iee13b30b195685c2461255f946685a288f352e06
2021-10-28 21:51:43 -07:00
Christopher Ferris
c67760611c Update for libunwindstack shared_ptr MapInfos.
Bug: 120606663

Test: Unit tests pass.
Change-Id: Ieae157388e8571345ed8968a2b5c2aa34464689f
Merged-In: Ieae157388e8571345ed8968a2b5c2aa34464689f
(cherry picked from commit 853733b627)
2021-10-28 15:05:39 -07:00
David Drysdale
fcf3fc08e4 KeyMint: don't mix Binder and std shared pointers
Bug: 203871378
Test: VtsAidlKeyMintTargetTest, TreeHugger
Change-Id: I8671342939af2bbdef643be9ce81b0bb9e7ae1a9
2021-10-28 15:39:34 +01:00
Yi-Yo Chiang
6a58c59269 Merge "Fix ubsan error path found by libfstab_fuzzer" 2021-10-27 12:08:12 +00:00
Yi-Yo Chiang
fb62a719a2 Fix ubsan error path found by libfstab_fuzzer
Fix: 204255714
Bug: 204056804
Test: Rerun the fuzzer
Change-Id: Ief4cd12c414033fc0a0c2891433a16c35c7a6e79
2021-10-27 12:06:41 +00:00
Treehugger Robot
af97deddb1 Merge "Sets 'verity_update_state' in init.rc" 2021-10-27 07:23:47 +00:00
Yi-Yo Chiang
a68b83fd60 Merge "libfstab_fuzzer: Add dictionary to guide the fuzzer" 2021-10-26 20:34:47 +00:00
Treehugger Robot
8d4993316b Merge "Add a bug component for test vts_libsnapshot_test." 2021-10-26 19:15:21 +00:00
Suren Baghdasaryan
43293deffe Merge "libprocessgroup: Prevent error spam when tests disable all cpus in a cpuset" 2021-10-26 16:23:24 +00:00
Yi-Yo Chiang
ed72e37c4a libfstab_fuzzer: Add dictionary to guide the fuzzer
This is probably an overkill, but still, add a collection of
interesting keywords that may appear in a fstab file.

Also add myself to the "CC" list of this fuzz target.

BYPASS_INCLUSIVE_LANGUAGE_REASON="slave" or MS_SLAVE is a mount flag

Bug: 204056804
Test: adb shell /data/fuzz/x86_64/libfstab_fuzzer/libfstab_fuzzer \
  -dict=/data/fuzz/x86_64/libfstab_fuzzer/fstab.dict
Change-Id: Ife55837212a711dcbeed4f00d97da0cb022c7156
2021-10-26 23:03:33 +08:00
Treehugger Robot
6aa256fdf6 Merge "Add libfstab_fuzzer that fuzzes ReadFstabFile()" 2021-10-26 07:50:24 +00:00
Yi-Yo Chiang
b398a0bc73 Add libfstab_fuzzer that fuzzes ReadFstabFile()
Just a modest initial implementation. Uses the fuzz data as the fstab
file content directly.

Bug: 204056804
Test: lunch aosp_cf_x86_64_phone-userdebug
  SANITIZE_TARGET=address m libfstab_fuzzer
  adb sync data
  adb shell /data/fuzz/x86_64/libfstab_fuzzer/libfstab_fuzzer
Change-Id: I7976a6ee124e9b5da59cfa7f4bae9699be3f1474
2021-10-26 14:22:36 +08:00
Colin Cross
8a87bdf80d Use HOST_OUT_EXECUTABLES instead of SOONG_HOST_OUT_EXECUTABLES
Soong is installing binaries directly to HOST_OUT_EXECUTABLES instead
of SOONG_HOST_OUT_EXECUTABLES, dist from the HOST_OUT_EXECUTABLES
location.

Bug: 204136549
Test: m checkbuild
Change-Id: Iee7ae8d1ed478aa2a0344fc9f54ad2c146841cb0
2021-10-25 22:41:07 -07:00
Wei Wang
3ef7c2373a Merge "init.rc: Create a new group for dex2oat" 2021-10-26 00:33:50 +00:00
Maciej Żenczykowski
28b94af1b2 Fix 32-bit userspace on 64-bit kernel quota2 compatibility.
Test: TreeHugger, manual testing of nearly identical code snippets.
Bug: 195716186
Bug: 203385942
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I42773c2b553a08919583b7932e757564b352c507
2021-10-25 16:24:49 -07:00
Suren Baghdasaryan
ec88556460 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
2021-10-25 16:18:08 -07:00
Rick Yiu
014446d702 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
2021-10-22 22:20:07 +08:00
Bowgo Tsai
5998c74d7a Sets 'verity_update_state' in init.rc
This is required since Android 12, because
CtsNativeVerifiedBootTestCases will read property
"partition.${partition}.verified.hash_alg" to
check that sha1 is not used.

Also see https://r.android.com/1546980 for more details.

Bug: 175236047
Bug: 203720638
Test: build and boot a device
Change-Id: I300265f4af9c2781d40537f391bda9eaf62c27ba
2021-10-21 21:38:22 +08:00
Treehugger Robot
c39d42ddde Merge "Added fastboot_fuzzer" 2021-10-21 01:22:51 +00:00