Commit graph

81743 commits

Author SHA1 Message Date
David Anderson
f489314dec Merge changes from topic "lpdump-snapshots" into main
* changes:
  Remove local_include_dirs from fs_mgr_defaults.
  Allow processes in the "system" group to read /metadata/ota.
2023-07-17 16:55:14 +00:00
Treehugger Robot
de5ba5c43a Merge "libsnapshot: GetReminingTime not required after mapping dm-user" into main 2023-07-17 16:52:51 +00:00
Akilesh Kailash
74c55e94c9 libsnapshot: GetReminingTime not required after mapping dm-user
After MapDmUserCow, there is no further calls in this function. Snapshot
is mapped; Hence, checking remaining time is not required as
it may return false if the time was exceeded. This would mean function returning false even though snapshots were successfully mapped.

Bug: 291288998
Test: OTA

Change-Id: I4fd8fa6ef90a48885392297f217361507268ba51
Signed-off-by: Akilesh Kailash <akailash@google.com>
2023-07-15 05:44:05 +00:00
Eric Biggers
6044e8e444 Merge "init.rc: start update_verifier instead of update_verifier_nonencrypted" into main 2023-07-14 20:32:30 +00:00
Andrew Walbran
dcac88ceac Merge "Add safety comments." into main 2023-07-14 19:34:11 +00:00
David Anderson
07339000d4 Remove local_include_dirs from fs_mgr_defaults.
fs_mgr_defaults gets used in lots of places, propagate
local_include_dirs to where it's needed so it doesn't cause problems on
modules that don't have an "includes" directory.

Bug: 291083311
Test: builds
Change-Id: Ief2f6362f584b99d3e2dc7dc1b46450609ad189d
2023-07-14 12:30:35 -07:00
David Anderson
f572053dab Merge "libsnapshot: Move export_include_dirs to correct location." into main 2023-07-14 17:12:52 +00:00
David Anderson
a71faae86f Allow processes in the "system" group to read /metadata/ota.
lpdumpd runs as "system", not "root". Adjust the DAC permissions of
/metadata/ota so it can call SnapshotManager::Dump.

Bug: 291083311
Test: lpdump
Change-Id: I97fd7eb2055cf6d31fd42f1021e2f99edbdb838a
2023-07-14 09:01:05 -07:00
David Anderson
edeae250c9 libsnapshot: Move export_include_dirs to correct location.
Bug: 291083311
Test: builds
Change-Id: I7a547bb0b2c06f312f83a6b8659a4e30e97c8438
2023-07-14 09:01:04 -07:00
David Anderson
3d0a332ff5 Merge "fs_mgr: Split fs_mgr_overlayfs into two separate files." into main 2023-07-14 15:56:15 +00:00
Kiyoung Kim
e7abd861da Merge "Enable ABI dump for libcutils" into main 2023-07-14 00:57:02 +00:00
David Anderson
bb235ebf48 Merge "snapuserd: Fix bool/int return value mismatches." into main 2023-07-13 21:17:30 +00:00
David Anderson
f8f3b627ae fs_mgr: Split fs_mgr_overlayfs into two separate files.
One of the paint points for fs_mgr_overlayfs is that mounting and
scratch management code are somewhat unrelated but very intertwined in
the same file.

Split it into two files: fs_mgr_overlayfs_mount, which is only for
mount-related code, and fs_mgr_overlayfs_control, which is only for
setup/teardown code.

The code removed from fs_mgr_overlayfs_control.cpp is code that moved
to fs_mgr_overlayfs_mount.cpp.

This converts a bunch of functions to "static", and splits
fs_mgr_priv_overlayfs.h into two new files (fs_mgr_overlayfs_mount.h and
fs_mgr_overlayfs_control.h).

Bug: N/A
Test: remount
Change-Id: I83da43652b4787f344da75a1d30177df1d7f63b2
2023-07-13 13:01:20 -07:00
Eric Miao
e91538a6de Merge "libutils: Improve performance of utf8_to_utf16/utf16_to_utf8" into main 2023-07-13 16:46:44 +00:00
David Anderson
77280caed1 snapuserd: Fix bool/int return value mismatches.
Bug: 288273605
Test: snapuserd_test, ota
Change-Id: I06d641d3255711dd51583ea9bd9fd6a1acdc7bb2
2023-07-13 08:46:41 -07:00
Treehugger Robot
ed2618bc98 Merge "Workaround for Global ThinLTO" into main 2023-07-13 09:33:16 +00:00
Jooyung Han
54b86e7b7a Workaround for Global ThinLTO
Global string literals are not initialized correctly with the new
config.

