Commit graph

4017 commits

Author SHA1 Message Date
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
Treehugger Robot
d019150a00 Merge "Add bug component id to OWNERS" 2023-02-07 02:44:56 +00:00
Jiyong Park
078cc15b00 Add bug component id to OWNERS
Bug: 261015504
Test: N/A
Change-Id: I07d951e0bc551f2e642ffc2ee1aaeca2b7e77626
2023-02-06 07:39:56 +00:00
Treehugger Robot
57f4fb60f9 Merge "Fix a spelling error" am: 7eb6dc9104 am: 4c180fed89 am: 01f2e503c7
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2412253

Change-Id: Ieb69c774beb1ec5e6254df9a3776e14b168e59bc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-02-06 06:25:51 +00:00
Bart Van Assche
dcc208f38a Fix a spelling error
Fixes: 2e4b3ffa75 ("Use Apex sepolicy if it's available")
Change-Id: Ib937fa8384658f05ff435024f7834c5df12f0d22
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-02-02 22:31:51 +00:00
Alex Hong
0bbcd7ce56 Merge "Reland "Set the log callback earlier for showing system property set denials"" am: 4c80eb13aa am: 644b8c7eae am: cc4d5fc6b2
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2361281

Change-Id: I55429763b82be498ea4e97d601a7115ca83ed5d6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-02-02 21:47:42 +00:00
Alex Hong
057b94215a Reland "Set the log callback earlier for showing system property set denials"
PropertyInit loads the build.prop files and set the system properties.
Set the SELinux log callback before that to show the avc denials for debugging.

Test: $ make init_system
      Push this module and ensure system property set denials are shown during boot
Bug: 185920634
Bug: 211547922
Change-Id: If9f34d469d3da2ebdfe64bb611de85a3ca37e000
2023-01-31 22:11:16 +08:00
Paul Lawrence
edf562f4cb Merge "Listen on property_service_for_system socket" 2023-01-27 23:18:25 +00:00
Paul Lawrence
90879edeea Listen on property_service_for_system socket
It is easy to dos the property_service socket, since it will wait for a
complete data packet from one command before moving on to the next one.
To prevent low privilege apps interfering with system and root apps,
add a second property_service socket that only they can use

Bug: 262237198
Test: Run POC in one shell, set properties as root and system in another
Ignore-AOSP-First: Security fix
Change-Id: I1d6fec833fc24352546bb90f770d3c4b675f5716
2023-01-27 11:24:23 -08:00
David Anderson
298f6c033b Merge "Disable multilib for CtsInitTestCases." 2023-01-17 23:15:47 +00:00