Commit graph

81794 commits

Author SHA1 Message Date
T.J. Mercier
aa6158b410 libprocessgroup: UIDs in linux are unsigned
We missed two incorrect specifiers in the previous commit with this same
title.

We use the %d format specificier for uid_t, which maps to
__kernel_uid32_t, which is unsigned. [1] This is undefined behavior
which can lead to paths with negative UIDs when erroneously large
values are passed for uid:

E libprocessgroup: No such cgroup attribute: /sys/fs/cgroup/uid_-89846/cgroup.freeze

Fix it with %u.

[1] https://cs.android.com/search?q=typedef.*__kernel_uid32_t&ss=android%2Fplatform%2Fsuperproject%2Fmain

Change-Id: Ica04b03526bd2e156f026a2797fe9912b259cd9f
2023-07-26 22:12:44 +00:00
Eric Biggers
428622bb7f Merge "Revert "init.rc: stop calling 'fsverity_init --load-verified-keys'"" into main 2023-07-26 18:06:51 +00:00
Treehugger Robot
17df69eb5f Merge "Add bug component to system/core" into main 2023-07-26 15:26:59 +00:00
Tomasz Wasilczyk
a895aac5e0 Add bug component to system/core
Bug: 289414897
Test: N/A
Change-Id: I9709b2483988f8d7a4204d5398cc559d167f14bf
2023-07-26 07:57:58 -07:00
Yunkai Lim
9292f74fc1 Revert "init.rc: stop calling 'fsverity_init --load-verified-keys'"
Revert submission 2662658-fsverity-init-cleanup

Reason for revert: Culprit for test breakage b/293232766

Reverted changes: /q/submissionid:2662658-fsverity-init-cleanup

Change-Id: I77086f955a53eec274166b7395a88b7dc0e1ad53
2023-07-26 06:21:43 +00:00
Eric Biggers
5aade9ca04 Merge "init.rc: stop calling 'fsverity_init --load-verified-keys'" into main 2023-07-25 22:49:09 +00:00
Ryan Prichard
60dbdaa3fa Merge "Explicitly ignore the result of std::async" into main 2023-07-25 20:21:14 +00:00
Treehugger Robot
406d43397c Merge "Add safety comments." into main 2023-07-25 07:00:16 +00:00
Treehugger Robot
a414e2fd9b Merge "libprocessgroup: UIDs in linux are unsigned" into main 2023-07-24 22:44:22 +00:00
Treehugger Robot
e4cbd9a6a0 Merge "storageproxyd: Start only a single binder thread" into main 2023-07-24 21:35:45 +00:00
Yi-Yo Chiang
64062f8f4a Merge changes I2581fd7c,I1ed57e6d into main
* changes:
  fs_mgr: Refactor by inlining trivial helpers
  fs_mgr_overlayfs: Make all string constants constexpr
2023-07-24 09:53:26 +00:00
Ryan Prichard
c5184f79ee Explicitly ignore the result of std::async
The newer libc++ marks std::async with [[nodiscard]] in C++20 mode.

Bug: b/175635923
Test: treehugger
Change-Id: Ib63259983d952b97cf1b1c6c243c831cb72f9724
2023-07-21 15:21:28 -07:00
Akilesh Kailash
da2fc1c6af Merge "snapuserd: use local buffers for xor processing during sync I/O" into main 2023-07-21 22:18:21 +00:00
Akilesh Kailash
37c18b30cb snapuserd: use local buffers for xor processing during sync I/O
Bug: 291862304
Test: Incremental OTA on Pixel - Verify first stage boot logs
Change-Id: Ifc4f1ec912ccc1d24673f7bb03b05129ce504fa1
Signed-off-by: Akilesh Kailash <akailash@google.com>
2023-07-21 20:08:37 +00:00
Stephen Crane
b05b870671 storageproxyd: Start only a single binder thread
We only need a single binder thread to receive notifications, so we
should set the thread pool max to 0 rather than 1. startThreadPool()
starts one thread + the max count.

Test: m storageproxyd
Bug: 281951047
Fixes: 292030372
Change-Id: I53a90eaa2aa69469fd3a00b6da0d7061318c8ba9
2023-07-21 19:23:45 +00:00
Andrew Walbran
f580fe5799 Add safety comments.
These will soon be required by a lint.