This change is a workaround by changing them into plain C literals until
we have a better solution.

Bug: 291033685
Test: adb-remount-test.sh
Change-Id: I178286133f55ff5dc11030fa132a9e6db0747ae7
2023-07-13 17:36:27 +09:00
Kiyoung Kim
a4648c2be0 Enable ABI dump for libcutils
Enable ABI dump for libcutils, so ABI can be stabilized from any update
after official release.

Bug: 254141417
Test: abidiff intermediates found from libcutils.vendor build
Change-Id: Ic27c82b908b7836c7bc538a24202ed8adba4d048
2023-07-13 07:23:39 +00:00
Treehugger Robot
30718e7431 Merge "libprocessgroup: Remove isolated UID cgroup directories" into main 2023-07-12 23:45:28 +00:00
Eric Miao
cb199b4795 libutils: Improve performance of utf8_to_utf16/utf16_to_utf8
This CL improves the performance of below functions in helping with conversion
between utf8/utf16 with libutils:

  - utf8_to_utf16_length
  - utf8_to_utf16
  - utf16_to_utf8_length
  - utf16_to_utf

The basic idea is to keep the loop as tight as possible for the most
common cases, e.g. in UTF16-->UTF8 case, the most common case is
when the character is < 0x80 (ASCII), next is when it's < 0x0800 (
most Latin), and so on.

This version of implementation reduces the number of instructions
needed for every incoming utf-8 bytes in the original implementation
where:

  1) calculating how many bytes needed given a leading UTF-8 byte
     in utf8_codepoint_len(), it's a very clever way but involves
     multiple instructions to calculate regardless

  2) and an intermediate conversion to utf32, and then to utf16
     utf8_to_utf32_codepoint()

The end result is about ~1.5x throughput improvement.

Benchmark results on redfin (64bit) before the change:

utf8_to_utf16_length: bytes_per_second=307.556M/s
utf8_to_utf16:        bytes_per_second=246.664M/s
utf16_to_utf8_length: bytes_per_second=482.241M/s
utf16_to_utf8:        bytes_per_second=351.376M/s

After the change:

utf8_to_utf16_length: bytes_per_second=544.022M/s
utf8_to_utf16:        bytes_per_second=471.135M/s
utf16_to_utf8_length: bytes_per_second=685.381M/s
utf16_to_utf8:        bytes_per_second=580.004M/s

Ideas for future improvement could include alignment handling and loop
unrolling to increase throughput more.

