Commit graph

4236 commits

Author SHA1 Message Date
Treehugger Robot
babf597508 Merge "Use no_full_install: true instead of installable: false" into main 2024-05-04 00:04:03 +00:00
Nate Myren
31b1582797 Merge "Revert "Only write appcompat properties if flag is defined"" into main 2024-05-02 19:49:45 +00:00
Nate Myren
6d8304aa46 Revert "Only write appcompat properties if flag is defined"
Revert submission 3049635-cherrypicker-L52500030003287943:N44300030053199935

Reason for revert: b/338244859
Bug: 338244859

Reverted changes: /q/submissionid:3049635-cherrypicker-L52500030003287943:N44300030053199935

Change-Id: I4b99429ce5df0af30e6ad99d3463d4dc2c96c012
2024-05-01 19:21:49 +00:00
Jiyong Park
b33025849d Use no_full_install: true instead of installable: false
So far, we have used `instalable: false` to avoid collision with the
other modules that are installed to the same path. A typical example was
<foo> and <foo>.microdroid. The latter is a modified version of the
former for the inclusion of the microdroid image. They however both have
the same instalation path (ex: system/bin) and stem (ex: foo) so that we
can reference them using the same path regardless of whether we are in
Android or microdroid.

However, the use of `installable: false` for the purpose is actually
incorrect, because `installable: false` also means, obviously, "this
module shouldn't be installed". The only reason this incorrect way has
worked is simply because packaging modules (ex: android_filesystem)
didn't respect the property when gathering the modules.

As packaging modules are now fixed to respect `installable: false`, we
need a correct way of avoiding the collision. `no_full_install: true` is
it.

If a module has this property set to true, it is never installed to the
full instal path like out/target/product/<partition>/... It can be
installed only via packaging modules.

Bug: 338160898
Test: m
Change-Id: I37380c19232f2c497bdf492a83cdc16616f0ae8d
2024-05-01 20:59:19 +09:00
Elliott Hughes
c9d44b84fe Don't reject "ctl.stop.*" during shutdown.
We're shutting down anyway, so the service is either dead already
or about to be killed, and callers get upset (and don't have a good
response themselves) if we reject the request.

This was seen by a partner where adbd was asked to stop during
shutdown.

Bug: https://issuetracker.google.com/336223505
Change-Id: If09feeef2e0f2d1be9ff84a88cca6ed593a35362
2024-04-30 20:20:43 +00:00
Florian Mayer
67027efd06 Merge "[MTE] disable memtag stack in early init" into main 2024-04-29 20:58:05 +00:00
Florian Mayer
c2eaac5ed2 [MTE] disable memtag stack in early init
when introducing instrumentation for MTE stack history buffer, we cannot
use stack MTE in early init

Bug: 309446520
Change-Id: I0921ae4ffe03ed971697f8daff4215c9b3772e35
2024-04-26 17:25:05 -07:00
Treehugger Robot
6f5205229b Merge "ueventd: Add devname sys_name to subsystem, pulling device names from sysfs" into main 2024-04-25 19:39:02 +00:00
A. Cody Schuffelen
b479666e3c ueventd: Add devname sys_name to subsystem, pulling device names from sysfs
This change introduces a new mode to `subsystem.devname` in `ueventd.rc`
configuration files, which sets the file name to the contents of
`/sys/DEVNAME/name`.

The objective of this change is to help Cuttlefish distinguish between
console devices, which are only different in uevents by initialization
order. Cuttlefish currently relies on `/dev/hvc##` devices which are
created for non-multiport virtio-console devices.

https://cs.android.com/android/platform/superproject/main/+/main:device/google/cuttlefish/shared/config/ueventd.rc;l=18;drc=5204f119d859d3ae5f1a2ee1c6a05ee68d6a28ed