Bug: 290018030
Test: m rust
Change-Id: I0b25bcaa18d167fb9c2d63e637833d4935dc8ff4
2023-07-21 19:13:48 +01:00
Yi-Yo Chiang
98e3522762 fs_mgr: Refactor by inlining trivial helpers
Inline some trivial helpers and remove unused header declarations.

Remove fs_mgr_*access() as it is really just access().
Remove fs_mgr_overlayfs_super_device() as we always want the primary
slot and having this wrapper isn't particularly helpful.

Test: adb-remount-test
Change-Id: I2581fd7c7d5071cbb97778535b7811dbcb80d76e
2023-07-22 00:08:51 +08:00
Yi-Yo Chiang
b2e0edcaae fs_mgr_overlayfs: Make all string constants constexpr
According to https://abseil.io/tips/140, string constants should be
constexpr char array or string_view object. This avoids subtle bugs due
to the toolchain shuffling object initialization order between/within
compilation units.

string_view has bad interoperability between C APIs as many of those
functions require string values to be null-terminated. Thus we can only
rely on good old c-string constants.

This change groups all string constants together and change them all to
constexpr char array for consistent style.
Also remove some duplicated method definition.

Test: adb-remount-test
Change-Id: I1ed57e6dc24ce3750e72c5538c388a6872cd2b40
2023-07-21 20:44:50 +08:00
Yi-Yo Chiang
6b57c885d3 Merge "init_first_stage: Disable ThinLTO" into main 2023-07-21 05:08:13 +00:00
T.J. Mercier
bf2bebd8e7 libprocessgroup: UIDs in linux are unsigned
We use the %d format specificier for uid_t, which maps to
__kernel_uid32_t, which is unsigned. [1] This is undefined behavior
which can lead to paths with negative UIDs when erroneously large
values are passed for uid:

E libprocessgroup: No such cgroup attribute: /sys/fs/cgroup/uid_-89846/cgroup.freeze

Fix it with %u.

[1] https://cs.android.com/search?q=typedef.*__kernel_uid32_t&ss=android%2Fplatform%2Fsuperproject%2Fmain

Change-Id: Ibb52ba2503e30e2f20770b7d23629167e38d076a
2023-07-21 00:39:57 +00:00
David Anderson
89d22239d2 Merge "snapuserd: Fix ubsan when reading a single aligned sector." into main 2023-07-20 16:23:08 +00:00
Yi-Yo Chiang
4d6fa8ccaf init_first_stage: Disable ThinLTO
Static executables + x86 target build + ThinLTO produces bug behavior.
Global variables are not constructor initialized, resulting in faulty
runtime behavior.

Bug: 169004486
Bug: 291033685
Test: Treehugger
Change-Id: I777016cceb4851f2b432a37bc4d29aed56c23804
2023-07-20 18:47:16 +08:00
Jakob Vukalović
998c3b4fbe Merge "ueventd: Fix creation of VFIO dev nodes" into main 2023-07-20 09:04:25 +00:00
David Anderson
e1132a9c2f snapuserd: Fix ubsan when reading a single aligned sector.
When a read request is for a single sector, and the sector is
block-aligned, it falls into the ReadAlignedSector path, which assumes
block-sized reads. Fix this by clamping the expected size.

Bug: 291862304
Test: manual test of ReadWorker::ReadAlignedSector
      full OTA
Change-Id: I00e460c333e8a9a4dc2433443e3633f3d794da1d
2023-07-19 23:05:58 -07:00
Treehugger Robot
fe1fa35823 Merge "storageproxyd: Start binder thread pool" into main 2023-07-19 22:52:21 +00:00
Stephen Crane
fb92cd3c22 storageproxyd: Start binder thread pool
The Trusty storage proxy requires that the suspend service is started to
acquire a wakelock for UFS RPMB operations. Without the binder thread
pool running, starting this service results in at least a 1s polling
delay. This change ensures that we start the thread pool before handling
any RPMB operations, so acquiring the wakelock will complete as soon as
the service is ready without needing to poll once per second.

