Commit graph

4026 commits

Author SHA1 Message Date
David Anderson
45ff1afd63 Merge "ueventd: Fix a race condition in handling device-mapper events." into udc-dev am: c742bfda6b am: 1a626643c1
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/23598091

Change-Id: Ia70f17e7823e9940119ab5e0485ec35b41e79376
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-08 16:58:29 +00:00
David Anderson
4866d284f8 ueventd: Fix a race condition in handling device-mapper events.
We've had flake in libdm_test for a long time, with no clear cause.
Lately however it has become particularly reproducible when running
the UeventAfterLoadTable test in isolation, and thus we've identified
the root cause.

uevents for device-mapper are fired when the sysfs node is added, but at
that time, the "dm" subnode has not yet been added. The root node and dm
node are added very close together, so usually it works, but sometimes
ueventd is too fast.

Instead of relying on sysfs, query the uuid/name node directly from
device-mapper.

Bug: 286011429
Test: libdm_test
(cherry picked from https://android-review.googlesource.com/q/commit:59abbfe64706a7ea0c4e932ae40bc8bde9746dce)
Merged-In: I258de5de05d813c3cb7f129e82e56dbfe8bf3117

Change-Id: I85e240807e0ce5ade211ec65453ab06d4066992a
2023-06-06 21:37:09 -07:00
JW Wang
ce09cdff62 Export active dsu slot to system prop
The prop can be consumed by init scripts to do customized setup:

on property:ro.gsid.dsu_slot=oemtest
    # Do setup for test
on property:ro.gsid.dsu_slot=oemdemo
    # Do setup for demo

Bug: 277691885
Test: m
Change-Id: I7bd78b9ba31021b27d57c6f092dad5d7ebf6e59b
Merged-In: I7bd78b9ba31021b27d57c6f092dad5d7ebf6e59b
Cherry-picked from aosp/2588465
2023-05-16 00:54:06 +00:00
Steven Moreland
ec2445d08e Merge "Explicit init .rc user." am: f0578771ea am: f90cb6315d am: 0ca68a5b05
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2530202

Change-Id: I86b206cc28c154239244301341c20bfafa17a77e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-04-14 23:20:41 +00:00
Steven Moreland
f0578771ea Merge "Explicit init .rc user." 2023-04-14 21:43:38 +00:00
Steven Moreland
2fccf5ead3 Explicit init .rc user.
Set the user explicitly.

For boringssl self-test, changed to 'nobody' since
this test doesn't require permissions.

Bug: 276813155
Test: boot, check can 'nobody' can still write to kmesg.
Change-Id: I32f7134e83183bd054bffbb22d412d7a2dc0ad09
2023-04-14 21:43:25 +00:00
Daniel Rosenberg
d319ac364f Merge "Require root for StartConsole Test" am: 76607e5b07 am: 5433d7db5c am: eb0ce2a22f
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2528610

Change-Id: I97708e2d8c293c86252c3fc2ea497b0af54ef31b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-04-11 02:51:41 +00:00
Daniel Rosenberg
76607e5b07 Merge "Require root for StartConsole Test" 2023-04-11 01:14:17 +00:00
Daniel Rosenberg
b8baa8dd34 Require root for StartConsole Test
This test requires root to run. Skip if not root.

Bug: 270052268
Test: CtsInitTestCases init#StartConsole
Change-Id: I8b54acf97cda4bc2cfa15d0e34c678ec2b13f83e
2023-04-07 13:18:53 -07:00
Treehugger Robot
600a2ee508 Merge "Improve the formatting for init's README." am: 57c1a4e308 am: 3a2405ca6b am: a2da0f0d69
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2528060

Change-Id: I6b8434a2ed3b5256b7f845ef2912c4e25c6b41d2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-04-07 02:29:20 +00:00
Mateus Azis
1a2f73d76a Improve the formatting for init's README.
Make sure the arguments to "mkdir" show up in the same block.

Before: c3a119caa3/init/README.md
After: https://android.googlesource.com/platform/system/core/+/refs/changes/60/2528060/1/init/README.md

Test: N/A
Change-Id: I88b4931e70e2793566cce53c38c0295168463971
2023-04-06 13:46:35 -07:00
Thiébaud Weksteen
7241d11427 Merge "Skip newlines for SELinux logs" am: c3a119caa3 am: f449ee1f89 am: e93f7196be
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2521555

Change-Id: I488586d985f7f798ed582f7a1384fc26ec368b71
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-04-06 01:06:25 +00:00
Thiébaud Weksteen
f03dde8549 Skip newlines for SELinux logs
libselinux log messages usually end with a new line character. Android
log system does not require the new line character and will include the
character as-is in the log buffer.

This trimming was already implemented when the message is typed as
SELINUX_AVC (see SelinuxAvcLog). Move the truncation one level up so it
is occurring for all types of logs.

Test: boot & adb logcat & inspect SELinux logs
Change-Id: I360359c1b178ef24d555dd41f8d4a18b293a175c
2023-04-05 09:32:18 +10:00
Paul Lawrence
606afc7b74 Fix deadlock caused by two-threaded property controls
Two threaded property controls were introduced in ag/21063815 to prevent
DOS for power controls. However, this causes deadlocks, so limit the
second thread to just sys.powerctl messages.

Bug: 273785601
Test: Boots, power messages work
Ignore-AOSP-First: Security fix
Change-Id: Ie27dc3b0cd9e2d28e94f2ad398c55ee27bc35835
2023-03-28 14:14:31 +00:00
Jingwen Chen
a33a40991f Merge "Make the host_init_verifier init.rc parser follow symlinks." am: 095374cde7 am: 982988eb95 am: fa0bc763b2
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2494555

Change-Id: Ia29e5b21c3c43abb47a974ffb5718a3d4df81d73
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-03-17 08:28:02 +00:00
Jingwen Chen
095374cde7 Merge "Make the host_init_verifier init.rc parser follow symlinks." 2023-03-17 06:42:04 +00:00
Jingwen Chen
f643b354fe Make the host_init_verifier init.rc parser follow symlinks.
Bazel's intermediates/inputs are symlinks in its execution root, unlike Soong.

e.g.

$ file $(readlink -f out/bazel/output/execroot/__main__/packages/modules/adb/apex/adbd.rc)
/usr/local/google/home/jingwen/aosp/master-with-phones/packages/modules/adb/apex/adbd.rc:
ASCII text

Test: presubmits
Change-Id: I3977a37ee989e07bee56abb019a21055b8cef567
2023-03-17 02:47:21 +00:00
Steven Moreland
6191d7f7fc Merge "init_kill_services_test: clearer logs" am: bc21816d5b am: 3c6f170262 am: 1d307c6fdf
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2490898

Change-Id: I2e7fc920ff12237fe673e16d4ceca79d8d59616a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-03-16 01:44:05 +00:00
Steven Moreland
bc21816d5b Merge "init_kill_services_test: clearer logs" 2023-03-15 23:59:10 +00:00
Treehugger Robot
d43bcc90c3 Merge "init tests: libhidl-gen-utils static" am: 89d8fdf3ed am: 47dfd3956c am: b5169307d7
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2492258

Change-Id: I7c944ceb0c4a771b5f915ac33aefd94feaba9523
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-03-15 23:14:23 +00:00
Steven Moreland
d9d4034d0b init_kill_services_test: clearer logs
Don't continue with a specific run if a service
is already dead.

Bug: 272618190
Test: init_kill_services_test
Change-Id: I1b1c0b4e87fd7a5200bd6e6e6af2eb9686d7367d
2023-03-15 21:47:38 +00:00
Treehugger Robot
89d8fdf3ed Merge "init tests: libhidl-gen-utils static" 2023-03-15 21:16:50 +00:00
Steven Moreland
973aadeff5 init tests: libhidl-gen-utils static
No longer installed on device, so we need to include
it as a static lib. This library was actually specified
as a dependency on vts_ibase_test in two places, so this
is the second CL doing the same thing but in another
project.

Fixes: 270497432
Test: readelf -d $ANDROID_BUILD_TOP/out/target/product/vsoc_x86_64/data/nativetest/vts_ibase_test/vts_ibase_test
  no longer shows libhidl-gen-utils
Change-Id: Icf427085e3978906e82231c8faacb7bdbcbf4569
2023-03-15 19:40:56 +00:00
Treehugger Robot
1143dde53e Merge "Stop respawning serial console if disabled" am: a6b295b95e am: 270959a336 am: cf0603892b
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2485621

Change-Id: I167b8d36afa019fba3c1f78d4744fd32aa45629b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-03-14 02:33:14 +00:00
Alistair Delva
f9bfe0d16d Stop respawning serial console if disabled
After introducing ro.boot.serialconsole=0, the console will no longer be
spawned, but a step was missed to disable the service to prevent
respawns.

Bug: 266982931
Bug: 223797063
Bug: 267428635
Change-Id: I12b159eaa1999781aec31c05ce431b55e2ba4017
2023-03-13 16:09:36 -07:00
Bart Van Assche
be86249fe5 Merge "init: Combine the CheckShutdown() and set_do_shutdown() methods" am: 42908c45e5 am: b61674ee02 am: 9d1a3f7cd2
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2444306

Change-Id: Ie129ab6cd276f0e91e80f3267d877afb5f7eb2aa
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-03-06 19:50:55 +00:00
Treehugger Robot
f5d0775459 Merge changes Ia150604c,Id4b9565f am: b28e508220 am: f00d7fd062 am: d0f9e81147
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2470042

Change-Id: Ic630996639874deb9b126b8157d9d94ef79144c2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-03-06 17:48:36 +00:00
Bart Van Assche
071dbc1729 init: Combine the CheckShutdown() and set_do_shutdown() methods
Let the CheckShutdown() method clear the do_shutdown_ member instead of
clearing that member separately from calling CheckShutdown().

Bug: 266255006
Change-Id: Ifc1cff2be92a45db7f91be2fdb812930d2fd1ad5
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-03-03 13:27:17 -08:00
Bart Van Assche
b4b1b75a35 init: Remove the DebugRebootLogging() function
The DebugRebootLogging() function was introduced to help with
root-causing b/150863651. Remove this function since this logging
functionality is no longer needed. Also remove the functions and methods
that are only used by DebugRebootLogging().

Change-Id: Ia150604c6cd70f42b13d655ba43b95445a55b6e2
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-03-03 13:26:58 -08:00
Bart Van Assche
1fdbf8d0f8 init: Combine two if-statements
Combine two if-statements. This change is fine because:
* The code between the two if-statements does not queue actions.
* If an action is queued from another thread then WakeMainInitThread()
  is called after the action has been queued.

Bug: 266255006
Change-Id: Id4b9565ff4fdb3ee2a2bbca316c8c78e0f2d38dd
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-03-03 13:26:58 -08:00
Treehugger Robot
28dc06b57b Merge "Use ro.boot.serialconsole to disable console services" am: 8dab2ef586 am: 55ba50e20f am: a024299130
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2451765

Change-Id: Ic9d785a4ae321d1191f6a36ef1d203657e2eead3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-03-03 16:53:07 +00:00
Treehugger Robot
8dab2ef586 Merge "Use ro.boot.serialconsole to disable console services" 2023-03-02 20:04:33 +00:00
Steven Moreland
80836de94f Merge "init: add log w/ service PID" am: 007769a0d7 am: 198d6a16a7 am: 0e5df14497
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2459588

Change-Id: Icaa19ec98a0a904c17342e60c915c1721c5716f9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-02-28 21:51:25 +00:00
Steven Moreland
8e25d9c5b0 init: add log w/ service PID
We could combine this with the existing log, but I
wouldn't want to make that appear later.

Ironically, adding this log to try to reduce logs.

Bug: 36785118
Test: :) adb logcat -d | grep "started service" | wc -l
131