On Cuttlefish we're considering moving to multiport virtio-console
devices ( https://fedoraproject.org/wiki/Features/VirtioSerial ). It
would be possible to rely on device order here as well, but using names
to distinguish devices makes it possible to drop unused devices in the
future, rather than reserving indexes indefinitely.

Multiport virtio-console devices create uevents with DEVNAME=vport#p#
and DEVPATH=.../vport#p#, only exposing the name in a sysfs file.

Bug: 336663898
Test: Attach multiport console, run with `-DLOG_UEVENTS=1`
Test: Introduce ueventd policy using `devname sys_name`
Change-Id: I59632b556db4a47883eab97e90c0e6ca81a9c650
2024-04-25 11:10:11 -07:00
Treehugger Robot
b46dcf4fcb Merge "Only write appcompat properties if flag is defined" into main 2024-04-24 22:35:37 +00:00
Treehugger Robot
f0db2406f7 Merge "Null terminate the std::array given to execve" into main 2024-04-20 02:41:34 +00:00
Jiyong Park
e873e1d31b Null terminate the std::array given to execve
std::array<T, N> takes exactly N * sizeof(T) bytes, leaving no room for
the null terminator.

Bug: 335047945
Test: re-run the GSI test
Change-Id: Ic3aca5f409021c78a7eb965c5ed610e6a51e42cb
2024-04-20 10:11:46 +09:00
Nate Myren
32677ae8f3 Only write appcompat properties if flag is defined
Only writes the appcompat properties if the
WRITE_APPCOMPAT_OVERRIDE_SYSTEM_PROPERTIES cflag is defined

Fixes: 331307495
Test: manual
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:f04f6bae4314e01111045ba231010ba7067477a0)
Merged-In: Ie99b5027a9704c0f4f7fe4d3a6a6cf49f4bb8176
Change-Id: Ie99b5027a9704c0f4f7fe4d3a6a6cf49f4bb8176
2024-04-19 19:07:52 +00:00
Jiyong Park
12c64a7586 Don't install Android-only dependencies to microdroid
init_second_stage_defaults provides properties that are common to both
Android's init and Microdroid's init. Before this CL, it included
target.product.required and target.recovery.required properties. The
required dependencies were Android-specific; the dependencies included
Android-only init.rc. Microdroid has its own init.rc (microdroid_init_rc
module).

This was problematic but so far it didn't cause an issue because those
Android-only dependencies were not installed to Microdroid due to a bug
in the build system.

As we fix the build system bug, the Android-only dependencies started
get installed to Microdroid, effectively overriding the Microdroid-only
init.rc file. This made Microdroid fail to boot.

Fixing this issue by moving the Android-only dependencies out of the
defaults module and putting them on the Android's init.

In addition to that, this CL removes the recovery variant for the
Microdroid's init because it's not used.

Bug: N/A
Test: run AVF tests
Change-Id: I09748f1123125cac74ce54fd5c360c9a3ba2f996
2024-04-17 14:36:55 +09:00
Shrinidhi Hegde
4922633d3f Merge "Throttle reboot from native watchdog" into main 2024-04-12 14:30:23 +00:00
Shrinidhi Hegde
ab9b683840 Throttle reboot from native watchdog
Found out that increasing the threshold to 20 crashes pushes the file
system based rollbacks as well. So introducing a throttling behaviour
instead. Now native watchdog performs reboot with ramdump at 5 restarts.
After that packageWatchdog/ RescueParty takes over to perform other
mitigations. Ram dump + reboot will not be performed more than once
in 24hrs.

Test: manual
Bug: 291137901
Change-Id: Ia192411dad94e8e25c26f700d2fe7f94d41439b8
2024-04-11 15:28:07 +00:00
Treehugger Robot
793679f47a Merge "skip nop persistent property writes" into main 2024-04-09 06:41:58 +00:00
Shrinidhi Hegde
09071c46d8 Merge "Revert "Update native watchdog to be triggered after 20 restarts instead of 4."" into main 2024-04-05 00:23:45 +00:00
Shrinidhi Hegde
ae5ce6f7c3 Revert "Update native watchdog to be triggered after 20 restarts instead of 4."
This reverts commit 1d928ca80b.

Reason for revert: Breaks Host side CTS test https://android-build.corp.google.com/test_investigate/?referrer=buganizer&regressionId=manual-dcf4b8bc69179f9a6bc4ce097a552d84-1712255116&testResultId=TR13229242143019813&invocationId=I86200010262612788