Test: m storageproxyd
Test: Artificially delay suspend_service to check if we poll
Bug: 281951047
Change-Id: I1a4cdd48d57201b0cf9c24523d22e5bdbcea376a
2023-07-19 18:37:52 +00:00
Jakob Vukalovic
e377432924 ueventd: Fix creation of VFIO dev nodes
VFIO nodes, both the container (`vfio`) node and group (numbered)
nodes, should be located in `/dev/vfio`. This change prevents
ueventd from flattening that structure.

Test: Bind a device to VFIO driver to create a VFIO group
Change-Id: I635e9febe6bb52718df263e735479f361eacad4c
2023-07-19 10:03:10 +01:00
Eric Miao
4a33c22c77 Merge "String8: fix infinite loop and segmentation fault in removeAll()" into main 2023-07-19 02:03:40 +00:00
Eric Biggers
7acaea6770 init.rc: stop calling 'fsverity_init --load-verified-keys'
Since Android 14, Android does not use fsverity builtin signatures.
(fsverity remains supported, but signatures are verified in userspace,
or fsverity is used for integrity-only use cases.)  Therefore, the only
reason to still run 'fsverity_init --load-verified-keys' at boot time is
to ensure that old files can still be opened, if:

- They were created by Android 13 or earlier, with an fsverity builtin
  signature by a key in /{system,product}/etc/security/fsverity/.

- *And*, the kernel still has CONFIG_FS_VERITY_BUILTIN_SIGNATURES=y.

However, it appears that this isn't actually needed anymore.  Only two
features could potentially be affected: APK verity and updatable fonts.
APK verity wasn't widely rolled out before being disabled, and updatable
fonts have recovery logic in place for when the files cannot be opened.
And in any case, disabling CONFIG_FS_VERITY_BUILTIN_SIGNATURES in the
kernel is recommended and would avoid any problem.

Bug: 290064770
Test: presubmit
Change-Id: I3376c3f0b4b9bd4ba2fd614259522be0c1daafb6
2023-07-19 01:13:15 +00:00
Daniel Zheng
f161ee2771 Merge "Adding documentation" into main 2023-07-19 00:20:59 +00:00
Eric Miao
c6ce48ef19 String8: fix infinite loop and segmentation fault in removeAll()
Bug: 290835996
Test: libutils_fuzz_string8 for several minutes

String8::removeAll() has 2 serious problems:

1. When `other` is an empty string, `removeAll()` will loop infinitely
   due to below process:

   a) with `other` being empty string `""`, find() will call strstr()
      on an empty string, which always returns `mString`, and thus
      find() always return 0 in this case
   b) with find() returns 0 for empty string, the next while loop in
      String8::removeAll() will keep loop infinitely as `index` will
      always be 0

   This CL fixes this problem by returning true if `other` is an empty
   string (i.e. `strlen(other) == 0`), this follows the logic that an
   empty string will always be found and no actual remove needs to be
   done.

2. When `other` is a NULL string, strstr() has undefined behavior. See
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf.

   This undefined behavior on Android unfortunately causes immediate
   segmentation fault as the current `strstr` implementation in bionic
   libc doesn't check `needle` being NULL, and an access to a NULL
   location is performed to check if the `needle` string is an empty
   string, and thus causes segmentation fault.

   This CL gives an error message and aborts instead of having a
   segfault, and to keep some backward compatibility.

   This CL also adds test for String8::removeAll()

Change-Id: Ie2ccee6767efe0fed476db4ec6072717198279e9
2023-07-18 16:02:07 -07:00
Daniel Zheng
658182b8e7 Adding documentation
adding --help documentation to fastboot for --disable-super-optimization
and --disable-fastboot-info

Test: fastboot -h
Change-Id: Ia8993b3894d302a63cc97796d66e0af3fb004eef
2023-07-18 15:36:26 -07:00
Treehugger Robot
435b520bf0 Merge "Fix libutils_fuzz_string8 deadlock." into main 2023-07-18 21:49:06 +00:00
Hao Chen
8dad4b2b8a Merge "threads.h: avoid defining gettid on glibc >= 2.30" into main 2023-07-18 21:38:34 +00:00
Steven Moreland
749becfa68 Fix libutils_fuzz_string8 deadlock.
Bug: 290835996
Test: libutils_fuzz_string8 for several minutes
Change-Id: I9b312dd968c380f4fa2a837d38121d0a7a7ac7b1
2023-07-18 21:04:07 +00:00
Hao Chen
253445ce3a threads.h: avoid defining gettid on glibc >= 2.30
The issue in https://bugs.chromium.org/p/chromium/issues/detail?id=1182060 also
exists on glibc 2.30 and 2.31 since `gettid` was Introduced in glibc 2.30.