Change-Id: I38f4e9740871aa256eef0c62e897038eb46871a5
2023-02-28 01:42:24 +00:00
Bart Van Assche
6356f49034 Merge "init: Simplify struct BuiltinArguments" am: 95465fe718 am: 81af4365b8 am: e7cba7f653
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2451825

Change-Id: I2dfffeada5efa60314b292bf1df911b66bd59cb3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-02-24 01:27:37 +00:00
Bart Van Assche
3dfb8bc889 init: Simplify struct BuiltinArguments
Make the code that creates BuiltinArguments instances easier to read by
using initializer lists instead of constructor calls. Remove the
BuiltinArguments constructors.

Change-Id: I6cf215a81d298cf7e524e22fb75db820e0225c9a
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-02-23 16:06:42 +00:00
Jiyong Park
1363082fda Merge "Fix failure on mounting system_ext partition" am: 8437b9a082 am: df10d96f4a am: 69eeff6580
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2442800

Change-Id: I1996bf55629d3f2ead4515925f889f82fd772727
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-02-23 06:04:04 +00:00
Jiyong Park
8437b9a082 Merge "Fix failure on mounting system_ext partition" 2023-02-23 03:56:40 +00:00
Alistair Delva
5591f12834 Use ro.boot.serialconsole to disable console services
For many years, services declaring "console" would only be started if the
console device specified by androidboot.console= was present under /dev.
However, they would also be started if the /dev/console node existed.