Change-Id: I2627a0c5f5b8d9a19b6a43f678facc64ffa6c189
2024-04-04 19:19:04 +00:00
Shrinidhi Hegde
9261e262cb Merge "Update native watchdog to be triggered after 20 restarts instead of 4." into main 2024-04-04 16:25:43 +00:00
Jiyong Park
2f8efe00af skip nop persistent property writes
Bug: 332611029
Test: TH
Change-Id: I0f6ca09c781964d1eb432a770c50e7216f043b4f
2024-04-04 22:15:18 +09:00
Nikita Ioffe
feb7e0ea97 Restorecon /microdroid_resources in setup_selinux
The main reason for running restorecon of /microdroid_resources during
the setup_selinux stage is to avoid granting init some weird permissions
like `allow init tmpfs:file relabelfrom;`.

Instead we add such permissions to kernel domain in which setup_selinux
runs. This feels better since kernel domain already has similar
permissions like `allow kernel rootfs:file relabelfrom;`.

Bug: 287593065
Test: run microdroid vm with vendor partition
Change-Id: I82ef5499392e90f53655f7582e887d0b6cb3a5f0
2024-04-04 13:04:52 +00:00
Shrinidhi Hegde
1d928ca80b Update native watchdog to be triggered after 20 restarts instead of 4.
The native watchdog performs a complete reboot on 5 system server
restarts even before packageWatchdog/RescueParty can perform any of the
mitigations. Increasing the thrsehold at which native watchdog kicks in
to 20 instad of 4.

Test: manual
Bug: 291137901
Change-Id: I9166f6555020e8bf26cc86994b13c53745a9934b
2024-04-03 13:02:12 +00:00
Devin Moore
bc4f870aaa Merge "init_kill_services_test: don't always try to kill hwservicemanager" into main 2024-04-02 16:37:00 +00:00
Devin Moore
a5521b0d9f init_kill_services_test: don't always try to kill hwservicemanager
When HIDL is not supported, hwservicemanager will not be running and may
not even be installed on the device.

Ignore-AOSP-First: Disabling HIDL internally first. Will cherry-pick
these test CLs after.

Test: init_kill_services_test
Bug: 218588089
Change-Id: Iae41e35e4669dd62c99ab9f138fc419be2f5fa29
2024-03-29 16:12:53 +00:00
Akilesh Kailash
ec799183c8 init: Remove legacy virtual-ab support
Bug: 304829384
Test: OTA on Pixel
Change-Id: I8463a1cc102379daa41fdade6820222a5e3bdd86
Signed-off-by: Akilesh Kailash <akailash@google.com>
2024-03-28 09:53:36 -07:00
Nikita Ioffe
d28f45772f Remove check that only allows microdroid vendor partition on debuggable VMs
The microdroid vendor partition is now verified during Microdroid boot,
so no need for this check.

Bug: 287593065
Test: AVF presubmit
Change-Id: I84811f818ef1140f1fe93d9da5f9ee61341e75dd
2024-03-26 18:04:21 +00:00
Jeongik Cha
6d7e83fb42 Add //visibility:any_system_partition
system image which is declared in Android.bp should include the module.

Bug: 321000103
Test: m nothing
Change-Id: I6e9d8fa4c1051211ff9ff80c7dfa4a8ee5cbd732
2024-03-23 12:31:32 +09:00
Krzysztof Kosiński
eaf7d77e7e Add missing header.
Protobuf 22.x no longer includes <unordered_map>, so it has to
be included explicitly.

Bug: 329747255
Test: presubmit
Change-Id: Icd5055e242e4f58029caf80cbb321222c612a9d0
2024-03-15 06:44:39 +00:00
Nikita Ioffe
13db31040f Merge changes from topic "derive-microdroid-vendor-dice-node" into main
* changes:
  Add a step to derive microdroid vendor dice node
  Move ForkExecveAndWaitForCompletion to util.h
  Mount /microdroid_resources as tmpfs