This CL also fixes issues below:

  1. utf16_to_utf8_length() should return 0 when the source string has
     length of 0, the original code returns -1 as below:

    ssize_t utf16_to_utf8_length(const char16_t *src, size_t src_len)
    {
        if (src == nullptr || src_len == 0) {
            return -1;
        }
	...

  2. utf8_to_utf16() should check whether input string is valid.

Change-Id: I546138a7a8050681a524eabce9864219fc44f48e
2023-07-12 13:23:07 -07:00
T.J. Mercier
9c8c748c11 libprocessgroup: Remove isolated UID cgroup directories
Global UID level cgroup removal was eliminated because of a race
between app launch and app killing using the same directory name. [1]

However isolated app UIDs are assigned sequentially, and are
basically never reused until we wrap around the large range of
isolated UIDs. This leaves thousands of isolated cgroup directories
unused, which consumes kernel memory and increases memory reclaim
overhead. Remove this subset of UID level cgroup directories when
killing process groups.

[1] d0464b0c01

Test: 50 cycle ACT leaves 1000 fewer empty isolated cgroups
Bug: 290953668
Change-Id: If7d2a7b8eec14561a72208049b74ff785ca961bd
2023-07-12 18:29:21 +00:00
Tomasz Wasilczyk
21841d4b8b Merge "Migrate gettid to GetThreadId" into main 2023-07-12 17:36:41 +00:00
Daniel Zheng
3062ca401e Merge "Turning on fastboot-info" into main 2023-07-12 16:51:57 +00:00
Daniel Zheng
e259c2dc17 Merge "Adding flag to disable fastboot_info" into main 2023-07-12 16:51:50 +00:00
Tomasz Wasilczyk
0de2195738 Migrate gettid to GetThreadId
Bug: 289414897
Test: it builds
Change-Id: If1214a181d4e9a193adf1bac0d35e7e3ac6c27db
2023-07-12 08:58:02 -07:00
David Anderson
80afdc08f5 Merge "snapuserd: Restrict where reads/writes to dm_user_header happen." into main 2023-07-12 03:09:06 +00:00
Daniel Zheng
dc8ae8c55a Merge "Fastboot-info testing" into main 2023-07-11 21:05:35 +00:00
Daniel Zheng
e1a473cdef Merge "Asserting flashing plan is used in do_flash" into main 2023-07-11 20:51:52 +00:00
Daniel Zheng
460631c028 Merge "Mocking get_uint_var()" into main 2023-07-11 20:51:47 +00:00
Daniel Zheng
6acfe9bcd0 Turning on fastboot-info
turning on fastboot-info by default again

Test: fastboot flashall
Change-Id: I6b8bb0d145af37d437419a5e6cee70158ed553ae
2023-07-11 12:53:30 -07:00
Daniel Zheng
63dfeaae7a Adding flag to disable fastboot_info
Adding flag to override fastboot_info for a quick fix in case
fastboot_info format is wrong

Test: fastboot flashall
Change-Id: I1f41646f14d747ce7ac7636ca9ced7279e13f7b0
2023-07-11 12:53:30 -07:00
Daniel Zheng
eabfe272c3 Fastboot-info testing
adding test to compare task list formed from fastboot-info vs list
formed from image list. To test, we need to set sparse_limit in flashing
plan and turn off update-super-optimization. The list of partitions to
be flashed by parsing fastboot-info should be a superset of the
partitions flashed by the hardcoded list. Changing is_retrofit_device()
to also take in a fastboot driver so we can pass in a mock

Test: fastboot_test
Bug: 194686221
Change-Id: Ib860c24c85779de1fbaa6bec8778e1f5ebb9475a
2023-07-11 12:53:29 -07:00
Daniel Zheng
59589d47db Asserting flashing plan is used in do_flash
Adding check to ensure flashing plan is used in do_flash. FlashingPlan
should never be null

Test: fastboot flashall -w
Change-Id: I8e69326c59b31c7b54d6d2e04c8ce5c0f12693a7
2023-07-11 12:44:13 -07:00
Daniel Zheng
a0d2401d23 Mocking get_uint_var()
Changing implementation to have mock fastboot driver return a the
sparse_limit rather than modifying the variable inside of flashing plan

Test: fastboot_test
Change-Id: I850ccd5bd09b6a8479ccc8cf7bf1d227abb87e3a
2023-07-11 12:44:13 -07:00
Treehugger Robot
b95f100640 Merge "NetlinkEvent: trivial simplification." into main 2023-07-11 19:03:06 +00:00
Eric Biggers
620ea56515 Merge "init.rc: merge the zygote-start actions" into main 2023-07-11 15:56:36 +00:00
Eric Biggers
6e8e8ac71f init.rc: start update_verifier instead of update_verifier_nonencrypted
The "update_verifier_nonencrypted" service is being replaced with simply
"update_verifier", so update init.rc accordingly.

Bug: 208476087
Test: presubmit
Change-Id: I58f3fb25167ff7d3679c72e5e9c012f02fa5b516
2023-07-11 00:05:35 +00:00
Eric Biggers
fac2b18fff init.rc: merge the zygote-start actions
The three actions for "zygote-start" are identical except for their
property triggers.  This seems to have been left over from when Android
supported both File Based Encryption (FBE) and Full Disk Encryption
(FDE), causing there to be four possible encryption states:

- ro.crypto.state=unsupported (No encryption configured)
- ro.crypto.state=encrypted && ro.crypto.type=file (FBE enabled)
- ro.crypto.state=unencrypted (FDE supported but disabled)
- ro.crypto.state=encrypted && ro.crypto.type=block (FDE enabled)

It seems that the reason the zygote-start action was duplicated three
times was to exclude the "FDE enabled" case, which could only be done by
explicitly listing the other three cases.

However, now that FDE is no longer supported, only the first two cases
are possible.  Therefore, zygote-start can just be the whole trigger.

Bug: 208476087
Test: presubmit
Change-Id: Icd6e4b0d2fb3f9f20595c0af4e2e35350564da8d
2023-07-10 23:33:13 +00:00
Elliott Hughes
1563250410 NetlinkEvent: trivial simplification.
free(NULL) is defined as a no-op. Don't overcomplicate things.

Bug: http://b/287138549
Test: treehugger
Change-Id: I9ae532a71f986d9468f191972a9b7acf6e709d13
2023-07-10 22:46:12 +00:00
David Anderson
9b567001ca Merge "snapuserd: Return void from RespondIOError." into main 2023-07-10 20:59:04 +00:00
Eric Biggers
5c79501ab8 Merge "init: simplify queue_fs_event()" into main 2023-07-10 19:34:10 +00:00
Eric Biggers
ab74dbb197 init: simplify queue_fs_event()
Combine some cases that are handled identically, and remove the
'userdata_remount' parameter which is unused.  No change in behavior.

Test: presubmit
Change-Id: I0567e47d02942af7865c155dab76e6d0e9d71a1f
2023-07-10 17:58:36 +00:00
David Anderson
740c0d274c Merge "snapuserd: Make header_response a state variable." into main 2023-07-10 17:42:50 +00:00
Andrew Walbran
9fbd1683d4 Add safety comments.
These will soon be required by a lint.

Bug: 290018030
Test: m vm virtmgr
Change-Id: Id628b2a88f1cb0235fbccc748c52514e64561fe5
2023-07-10 14:56:20 +01:00
Nikita Ioffe
7f9b2c1739 Merge "Only allow debuggable Microdroid VMs to mount /vendor" into main 2023-07-07 15:46:39 +00:00
Nikita Ioffe
230af76757 Merge changes from topic "mount-vendor-in-microdroid" into main
* changes:
  Support for conditionally mounting /vendor partition in Microdroid
  Small refactoring in first_stage_mount
2023-07-07 15:28:33 +00:00
Nikita Ioffe
df0e96e962 Only allow debuggable Microdroid VMs to mount /vendor
Until the verification of the /vendor partition we restrict the usage of
the feature to only debuggable VMs. If a non-debuggable Microdroid VM
is requested to mount /vendor, first_stage_init will crash and the VM
won't boot.

Bug: 285855436
Test: vm run-microdroid --debug none --vendor test_vendor.img
Change-Id: I9d44ad5c1d971bac1a9173c291ce61b628f2f8e9
2023-07-07 14:46:23 +01:00
Nikita Ioffe
440354afa0 Support for conditionally mounting /vendor partition in Microdroid
first_stage_init will only mount the /vendor partition in Microdroid if
the androidboot.microdroid.mount_vendor=1 is provided in the kernel
cmdline.

Bug: 285855433
Test: atest MicrodroidTestApp
Change-Id: I5b840b5474bc52ec2696a0ba6ead0476acddfb1a
2023-07-07 14:45:58 +01:00
Nikita Ioffe
f17079ff58 Small refactoring in first_stage_mount
The existing approach in first_stage_init/first_stage_mount makes it
harder to add conditional logic that should only be applied for
Microdroid. Additionally, it forces the FirstStageMount object to be
created twice.

This change refactors the control flow to make first_stage_init take the
ownership of the FirstStageMount object. It will help with the follow up
change (which will add logic to conditionally mount /vendor partition
while booting Microdroid). As a nice side effect, this refactoring also
fixes the problem of the FirstStageMount being created twice.

This change also merges the FirstStageMount and FirstStageMountVBootV2
in a single class, since nobody actually uses FirstStageMount.

Bug: 285855433
Test: device boots
Test: atest MicrodroidTestApp
Change-Id: I38a72c0f20e7c1ac70031498aeeca22b091fa827
2023-07-07 14:45:01 +01:00
Kelvin Zhang
314e70966a Merge "Move libbinderwrapper to update_engine" 2023-07-06 02:45:14 +00:00