See https://man7.org/linux/man-pages/man2/gettid.2.html

Bug: 285204695
Test: Build
Change-Id: I7e534edf8c0a20c415232bcfffabbf2c1d6eec98
2023-07-18 19:52:19 +00:00
David Anderson
72c3ca1604 Merge "snapuserd: Refactor how buffers are managed." into main 2023-07-18 16:42:22 +00:00
Eric Biggers
0306bc1a31 Merge "init: avoid ERROR log due to missing SEPolicy.zip" into main 2023-07-18 15:38:20 +00:00
David Anderson
3930625074 snapuserd: Refactor how buffers are managed.
Currently all I/O is processed through BufferSink. However, the
allocation of buffers is implicit in low-level helper functions, which
have no knowledge of how much data will actually be sent. As a result,
"allocation of buffers" and "tracking of how many bytes were written" is
disjoint. This will make it very difficult to break dependence on
dm-user, without a much more complex API.

This patch refactors how BufferSink is used. First, GetPayloadBuffer has
been deprecated in favor of AcquireBuffer. AcquireBuffer performs both
allocation and write tracking. The number of bytes written is not
necessarily the number of bytes allocated, and the new API allows for
this.

The "Process" helpers now take in an explicit buffer, and their callers
are responsible for allocating a buffer. This allows for
ReadUnalignedSector to have proper buffer offset tracking.

Because write tracking is now accurate, no explicit size needs to be
passed to WriteDmUserPayload. It can simply read the current watermark
in BufferSink.

This patch also removes XorSink, since its dependence on BufferSink made
this change more difficult.

Bug: 288273605
Test: snapuserd_test
Change-Id: Id9ca5044f9c0386f351b250349793b6b276b01b7
2023-07-17 17:10:19 -07:00
Treehugger Robot
1c77579a06 Merge "Look for radio.img and bootloader.img in ANDROID_PRODUCT_OUT" into main 2023-07-17 21:51:01 +00:00
Paul Lawrence
556c46bfb9 Look for radio.img and bootloader.img in ANDROID_PRODUCT_OUT
Test: fastboot flash bootloader and fastboot flash radio both work
Change-Id: I79674469c0df3dd592e5fcf840fef0dcc3f11d33
2023-07-17 14:05:21 -07:00
Eric Biggers
53ed745e3f init: avoid ERROR log due to missing SEPolicy.zip
One of the first ERROR messages in logcat of a normal boot of Cuttlefish
is from failure to open SEPolicy.zip.  This condition is expected.
Therefore don't try to load SEPolicy.zip when it doesn't exist.  This
replaces the following log messages:

0     0 I init    : Error: Apex SEPolicy failed signature check
0     0 I init    : Loading APEX Sepolicy from /system/etc/selinux/apex/SEPolicy.zip
0     0 E init    : Failed to open package /system/etc/selinux/apex/SEPolicy.zip: No such file or directory

... with just:

0     0 I init    : No APEX Sepolicy found

Change-Id: If3a77407c35130165df5782b9ef91912e8374dbf
2023-07-17 20:45:44 +00:00
Eric Biggers
42164ff920 Merge changes from topic "fsverity-init-cleanup" into main
* changes:
  init.rc: stop using fsverity_init --lock
  init: remove unfinished fsverity signature support for APEX sepolicy
2023-07-17 20:10:28 +00:00
David Anderson
83ebc4376d Merge changes I1625d1a6,I2db9cfa2,I59c31318,Ic0ed1a8d,I612374bb into main
* changes:
  snapuserd: Move Process ops out of Worker.
  snapuserd: Move more fields out of Worker.
  snapuserd: Split more methods out of Worker.
  snapuserd: Create a ReadWorker class.
  snapuserd: Create a MergeWorker class.
2023-07-17 18:44:46 +00:00
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