This fallback causes problems with newer GKI kernel images which now
hard-code "console=ttynull" via CONFIG_CMDLINE, which essentially means
/dev/console always exists, even though this console points nowhere.

It also causes problems on devices where the androidboot.console was not
the same as the kernel dmesg console ("console="), such as cuttlefish,
because those platforms could not simultaneously enable kernel logging
but disable the interactive serial console feature. The framework just
assumed both would be muxed on the same serial port. Cuttlefish had a
workaround, to use "androidboot.console=invalid" to avoid the fallback,
but this doesn't work on devices which still want to mux the kernel logs
and interactive serial console.

This change resolves the issue in a better way, by introducing a new
boolean property called "androidboot.serialconsole". Setting this to "0"
will disable the console services, regardless of whether the
/dev/console or /dev/${ro.boot.console} devices exist. Older kernels
and bootloaders don't need to set this and can rely on the old behavior
in init, but bootloaders booting newer kernels must set it to avoid the
"performance is impacted" message due to console services being started.

Bug: 266982931
Bug: 223797063
Bug: 267428635
Test: "launch_cvd" with "androidboot.console=invalid" removed;
      See the "performance is impacted" message.
Test: "launch_cvd" with "androidboot.serialconsole=0";
      The "performance is impacted" message is gone.