2024-03-14 11:20:06 +00:00
Nikita Ioffe
1e114e677b Add a step to derive microdroid vendor dice node
The derivation happens in the derive_microdroid_vendor_dice_node binary
which first_stage_init forks and execvs.

Since the derivation requires talking to the dice driver, its
initialisation is also moved to the first stage init.

The derivation happens before the microdroid vendor partition is
verified & mounted. This should be safe because the first_stage_init
will fail the boot if the verification of the microdroid vendor
partition fails.

Bug: 287593065
Test: run microdroid with and without vendor partition
Test: atest MicrodroidTests
Change-Id: I0d83772eb98a56c315617e66ec64bd03639cfde6
2024-03-13 15:24:44 +00:00
Nikita Ioffe
fe7b83faea Move ForkExecveAndWaitForCompletion to util.h
In the follow up patch this function will also be used in
first_stage_init.

Bug: 287593065
Test: m
Change-Id: Id805f8523596c26ed262d89aa652b27184b612c1
2024-03-13 14:44:46 +00:00
Nikita Ioffe
2384e8abfe Mount /microdroid_resources as tmpfs
This will be used to store the new dice chain generated during
first_stage_init phase in case Microdroid VM is launched with
microdroid vendor partition.

Bug: 287593065
Test: atest MicrodroidTests
Test: start Microdroid VM & check microdroid_resources exists
Change-Id: I40677376bfed14d813ad51c78db6109b2d76d1d1
2024-03-13 14:39:08 +00:00
Veena Arvind
b46e5e6d0b Scan for quiescent in sub reason and details
Bug: 326526460
Test: manual (b/320369923#comment19)
Change-Id: I702841bf1afa6a04318b8233eb6ddb89c46b7ad5
2024-03-11 22:23:09 +00:00
Xin Li
ba485e7f71 Merge "Merge Android 14 QPR2 to AOSP main" into main 2024-03-07 06:10:51 +00:00
Justin Yun
4058ba29b5 Skip initializing ro.vendor.api_level if already defined
Devices may predefine ro.vendor.api_level. Skip calculating the value
if the ro.vendor.api_level is already defined.

Bug: 326164316
Test: getprop ro.vendor.api_level
Change-Id: Ic9fd2a0eef6ba9345f98a5cb1eb790080e19ca19
2024-03-06 18:28:58 +09:00
Jooyung Han
14f00567a9 Merge "init: move generated_android_ids to host_init_verifier" into main am: 3289747a5c
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2976531

Change-Id: I334c0f0e80fbc0ef4429a45ddfffe569f2ac4c36
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-26 08:17:42 +00:00
Jooyung Han
18407b7870 init: move generated_android_ids to host_init_verifier
It's used only by host_init_verifier. This is to remove the unnecessary
dependency from clients of init_host_defaults.

Bug: 326509378
Test: mmma system/core/init
Change-Id: I983fbfe616f0bcb87940c934e19f614d3bf51030
2024-02-26 11:18:00 +09:00
Kalesh Singh
20eab6f58b Merge "init: snapuserd: Fix ranges for mlock()" into main am: df09f80cf4
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2964563

Change-Id: Ie80dbe09c6afb8d5973a3fa06941015f2667ff9a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-22 21:05:09 +00:00
Kalesh Singh
df09f80cf4 Merge "init: snapuserd: Fix ranges for mlock()" into main 2024-02-22 20:27:13 +00:00
Treehugger Robot
6b803bcfaa Merge changes Ifaab2be0,I54df888e into main am: 8687d25c0d
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2959289

Change-Id: I376f6b0e8697733e395edd7257eb21f814c587e3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-22 15:26:00 +00:00
Kalesh Singh
f90de49e0e init: snapuserd: Fix ranges for mlock()
It cannot be assumed that file mappings in /proc/<pid>/maps will be
completely backed by the underlying file. [1]

Use MappedFileSize() to deduce the correct ranges for the mlock()
calls when locking system pages in the OTA path.

While at it also clean up the some unreachable code (mlockall()),
and improve error logging.

[1] SIGBUS at https://man7.org/linux/man-pages/man2/mmap.2.html#RETURN_VALUE

Test: Incremental OTA
Bug: 324952273
Change-Id: Ia2ab150e1b8de8c638f5b1acc1de83deb7ac5cff
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2024-02-21 18:40:45 -08:00
Pierre-Clément Tosi
b6b2afb6b3 first_stage_console: Refactor RunScript()
Introduce SpawnImage() as a reusable single-argument wrapper around
posix_spawn(), to avoid having to manually manage the child process.

Note that Bionic currently doesn't return the errno from the child's
exec() call to the caller in the parent process, which may temporarily
hide errors such as ENOENT in first_stage_console until Bionic improves.

Also, this introduces a subtle change in behavior as the first_stage.sh
script is now passed directly to the loader, which will only properly
invoke the Shell if the file contains the right shebang.

Inline the call to RunScript() to hopefully make it simpler for readers
to track the lifetime of the various processes on different code paths.

Test: run first_stage_init
Change-Id: Ifaab2be032b2080a039209295d0b5a3759764ea7
2024-02-21 12:35:55 +00:00
Pierre-Clément Tosi
b1d92c6508 first_stage_console: Fix waitpid() as SA_NOCLDWAIT
From wait(2):

  POSIX.1-2001 specifies that if [...] the SA_NOCLDWAIT flag is set for
  SIGCHLD, then children that terminate do not become zombies and a call
  to [...] waitpid() will block until all children have terminated, and
  then fail with errno set to ECHILD.

As we call sigaction(SIGCHLD, { SIG_DFL, SA_NOCLDWAIT }), running

  pid_t w = waitpid(pid, &status, 0);
  LOG(INFO) << "..." << status << " " << w << " " << errno;

shows that the calls consistently return (status=0, w=-1, errno=ECHILD).

Therefore, clarify the parent code by prefering wait(2) over waitpid(2),
as SA_NOCLDWAIT makes the kernel ignore the passed PID, and stop logging
the irrelevant status, to avoid confusion when the logs say the exit
status was 0 but the child actually returned an error.

Test: run first_stage_console
Change-Id: I54df888e38b947e206e374ad28ebb044c70c6640
2024-02-19 15:01:11 +00:00
Treehugger Robot
dccae8ce3c Merge "first_stage_console: Fix execv() child error path" into main am: 3b79ada7ef
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2959288

Change-Id: I56ddf989130e37f9d3a5ca6b884da6eeac46c62f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-19 11:19:54 +00:00
Treehugger Robot
3b79ada7ef Merge "first_stage_console: Fix execv() child error path" into main 2024-02-19 10:49:01 +00:00
Treehugger Robot
ca95bfc10e Merge "Rename functions in libvendorsupport" into main am: f27d8cebbd
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2964824

Change-Id: If033344bccfffd08fadda77c1d2617a788f2815a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-19 00:29:14 +00:00
Treehugger Robot
f27d8cebbd Merge "Rename functions in libvendorsupport" into main 2024-02-18 23:53:22 +00:00
Treehugger Robot
8a10b8a71d Merge "Add check_builtins to libinit_host" into main am: cb09ff33a3
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2966903

Change-Id: Iac72d76a94521b33ce79c7c791b25945a4e05889
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-17 00:44:12 +00:00
Pierre-Clément Tosi
0335dac70d first_stage_console: Fix execv() child error path
If the /first_stage.sh is not present on the system, the child process
which attempted to execv() ends up returning from the function along
with its parent, which can be seen in early logs e.g.

[   10.747576][   T51] init: Attempting to run /first_stage.sh...
[   10.757371][   T52] init: unable to execv /first_stage.sh, returned -1 errno 2
[   10.767527][   T52] init: unable to execv, returned -1 errno 2
                      [...]
[   10.789189][   T51] init: unable to execv, returned -1 errno 2

where both T51 and T52 end up executing the "rest" of StartConsole().

Instead, terminate the child if its execv() failed.

Test: run first_stage_init
Change-Id: I20bc0aeae627761a60fb2b55bae39871ad506f69
2024-02-16 15:23:32 +00:00