Change-Id: Iaad4d27ffe4df74ed49606d3cabe83483c350df4
2023-02-22 14:31:24 -08:00
Bart Van Assche
1173feedc7 Merge changes I71b34181,Ibd05137a am: 8f09cb5ba6 am: 860d84cf55 am: 99acf232cf
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2444305

Change-Id: Id6d972f34e5e0cb7194911eb5e4b1c449336a2f2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-02-22 02:40:20 +00:00
Lianjun Huang
ccd094cd4e Fix failure on mounting system_ext partition
There can be more than one fstab entry of system partition.
For example, the filesystem of one entry is ext4 and another is erofs.

system /system ext4 ro wait,slotselect,avb=vbmeta_system,logical,first_stage_mount,avb_keys=/avb/q-gsi.avbpubkey:/avb/r-gsi.avbpubkey:/avb/s-gsi.avbpubkey
system /system erofs ro wait,slotselect,avb=vbmeta_system,logical,first_stage_mount,avb_keys=/avb/q-gsi.avbpubkey:/avb/r-gsi.avbpubkey:/avb/s-gsi.avbpubkey

If both filesystems of system and system_ext paritions are erofs,
only the ext4 fstab entry will be returned by GetEntryForMountPoint,
and system_ext cann't be mounted.

So we need to return both of the fstab entries and try all of them.

Signed-off-by: Lianjun Huang <huanglianjun@xiaomi.com>
Change-Id: I407553d48b1749cd0554f057a6bfd38daa96fdcb
Signed-off-by: Lianjun Huang <huanglianjun@xiaomi.corp-partner.google.com>
2023-02-20 16:50:03 +08:00
Bart Van Assche
b6b7ccc24f init: Document the locking strategy used in class PropWaiterState
Let the compiler verify that lock_ is held when any of the data members
are accessed.

Bug: 266255006
Change-Id: I71b341815d84ab530627d934ad4d4681b652b9d8
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-02-17 13:55:11 -08:00
Bart Van Assche
68a59e1c72 init: Document the locking strategy in class ShutdownState
Let the compiler verify that shutdown_command_lock_ is held when
shutdown_command_ is accessed.

Bug: 266255006
Change-Id: Ibd05137ab65e20f247f35bbb2bb1865e05f51f41
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-02-17 13:55:11 -08:00
Bart Van Assche
e08efc5131 Merge changes Ib9a6b75b,Ifb71fa24,If329e912 am: 678516efa1 am: 7d85beda6e am: 5b9d7710d2
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2435914

Change-Id: I8b958402ef9cf92c6ee68ebff4b57cd1411b4944
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-02-15 20:38:24 +00:00
Bart Van Assche
468067a204 init_test: Close all file descriptors before calling execv()
This change improves test reliability.

Change-Id: Ib9a6b75bbd81968eb7e2fd90ea567155bc8355f7
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-02-15 09:27:32 -08:00
Bart Van Assche
878560dae0 init_test: Fix a race condition
Wait until strace has attached to the service instead of assuming that
it has attached after one second.

Change-Id: Ifb71fa2419563e1334d8500ea867ec92121395e0
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-02-15 09:27:32 -08:00
Bart Van Assche
947d75f0b8 init_test: Simplify the gentle_kill test
Remove the ConvertToArgv() function. Do not cast the std::string::find()
result. Make the strace path absolute.

Change-Id: If329e91275c834ba375863e40901f6be07a5f347
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-02-15 09:27:32 -08:00
Treehugger Robot
352f64df50 Merge "Only run GentleKill test as root" am: 120902971b am: 9879ebd747 am: 3034fd6cde
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2427211

Change-Id: I20f4ffc9aaad018494ef4409a312017c10b31cac
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-02-10 05:15:32 +00:00
Daniel Rosenberg
2f0508686e Only run GentleKill test as root
Without root, Service::Start() fails due to lack of permissions.

Bug: 267559075
Test: run cts -m CtsInitTestCases -t init#GentleKill
      atest init#GentleKill
      Will skip under cts, pass under atest
Change-Id: I69e8be7000718bdba1c2acd9675b5645c0891afc
2023-02-08 17:31:49 -08:00
Treehugger Robot
7828311140 Merge "Add bug component id to OWNERS" am: d019150a00 am: e9cdece2b4 am: 9a3b7fb7a9
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2420719

Change-Id: I125977ea75accb121b29c9111ff6b1f1478ef55c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-02-07 04:46:44 +00:00