Commit graph

4136 commits

Author SHA1 Message Date
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
8dab2ef586 Merge "Use ro.boot.serialconsole to disable console services" 2023-03-02 20:04:33 +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
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
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
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
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
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
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
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
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
David Anderson
298f6c033b Merge "Disable multilib for CtsInitTestCases." 2023-01-17 23:15:47 +00:00
Treehugger Robot
b9e1821201 Merge "Find a zoned partition automatically" 2023-01-17 22:22:26 +00:00
Jaegeuk Kim
b92e5b5c48 Find a zoned partition automatically
Since we cannot create a gpt table on zoned LU, we cannot make a generic symlink
from it. Instead, let's make it by uevent, "/dev/block/by-name/zoned_device".
Note that, we support only one zoned device in the system.

Bug: 265180564
Change-Id: Ie62b0fd68b77e3e43cf0f5c5cad9503150174271
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2023-01-14 10:29:31 -08:00
Akilesh Kailash
545870e53a Merge "init: Wait for daemon to fully spin up all threads" 2023-01-13 06:35:33 +00:00
David Anderson
9b9924b412 Merge "init: Allow persistent properties to be written asynchronously." 2023-01-12 21:50:42 +00:00
Treehugger Robot
e8d42e65c8 Merge changes I169b52cf,Ieb0e4e24
* changes:
  init: Add test for gentle_kill
  init: Add gentle_kill service property
2023-01-11 23:16:55 +00:00
Akilesh Kailash
717ee9120a Merge "init: Avoid killing all processes during reboot if update is in progress" 2023-01-11 20:52:13 +00:00
Akilesh Kailash
5140f3ad47 init: Wait for daemon to fully spin up all threads
During selinux transition, daemon will notify `init` process
by writing to file "/metadata/ota/daemon-alive-indicator".

Init will wait until daemon notifies it. Furthermore, daemon
will only write to that file once all threads are spin up
and attached to dm-user misc devices.

Once snapshot-merge is completed, this file will be removed.
Additionally, during boot, init will also ensure that
there are no stale files and will try to remove just
before selinux transition.

Bug: 262407519
Test: OTA on Pixel - Verify new file exits and init waits until daemon
is fully up.
Change-Id: Iabef58ad282d80a7afa493e9df9468ae41a13e44
Signed-off-by: Akilesh Kailash <akailash@google.com>
2023-01-11 19:24:56 +00:00
Treehugger Robot
7fcaa14e27 Merge "Add comment about out-of-bounds being on purpose" 2023-01-11 18:55:18 +00:00
Jooyung Han
6b88d1684c Parser::ParseConfigFile returns Result<void>
ParseApexConfigs() uses Parser::ParseConfigFile() to parse .rc files in
the target apex. ParseConfigFile() returning bool (with logging on
error) doesn't propagate the error message back to the callers
(including apexd or PackageManager).

We'd better to migrate other Parse*() methods of Parser class to return
Result<T>. But this change focuses on plumbing error progagation for
APEX configs.

Bug: 238820991
Test: atest CtsInitTestCases
Change-Id: Ifad97635dbb53a70053ec73a7a5b7e742466daf6
2023-01-11 17:20:16 +09:00
Akilesh Kailash
2c52d09078 init: Avoid killing all processes during reboot if update is in progress
Bug: 262321167
Test: Reboot device post OTA reboot
Change-Id: I5d13844e4e157d24a414dce668163bb1915bf65e
Signed-off-by: Akilesh Kailash <akailash@google.com>
2023-01-11 06:00:34 +00:00
Daniel Rosenberg
ed8178c8cc init: Add test for gentle_kill
Tests that a service marked as gentle_kill terminiated with SIGTERM

Bug: 249043036
Test: atest CtsInitTestCases:init#GentleKill
Change-Id: I169b52cfd74f07b4d2439761ea315117323b3fcb
2023-01-10 18:29:46 -08:00
Daniel Rosenberg
de76688e40 init: Add gentle_kill service property
If a service specifies gentle_kill, attempt to stop it will send SIGTERM
instead of SIGKILL. After 200ms, it will issue a SIGKILL.

Bug: 249043036
Test: atest CtsInitTestCases:init#GentleKill
      Added in next patch
Change-Id: Ieb0e4e24d31780aca1cf291f9d21d49cee181cf2
2023-01-10 18:29:46 -08:00
David Anderson
0af9ab3308 init: Allow persistent properties to be written asynchronously.
Persistent properties are flushed with fsync which can cause the
non-persistent property write path to block.

Bug: 250125146
Test: manual test with ro.property_service.async_persist_write = true
Change-Id: Id123bfc7de948b76c51b4d98d00c8cb4a0850bf1
2023-01-09 16:41:56 -08:00
Florian Mayer
04fb2c838d Add comment about out-of-bounds being on purpose
Change-Id: I97e334f0555cce80eeab6567905054d807af3c91
2023-01-09 21:46:10 +00:00
Carlos Galo
1447120f78 Set memlock rlimit to 64KB
Defaulting Android to limit memlock to 64KB. This will help preventing
pages from being swapped until the app is killed it's memory will stay
resident. CTS test is enforced only in U+ devies.

Bug: 201797650
Test: Added new test to verify we are memlock at or under 64KB
Change-Id: I5a9e9da12f6df5a056ee47d0593c13e9c779e054
2023-01-05 16:29:59 +00:00
Bart Van Assche
f85317fb43 Make an error message more informative
From
https://android-build.googleplex.com/builds/tests/view?testResultId=TR66328435937757440&invocationId=I00700010119503421:

system/core/init/init_test.cpp:219: Failure
Failed
Value of: service-&gt;Start()
  Actual: createProcessGroup(0, 15611) failed for service 'console'
  Expected: is ok

The above error message does not contain enough information to
root-cause the test failure. Hence this CL that makes an error message
more informative.

Bug: 262090304
Change-Id: I09929b2f2aabf1eec4d90ec93234a9e968888da4
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-12-31 23:41:29 +00:00
Nikita Ioffe
24d1c238ce Revert "host_init_verifier: add check for root services and linux capabilities"
This reverts commit f1e3bfff40.

Reason for revert: Breaks builds

Bug: 263874232
Change-Id: Iabe5cd01114bf4a3731ace4345da8009e6b86f74
2022-12-28 16:18:20 +00:00
Nikita Ioffe
f1e3bfff40 host_init_verifier: add check for root services and linux capabilities
If a service that runs under root doesn't have the capabilities field in
it's definition, then it will inherit all the capabilities that init
has.

This change adds a linter to detect such services and ask developers to
explicitly specify capabilities that their service needs. If service
doesn't require any capabilities then empty capabilities fields should
be added in the service definition.

The actual access control list on what capabilities a process can use is
controlled by the SELinux, so inheriting all the init capabilities is
not a security issue here. However, asking services to explicitly
specify the capabilities they need is a good defense-in-depth mechanism.

So far this linter only checks the services on /system partition.

All currently offending services are added to the exempt list. I will
work on fixing some of them in the follow-up changes.

Bug: 249796710
Test: m dist
Change-Id: I2db06af165ae320a9c5086756067dceef20cd28d
2022-12-22 22:08:49 +00:00
Jiyong Park
3e951a7758 Merge "Skip StartConsole test on user builds." 2022-12-20 07:08:23 +00:00
Jiyong Park
5b7a51a59a Skip StartConsole test on user builds.
It runs a service with root privilege which can't be done on user
builds. Until the issue is resolved, skip the test on user builds.

Bug: 262090304
Test: N/A
Change-Id: I690ffbd7fdaef688a0c862e0c653e9b21e281ece
2022-12-20 10:46:31 +09:00
Treehugger Robot
fd98382506 Merge "Run the console test with /dev/null" 2022-12-16 01:54:14 +00:00
Nikita Ioffe
cc0e90a964 Update docs around capabilities and root processes
Current documentation is misleading: if a service runs as root and
doesn't specify any capabilities, then it will start with all the
capabilities (note that whether it can use them is controlled by
selinux).

Test: n/a
Bug: 249796710
Change-Id: I0d6a884127c6a6c5b651c1222fcf48322065daae
2022-12-15 18:04:21 +00:00
Jiyong Park
ae412804ca Run the console test with /dev/null
The availability of /dev/console varies across different devices and
even across different build variants (ex: userdebug/user). Instead of
relying on the device-specific condition, use the /dev/null as the
console device for the test.

Bug: 262090304
Test: atest CtsInitTestCases on raven-user
Change-Id: I3b12d66e94609328dfdd6f640d1adb88a773fa38
2022-12-15 16:32:38 +09:00
Jiyong Park
717ece7397 Merge "Clarify the behavior about event and property triggers" 2022-12-14 15:16:31 +00:00
Steven Moreland
bb1ee3c689 Merge "ignore error -> log" 2022-12-14 01:29:20 +00:00
Steven Moreland
507209ba55 ignore error -> log
Current code ignores an error, which is a code
rot risk.

Bug: 261700511
Change-Id: I04ca7046dc42d761ecaaf56f6100c96cc8298ec5
Test: N/A
2022-12-13 22:43:58 +00:00
David Anderson
95cfb31bd2 Merge "Support sysfs changes in the Linux 5.15 kernel." 2022-12-12 18:38:04 +00:00
Treehugger Robot
5c3e24816d Merge "Kill services even when cgroups is disabled" 2022-12-12 01:20:45 +00:00
Inseob Kim
a049a9928b Kill services even when cgroups is disabled
process_cgroup_empty_ is used to indicate that a service is already
killed or not. If cgroup support lacks, services cannot be killed
because process_cgroup_empty_ is always true.

This change fixes it by not assigning process_cgroup_empty_ as true.
Instead, make KillProcessGroup send signals even when cgroup is
disabled. Also DoKillProcessGroupOnce() is updated so it returns a number of killed processes, excluding already dead processes. This behavior agrees with its name (DoKillProcessOnce), and it prevents regression upon missing cgroups, because kill(-pgid) will always
"succeed" so KillProcessGroup will loop even when all processes are
already dead.

Bug: 257264124
Test: boot microdroid, see services are terminated
Change-Id: I19abf19ff1b70c666cd6f12d0a12956765174aaa
2022-12-12 01:19:26 +00:00
David Anderson
d6bf86b8cf Support sysfs changes in the Linux 5.15 kernel.
DM_DEV_CREATE no longer creates sysfs nodes. Note this in ueventd and
add some helper APIs to libdm, so devices can be created with a
placeholder table.

This also fixes a bug in dmctl where the detailed info on suspended
devices was wrong.

Bug: 259328366
Test: dmctl with "uevents" tool
Change-Id: I822f8010e48d32841aa0ee508822f76d03a3dd85
2022-12-08 16:22:47 -08:00
David Anderson
cbd082d46d Disable multilib for CtsInitTestCases.
Bug: 260393485
Test: run cts -m CtsInitTestCases
Change-Id: I92a11b7961411b22525d4434312479878b353b55
2022-12-06 20:13:53 -08:00
Chih-hung Hsieh
48cd41324b Merge "Fix potential memory leaks" 2022-12-07 02:36:27 +00:00
Bart Van Assche
d3484c84bf Merge "init: Enable ANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION" 2022-12-06 23:05:30 +00:00
Bart Van Assche
9dbf8c32e9 Merge "init: Prevent copying of Service objects" 2022-12-06 17:32:23 +00:00
Bart Van Assche
b3f9f6f4c6 Merge "init/Android.bp: Sort cflags alphabetically" 2022-12-06 17:29:41 +00:00
Treehugger Robot
70b22e1c5b Merge "init: Make an error message more informative" 2022-12-06 03:04:16 +00:00
Treehugger Robot
ab3bc215e8 Merge "init: Convert a single-element array into a scalar" 2022-12-06 01:48:58 +00:00
Chih-Hung Hsieh
784e63c9a2 Fix potential memory leaks
Bug: 259995529
Test: make tidy-system_subset
Change-Id: I604a308caf498a854b916dc86a8e274148c21ab0
2022-12-05 23:52:58 +00:00
Bart Van Assche
0bb4757d03 init: Prevent copying of Service objects
Service objects have external state (the child process) and hence must
not be duplicated. Disable the copy constructor and the assignment
operator to prevent that these objects get duplicated accidentally.

Bug: 213617178
Change-Id: Ia5391154b94eca7f12be69eabcdf3f173fc06452
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-12-05 11:41:26 -08:00
Bart Van Assche
42764c4e3e init: Make an error message more informative
Make it easier to diagnose service failures.

Bug: 213617178
Change-Id: I27135cb32b6a98b2fe24ab2324dffbf5b591fdd5
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-12-05 11:41:10 -08:00
Bart Van Assche
c41a4826d1 init: Do not invoke the ServiceList destructor when exiting
From the Google C++ style guide: "Objects with static storage duration
are forbidden unless they are trivially destructible." Hence this CL.

Bug: 213617178
Change-Id: I4c9a51618ee1eb14ed439295a5fc0101b940a63d
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-12-05 10:45:49 -08:00
Bart Van Assche
aee2ec8f1e init: Enable ANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION
From the unique_fd.h header file: "unique_fd's operator int is
dangerous, but we have way too much code that depends on it, so make
this opt-in at first."

From the Google C++ style guide: "Do not define implicit conversions."
See also go/cstyle#Implicit_Conversions.

Hence this CL that disables unique_fd::operator int().

Change-Id: I28d94755d5408f63e5819da8d1cbc285057f867f
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-12-05 09:40:06 -08:00
Bart Van Assche
91ba2197ef init/Android.bp: Sort cflags alphabetically
Sort the compiler flags alphabetically before adding a new macro
definition.

Change-Id: If919333302817406a890c9622396ec96920adf29
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-12-05 09:40:05 -08:00
Bart Van Assche
fdc0f89a4a init: Convert a single-element array into a scalar
Simplify PollIn() by converting a single-element array into a scalar. No
functionality is changed.

Change-Id: I3ef36b9c0daafeed3a92f90c7a7c4fe0654dd586
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-12-05 09:40:05 -08:00
Bart Van Assche
fa4926a9de Merge "Revert "init: Add more diagnostics for signalfd hangs."" 2022-12-01 17:50:27 +00:00
Jiyong Park
f477319692 Clarify the behavior about event and property triggers
See the comment threads at [1] for the rationale behind the behavior.

[1] https://android-review.git.corp.google.com/c/platform/system/core/+/161601/16/init/action.cpp#232

Bug: N/A
Test: N/A

Change-Id: I8b271073ec14ad9fa9add5df60577b34d1df3241
2022-12-01 10:38:48 +09:00
Bart Van Assche
3b21d95a0e init: Fix and re-enable the init#StartConsole test
Skip the test if /dev/console does not exist. Fix the console service
security label. Fix the getsid() test.

Bug: 260104465
Test: atest 'CtsInitTestCases:init#StartConsole' on a P2023 development board
Change-Id: If2533a3f205f922a9b04a748cb558a09c5925986
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-11-30 13:25:47 -08:00
Bart Van Assche
29d8a42d14 Revert "init: Add more diagnostics for signalfd hangs."
Revert commit 14f9c15e05 ("init: Add more diagnostics for signalfd
hangs") because:
* That commit was intented to help with root-causing b/223076262.
* The root cause of b/223076262 has been fixed (not blocking SIGCHLD
  in all threads in the init process).

Test: Treehugger
Change-Id: I586663ec0588e74a9d58512f7f31155398cf4f52
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-11-30 09:17:16 -08:00
Bart Van Assche
027b275b57 init: Disable test init#StartConsole
Bug: 260104465
Change-Id: I43a19b2451bad955d101d9ebdc3c98419d83597d
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-11-22 16:38:43 -08:00
Bart Van Assche
01e6669c66 init: Fix a race condition in KillProcessGroup()
Multiple tests in CtsInitTestCases, e.g. RebootTest#StopServicesSIGKILL,
can trigger the following race condition:
* A service is started. This involves calling fork() and also to call
  RunService() in the child process. RunService() calls setpgid().
* Service::Stop() is called and calls KillProcessGroup().
  KillProcessGroup() calls kill(-pgid, SIGKILL) before the child process
  has called setpgid(). pgid is the process ID of the child process. The
  kill() call fails because setpgid() has not yet been called.

Fix this race condition by adding a setpgid() call in the parent process
and by waiting from the parent until the child has called setsid() if a
console is attached.

Bug: 213617178
Change-Id: Ieb9e6908df725447e3695ed66bb8bd30e4e38aa9
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-11-21 11:42:44 -08:00
Bart Van Assche
987391656f init: Introduce RequiresConsole()
Prepare for adding more code in the parent process that depends on
whether or not a console is required.

Bug: 213617178
Change-Id: I066ede32fcd4ce09d06be23158f3c1970064a697
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-11-18 09:49:43 -08:00
Bart Van Assche
c8f34254b8 init: Introduce symbolic names for certain constants
Make the code easier to read by introducing symbolic names for the
constants used by Service::Start() for communication between the parent
and child processes.

Bug: 213617178
Change-Id: I3e735e149682fa9df2ed57f75eb5a67d7c68bd92
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-11-18 09:49:01 -08:00
Bart Van Assche
d394f74365 init: Reduce the number of system calls
Change setpgid(0, getpid()) into setpgid(0, 0). This patch removes one
system call but does not change the behavior of the code. From the
setpgid() man page: "If pgid is zero, then the PGID of the process
specified by pid is made the same as its process ID."

Bug: 213617178
Change-Id: I7031d9eb3711f526751da495c07a8927f9386d97
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-11-18 09:45:33 -08:00
Bart Van Assche
41787239ec Revert "init: Rename 'cgroups_activated' into 'fifo'"
Revert commit 9c61dad67e in preparation of
introducing a second interprocess communication channel.

Bug: 213617178
Change-Id: I2959a3902a1b994cca2ac99855be1fc60d63bcbb
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-11-18 09:42:14 -08:00
Bart Van Assche
bfcf4374ed init: Document which class Service members are not modified
It is nontrivial to derive from the implementation of class Service
which members are not modified. Hence this CL that documents this by
declaring these members 'const'.

Change-Id: I27b907a1c7044376d5c5393a29050c66cbdab7bf
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-11-18 09:42:14 -08:00
Bart Van Assche
5d18891e60 init: Add a unit test for the "start console" action
Treehugger starts Cuttlefish with the console disabled. Add a test that
enables the console. The purpose of this test is to trigger the code paths
in Service::Start() that are unique to processes associated with a
console.

Bug: 213617178
Change-Id: I834632ce6ec5c237c9c2c3f5b1aa7bc98c3ef260
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-11-18 09:42:05 -08:00
Bart Van Assche
f26e59ebba Revert "init: Fix a race condition in KillProcessGroup()"
This reverts commit 15e5ecdcd7.

Reason for revert: breaks console support.
Bug: 213617178
Bug: 258754901
Change-Id: Iffe213e2cd295461a427621f2b84933f1bebd39f
2022-11-15 00:55:45 +00:00
Bart Van Assche
15e5ecdcd7 init: Fix a race condition in KillProcessGroup()
Multiple tests in CtsInitTestCases, e.g. RebootTest#StopServicesSIGKILL,
can trigger the following race condition:
* A service is started. This involves calling fork() and also to call
  RunService() in the child process. RunService() calls setpgid().
* Service::Stop() is called and calls KillProcessGroup().
  KillProcessGroup() calls kill(-pgid, SIGKILL) before the child process
  has called setpgid(). pgid is the process ID of the child process. The
  kill() call fails because setpgid() has not yet been called.

Fix this race condition by adding a setpgid() call in the parent process
and by waiting from the parent until the child has called setsid() if a
console is attached.

Bug: 213617178
Test: Cuttlefish + atest 'CtsInitTestCases'
Change-Id: I6931cd579e607c247b4f79a5b375455ca3d52e29
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-11-10 09:08:21 -08:00
Inseob Kim
0fbc1d7e31 Don't unmount APEXes in microdroid
In microdroid, APEXes are passed as block devices from host, and then
mounted directly, without using /data. Unmounting APEXes on reboot is
for clean unmount of /data, so it's not needed in microdroid.

This skips unmounting in microdroid to remove unnecessary SELinux
denials.

Bug: 256793087
Test: run microdroid and reboot, see no denials happen
Change-Id: Iaf737876f5ab5de5e8f76ed8bb0963cc25d73a80
2022-11-09 12:50:14 +09:00
Bart Van Assche
9c61dad67e init: Rename 'cgroups_activated' into 'fifo'
Prepare for using the interprocess communication channel in two
directions.

Bug: 213617178
Change-Id: Ic78a3d8a2ec1f808fa5b4c4b198051655ee1b0ec
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-11-04 14:56:43 -07:00
Bart Van Assche
8462ceef62 Merge "Revert "init: Fix a race condition in KillProcessGroup()"" 2022-11-03 18:21:59 +00:00
Bart Van Assche
dcc378e53c Revert "init: Fix a race condition in KillProcessGroup()"
This reverts commit d8ef6f84d4.

Reason for revert: b/256874349

Change-Id: I86a1e03a0d2979db1c54abd3e78c32591fda98a1
2022-11-03 15:15:25 +00:00
Shen Lin
63ae3fdd9d init: Amend code format for DoLoadApex
Test: m init
Change-Id: I9d873cdf067ea586f75e62ff8a39cb753151f9ec
2022-11-02 11:01:04 +08:00
Treehugger Robot
c8c24a7255 Merge changes I4c55790c,I14baaa7a
* changes:
  init: Fix a race condition in KillProcessGroup()
  init: Document that ReapOneProcess() does not modify 'pid'
2022-10-27 23:17:03 +00:00
Treehugger Robot
0eaca46f48 Merge "Add mmap_rnd_bits routine for riscv64" 2022-10-27 22:28:21 +00:00
Bart Van Assche
d8ef6f84d4 init: Fix a race condition in KillProcessGroup()
Multiple tests in CtsInitTestCases, e.g. RebootTest#StopServicesSIGKILL,
can trigger the following race condition:
* A service is started. This involves calling fork() and also to call
  RunService() in the child process. RunService() calls setpgid().
* Service::Stop() is called and calls KillProcessGroup().
  KillProcessGroup() calls kill(-pgid, SIGKILL) before the child process
  has called setpgid(). pgid is the process ID of the child process. The
  kill() call fails because setpgid() has not yet been called.

Fix this race condition by adding a setpgid() call in the parent process
and by waiting from the parent until the child has called setsid() if a
console is attached.

Bug: 213617178
Test: Cuttlefish + atest 'CtsInitTestCases'
Change-Id: I4c55790c2dcde8716b860aecd57708d51a081086
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-10-27 14:29:35 -07:00
Bart Van Assche
c7d7ed0eae init: Document that ReapOneProcess() does not modify 'pid'
It is essential for correct operation of ReapAnyOutstandingChildren()
that ReapOneProcess() does not modify 'pid'. Make it easier to verify
for humans that ReapOneProcess() does not modify the 'pid' local
variable. Document the value of siginfo.si_signo with DCHECK_EQ()
statements.

Bug: 213617178
Change-Id: I14baaa7adbe5416b7f777f32fb76896f2ae27b4e
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-10-27 14:29:35 -07:00
Treehugger Robot
1b2d443626 Merge "init: Log more information if stopping times out" 2022-10-27 21:12:19 +00:00
Bart Van Assche
ea595ba2a0 init: Log more information if stopping times out
The newly logged information includes the pending signals bitmask (SigPnd).
That information allows to determine whether kill() did not deliver a
signal or whether SIGCHLD has not been processed in time. This patch is
expected to help with root-causing b/254878413.

Bug: 254878413
Change-Id: Id33d1fb724163f8e5d4b3edfeb6c4be5321c0d95
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-10-27 12:17:34 -07:00
Mao Han
c09eee098b Add mmap_rnd_bits routine for riscv64
Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Change-Id: Ide793f4365fee67f30e35302365c4a7a5ba1f021
2022-10-27 17:59:25 +00:00
Bart Van Assche
1a5b59386d init: Fix HandleSignalFd()
There are two bugs in HandleSignalFd():
* If the one_off argument is true and if no data is read from the
  signalfd, 'siginfo' is left uninitialized and used in the switch
  statement in HandleSignalFd().
* The PLOG() statement in the switch statement should be a LOG()
  statement since it does not report a failed system call.

This CL has been tested by changing kDiagnosticTimeout locally from 10s
into 100ms.

Change-Id: I0e488dd95bc13e1befaef770c0748d1d47f6e431
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-10-27 08:07:26 -07:00
Bart Van Assche
874448f4aa Merge "subcontext: Change a std::string argument into std::string_view" 2022-10-27 14:34:57 +00:00
Nathan Huckleberry
f2d93cebfd Merge changes I8174adf8,I9d252b0b
* changes:
  Expose system property for dm-verity check_at_most_once
  Fix flaky AVB test from late verity_update_state
2022-10-27 00:45:01 +00:00
Bart Van Assche
462ea55095 subcontext: Change a std::string argument into std::string_view
This change prevents that a later CL will trigger the following warning:

parameter 'test_context' is passed by value and only copied once; consider
moving it to avoid unnecessary copies

Change-Id: If5837ee6438efdf194781de041779c1089897789
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-10-26 09:31:59 -07:00
Nathan Huckleberry
997d738dda Expose system property for dm-verity check_at_most_once
Allow us to check if check_at_most_once is set for any partitions.

This property should be false for any device with a reasonable amount of
RAM and a modern CPU. Enabling check_at_most_once violates AVB best
practices, it should only be allowed on performance limited devices.

Bug: 253033920
Test: Ensure that avbHashtreeNotUsingSha1 CTS test still passes
    and that partition.system.verified.check_at_most_once is set.
Change-Id: I8174adf81111cc0df547ea01f81b0dfaca32631f
Signed-off-by: Nathan Huckleberry <nhuck@google.com>
2022-10-25 21:12:52 +00:00
Bart Van Assche
1693f420d4 init: Introduce class InterprocessFifo
Prepare for introducing a second interprocess communication channel by
introducing the class InterprocessFifo. Stop using std::unique_ptr<> for
holding the pipe file descriptors. Handle EOF consistently.

Bug: 213617178
Change-Id: Ic0cf18d3d8ea61b8ee17e64de8a9df2736e26728
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-10-25 06:56:50 -07:00
Nikita Ioffe
537ab23872 Merge "init: skip cgroup/task_profiles configuration if cgroups are disabled" 2022-10-24 07:14:12 +00:00
Bart Van Assche
77f3fe5e68 init: Fix the implementation of the task_profiles keyword
The documentation added by commit c9c0bbac53 ("init: Add task_profiles
init command") mentions that the task_profiles keyword sets process
attributes. Make the implementation of that keyword match the
documentation.

Change-Id: Ia080132f16bfc2488f8c25176d6aed37a2c42780
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-10-21 15:34:19 -07:00
Bart Van Assche
4029b05b04 Add __ANDROID_API_[STU]__ definitions
Bring the host_init_stubs.h header file in sync with the
<android/api-level.h> header file.

Change-Id: I0d344b5f89f909e5315a0075773efd0b725a72a4
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-10-21 15:33:09 -07:00
Nikita Ioffe
c2b1654c11 init: skip cgroup/task_profiles configuration if cgroups are disabled
We are planning to remove cgroups from the Micrdroid kernel, since the
entire VM belongs exclusively to a single owner, and is in the control
of the cgroups on the host side.

This patch expoxes CgroupAvailable API from libprocessgroup, and changes
init to query the CgroupAvailable API before doing any
cgroups/task_profiles related work.

Bug: 239367015
Test: run MicrodroidDemoApp
Test: atest --test-mapping packages/modules/Virtualization:avf-presubmit
Change-Id: I82787141cd2a7f9309a4e9b24acbd92ca21c145b
2022-10-21 13:14:23 +01:00
Bart Van Assche
dcd23dfc58 init/epoll: Stop using smart pointers
Change the type of 'handler' from std::shared_ptr<Handler> into Handler.
This change is safe since a previous CL moved the handler calls from the
Epoll::Wait() caller into Epoll::Wait() itself.

Bug: 213617178
Change-Id: Ife79e6863536b96ee4bb3cd778f6b0b164a95fed
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-10-20 09:32:51 -07:00
Bart Van Assche
bc5c4a4659 init/epoll: Make Epoll::Wait() easier to use
Invoke the callback functions from inside Epoll::Wait() instead of
returning a vector with pointers to callback functions. Remove handlers
after handler invocation finished to prevent that self-removal triggers
a use-after-free.

The CL that made Epoll::Wait() return a vector is available at
https://android-review.googlesource.com/c/platform/system/core/+/1112042.

Bug: 213617178
Change-Id: I52c6ade5746a911510746f83802684f2d9cfb429
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-10-20 09:32:51 -07:00
Bart Van Assche
a1c8a622b2 init/epoll: Switch to aggregate initialization
Make it easier to verify for humans that all data structure members are
initialized. No functionality is changed.

Bug: 213617178
Change-Id: I1ce2af566dba51f2032f2e7518576a67e666d12e
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-10-20 09:32:51 -07:00
Bart Van Assche
4842650043 init: Improve readability of the code in SecondStageMain()
Change the type of epoll_timeout from
std::optional<std::chrono:milliseconds> into std::chrono::milliseconds.
No functionality is changed.

Bug: 213617178
Change-Id: Ieb150e0aeabdb79c8da4649875ea3ed59297343b
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-10-20 09:32:51 -07:00
Bart Van Assche
b0177a0828 init/epoll: Fix a potential use-after-free
If UnregisterHandler() is called from inside a handler for an event that
has not yet been processed then that will result in a use-after-free.
Fix this by passing file descriptors to epoll_ctl() instead of pointers
to map elements.

Bug: 213617178
Change-Id: Ie62e3a299af964271ec24cd8fc2e794042b77ee6
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-10-18 16:34:12 -07:00
Bart Van Assche
a2c160449b init: Introduce Epoll::SetFirstCallback()
Prepare for optimizing Epoll::Wait() by moving the
ReapAnyOutstandingChildren() call into Epoll::Wait(). No functionality
is changed.

Bug: 213617178
Change-Id: I280ea0069ed29cf323e4177ec500b30b900f7c8d
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-10-18 09:17:55 -07:00
Bart Van Assche
20954a8e34 init/epoll_test: Improve this test
Add a move constructor in the CatchDtor class. Check the .emplace()
result. Simplify the destructor. Initialize handler_invoked. Explain the
purpose of this test.

Bug: 213617178
Change-Id: I4d6f97dbb2705a2f2dd78e449ae8de74e90b102f
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-10-18 09:17:55 -07:00
Akilesh Kailash
889b446810 Merge "init: Detach daemon only after sepolicy is loaded" 2022-10-11 21:04:42 +00:00
Yi-yo Chiang
9b123de886 Merge "Remove deprecated BOARD_BUILD_SYSTEM_ROOT_IMAGE" 2022-10-11 10:31:19 +00:00
Akilesh Kailash
035e557fd3 init: Detach daemon only after sepolicy is loaded
The new sequence of operation would be:

1: Load sepolicy - Daemon will continue to be alive and serve any I/O request

2: After sepolicy loading is complete - Switch the device-mapper tables.

3: Kill the block device daemon launched in the first-stage init.

4: Re-launch the daemon with the correct selinux labels set.

5: Enforce the sepolicy

Bug: 240321741
Test: Full OTA on pixel
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: Idd392f0f0aae7d93e546c0ec0762e6c07b6263e4
2022-10-10 21:58:52 +00:00
Sayanna Chandula
5754b5ab10 init: Support reboot reason with thermal warmreset
Thermal shutdown could be due to tskin temperature or
battery temperature. Pass reason while rebooting the
system to reflect properly in boot.reason

Bug: 238464124
Test: Build and boot on device. Check reboot reason
for thermal shutdown and battery thermal shutdown with
thermal warmreset enabled.

Change-Id: I192562fed48ae7da7843e383362cd22a76ce479f
2022-10-07 14:11:25 -07:00
Yi-Yo Chiang
ddc9763ee2 Remove deprecated BOARD_BUILD_SYSTEM_ROOT_IMAGE
This variable is always false or empty now, so clean up remaining
references of the variable.

Bug: 241346584
Test: Presubmit
Change-Id: Id5c37a1391239206477fd802d364a2678692f513
2022-10-07 21:17:40 +08:00
Bob Badour
03d5052754 Add LOCAL_LICENSE_KINDS to system/core
Added SPDX-license-identifier-Apache-2.0 to:
  init/fuzzer/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all
Change-Id: I2db55c80799d0a8fc5935d9b07a2ddb17eb7235e
2022-10-06 19:59:07 +00:00
Treehugger Robot
71d9f3607b Merge changes I264d0891,I1af733e7,Iae344c1e
* changes:
  Added init_ueventHandler_fuzzer
  Added init_property_fuzzer
  Added init_parser_fuzzer
2022-10-06 13:59:37 +00:00
David Anderson
aaa16bbad4 Merge "init: Statically link libbootloader_message." 2022-10-04 16:32:50 +00:00
David Anderson
12e53bc350 init: Statically link libbootloader_message.
This is to resolve idiosyncracies with test packaging.

Bug: 244284630
Test: ldd -d -r CtsInitTestCases
Change-Id: Iec2c14c3ca5cd359b79d9e1f12e689c0eeffb122
2022-10-03 21:37:56 -07:00
Florian Mayer
84a30c8526 Merge "[MTE] Add device config to control upgrade time" 2022-10-03 17:47:12 +00:00
Cole Faust
7e279e97a3 Fix module-file name collisions
Bazel doesn't allow a module and file with the same name.

Bug: 198619163
Test: Presubmits
Change-Id: I345086764071ca649de1ac11804e21675cd5e59d
2022-09-20 12:33:47 -07:00
Florian Mayer
caa7a60e2d [MTE] Add device config to control upgrade time
Bug: 169277947
Change-Id: I67eb94a668e60a2970bb086f82cc69396275340a
2022-09-16 09:49:38 -07:00
Florian Mayer
565305b852 Merge "[MTE] only upgrade to SYNC mode for MTE crashes" 2022-09-14 01:22:45 +00:00
Florian Mayer
d705c2dbcd [MTE] only upgrade to SYNC mode for MTE crashes
Bug: 244471804
Test: atest mte_ugprade_test on emulator
Change-Id: Ie974cf2dec96267012f1b01b9a40dad86551b1be
2022-09-13 15:35:07 -07:00
Adam Langley
ecc14a5958 init: Add option to listen on sockets before starting service.
Review note: Original change was a p-o-c by agl in
https://r.android.com/2094350 which I think is actually
production quality.  I'm just taking it over so that he doesn't
get spammed by any review comments as that's not a good use
of his time.

Needed for the hardware entropy daemon (see bug).

Original commit message:
If one needs to create a service that synchronously starts listening on
a socket then there are currently no good options.

The traditional UNIX solution is to have the service create the socket
and then daemonise. In this situation, init could start the service with
`exec_start` and yet not block forever because the service forks and
exits. However, when the initial child process exits, init kills the
daemon process:

> init: Killed 1 additional processes from a oneshot process group for
> service 'foo'. This is new behavior, previously child processes
> would not be killed in this case.

Next, there is a `socket` option for services and (although the
documentation didn't nail this down), the socket is created
synchronously by `start`. However, init doesn't call `listen` on the
socket so, until the service starts listening on the socket itself,
clients will get ECONNREFUSED.

This this change adds a `+listen` option, similar to `+passcred` which
allows a socket service to reliably handle connections.

Bug: 243933553
Test: Started prng_seeder from init using the new listen flag
Change-Id: I91b3b2b1fd38cc3d96e19e92b76c8e95788191d5
2022-09-12 15:16:35 +01:00
Suren Baghdasaryan
633ce78b94 Merge "init: Change extra_free_kbytes.sh to add margin relative to the default watermark level" 2022-09-09 16:55:25 +00:00
Deyao Ren
2880afb77f Merge "Clean up services created after running test" 2022-09-09 16:20:31 +00:00
deyaoren@google.com
909bc47536 Clean up services created after running test
Services created during new tests weren't properly cleaned up after tests. It caused slowdown of subsequent tests as described in b/244486404.
This change kills/terminates services after test with apex services.

To provide some context, original change is at https://android-review.googlesource.com/q/topic:vapex_stop_service. The issue was discovered by android test monitor and filed as a P0 bug.

Bug: 244486404
Change-Id: Ie64e0eb1686e94ef543a457ea49d1d7aeab38c97
2022-09-09 04:15:26 +00:00
Suren Baghdasaryan
cfd8864f9a init: Change extra_free_kbytes.sh to add margin relative to the default watermark level
extra_free_kbytes.sh accepts a parameter representing the number of KB
to add to low and high watermarks. It adds this margin to the current
watermark levels, however this is not how /proc/sys/vm/extra_free_kbytes
knob that it replaces used to work. The old knob would add the margin
relative to the original and not the current level of the watermarks.
Change extra_free_kbytes.sh to add the specified margin to the original
watermark levels to act as correct replacement of the old knob.

Bug: 242837506
Fixes: 642048d969 ("init: Add extra_free_kbytes.sh script to adjust watermark_scale_factor")
Test: repeatedly run 'setprop sys.sysctl.extra_free_kbytes 30375'
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I8af603ba00bd4fb8182b80b3c0969fa96cdd7311
2022-09-08 19:34:43 +00:00
Bob Badour
9cf81ccfef [LSC] Add LOCAL_LICENSE_KINDS to system/core
Added SPDX-license-identifier-Apache-2.0 to:
  init/test_upgrade_mte/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all
Change-Id: I77b956ed672a2f171b78ab1e7bfddc09bd0dc158
2022-09-08 15:23:25 +00:00
Sandro
d01921034c Remove /dev/selinux directory creation from first_stage_init.cpp
Follow-up from aosp/2203897

Bug: 243923977
Test: m and manual verification
Change-Id: I9e41301d2fe4447906253a5c1249dc6c25cd5218
2022-09-07 15:04:59 +00:00
Sandro
1120f7f4a9 Create /dev/selinux folder if it was not created by first-stage-init
The /dev/selinux folder is normally created by first-stage-init
https://cs.android.com/android/platform/superproject/+/master:system/core/init/first_stage_init.cpp;l=299-300;drc=07c86bace1e7a7cc4dd975f10b077d21c3743749

However, in some cases the first-stage-init comes from a GKI prebuilt
boot.img and doess not create the required folder (see for example
b/217677967), resulting in bugs like b/244793900.

I modified the selinux.cpp code to create the /dev/selinux folder if it
does not exist already, as a safety measure.

To verify these changes for b/244793900, follow gpaste/4922166775644160

Bug: 243923977
Test: atest SeamendcHostTest, manual verification
Change-Id: I8fe798643b1aeab2b4caac837055348febf70b94
2022-09-07 11:31:47 +00:00
Treehugger Robot
c113dc3a95 Merge "Upgrade MTE to SYNC after ASYNC crash." 2022-09-06 21:29:14 +00:00
Florian Mayer
2ef47f8f6d Upgrade MTE to SYNC after ASYNC crash.
Bug: 169277947
Test: atest mte_ugprade_test on emulator.
Test: ASSUMPTION_FAILED on non-MTE
Test: ASSUMPTION_FAILED on HWASan
Change-Id: I5328d094ffb106abaa548feb76058c9ebd11d745
2022-09-06 20:10:57 +00:00
Jooyung Han
93c24d7e65 Only run Service::Start() under root
Tests using Service::Start() should run under root. Otherwise tests fail
to start services from the test binary due to lack of permission.

Bug: 244748231
Test: CtsInitTestCases
Change-Id: Ia4eb8457cfad7d44da6b171e44f64238e08af9f7
2022-09-06 10:03:47 +09:00
Jiyong Park
a5dfe700b8 Merge "init: remove unnecessary semicolon" 2022-09-02 11:39:05 +00:00
Jooyung Han
c69bcd4a6d Merge "Removed property init.apex.<apex-name>.load/unload." 2022-09-02 06:46:54 +00:00
Deyao Ren
259b63d71c Removed property init.apex.<apex-name>.load/unload.
Bug: 240533726
Test: atest CtsInitTestCases ApexTestCases
Change-Id: I7ed149f24dc4b116865320c85389ffe7bae6ae0d
2022-09-01 16:14:00 +00:00
Deyao Ren
e37c15e9b0 Merge changes from topic "vapex_stop_service"
* changes:
  Remove and add service and action during apex load and unload
  Stop services when unload an apex
2022-08-31 16:09:43 +00:00
Deyao Ren
238e909349 Remove and add service and action during apex load and unload
Bug: 232114573
Test: atest CtsInitTestCases ApexTestCases
Change-Id: I1f91ada1d44ac2380e2faf8fc25e0a521cc1a826
2022-08-30 17:31:00 +00:00
Treehugger Robot
85d69af38e Merge "Validate persistent properties file" 2022-08-30 08:42:09 +00:00
Bart Van Assche
fcf047113f init: Apply the NormalIoProfile when creating a service
Prepare for migration of the blkio controller to the v2 cgroup hierarchy
by applying the NormalIoProfile when starting a service. While the
NormalIoProfile is automatically applied when the blkio controller is
mounted in the v1 hierarchy, this is not the case for the v2 hierarchy.

Bug: 213617178
Change-Id: I3cad288a31aa2692e10c778ae1e5fdd04acd66d7
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-08-25 14:01:01 -07:00
Paul Crowley
f7c74694d7 Validate persistent properties file
Before loading persistent properties, init now checks if there are any
invalid properties (not starting with "persist.").

Bug: 243723877
Test: atest persistent_properties
Change-Id: Ieb4ddce05916f193388af6b658e1904004ffa473
2022-08-25 11:40:18 -07:00
Sandro
956ce287f3 Add SeamendcHostTest to selinux.cpp TEST_MAPPING
SeamendcHostTest should run when making changes to selinux.cpp, to
ensure the test logic is updated to match the logic selinux.cpp follows
when it decides to compile the SELinux policy in the OpenSplitPolicy
method.

Bug: 238394904
Test: atest --test-mapping system/core/init/TEST_MAPPING:presubmit
Change-Id: Iaf0ec2356a894b071e6875dd41bcf9e842126e42
2022-08-25 09:26:24 +00:00
Deyao Ren
07595e198c Stop services when unload an apex
Bug: 238854102
Test: atest CtsInitTestCases ApexTestCases
Change-Id: I3b9df9424f7841c42bd1bde27cd0e0750615bd6c
2022-08-24 06:22:57 +00:00
kunal rai
803b5f4230 Added init_ueventHandler_fuzzer
Test: ./init_ueventHandler_fuzzer
Bug: 218631398

Change-Id: I264d0891f14cc5836e45d08578347737c94a168f
2022-08-19 11:48:30 +05:30
Akshata Kadam
2ae767105d Added init_property_fuzzer
Test: ./init_property_fuzzer
Bug: 218631398

Change-Id: I1af733e7f82bef2979fc308b0109094b0ebe1e28
2022-08-19 11:48:19 +05:30
Devendra Singhi
d29be4aaa0 Added init_parser_fuzzer
Test: ./init_parser_fuzzer
Bug: 218631398

Change-Id: Iae344c1e174fb5e07a0fb6813744fa1ae78eff6a
2022-08-19 11:48:07 +05:30
Xin Li
4f74d4542d Merge "DO NOT MERGE - Merge Android 13" 2022-08-16 19:08:18 +00:00
Trevor Radcliffe
fcfd725a5c Point directly to generated c sysprop_library
Bug: 226199990
Test: m
Change-Id: I0ea65714f9a27093b37034abde7d59f1951a5cb6
2022-08-12 18:23:40 +00:00
Deyao Ren
aebf88191b Merge "Add apex name to service" am: ec73481e58
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2155014

Change-Id: I3c44c321568173fa11588c2d6c69a43ad48c63f9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-22 23:09:19 +00:00
Jooyung Han
07316159c3 Merge "Respect namespace mnt" am: ba1fbaf50c
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2163903

Change-Id: I67d5c5d93109b97b376fb97b01618893aba8af13
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-22 23:08:56 +00:00
Deyao Ren
ec73481e58 Merge "Add apex name to service" 2022-07-22 23:03:45 +00:00
Jooyung Han
5eb441caca Respect namespace mnt
This fixes the regression of aosp/2153354.
SwitchToMountNamespaceIfNeeded() is supposed to switch between "default"
mount namespace and "bootstrap" mount namespace. But it shouldn't affect
services with its own mount namespace.

Bug: 239882455
Test: make a hal service start in a separate mount namespace
    using 'namespace mnt' in its definition.
    see the mount namespace of the service process
    $ cat /proc/$(pgrep -f myservice)/ns/mnt
Change-Id: I8c80eaec723241c405f48980b9e88640123c43ad
2022-07-23 01:41:18 +09:00
Deyao Ren
df40ed1be1 Add apex name to service
Passed apex file name to service. The file name will be parsed
to determine 1) whether the service is from an apex; 2) apex name

Bug: 236090201

Change-Id: I2c292c0c067f4bf44bb25b1f80e4f972b94f7258
2022-07-22 04:00:30 +00:00
Yi-yo Chiang
a367bdbc4c Merge "Revert "first_stage_mount: Bind mount /system after switch root"" am: e321b113d6
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2159462

Change-Id: Ie9afb0754d73a7bdcf735c8dc6d1c0fec4a514db
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-20 03:57:26 +00:00
Yi-yo Chiang
e321b113d6 Merge "Revert "first_stage_mount: Bind mount /system after switch root"" 2022-07-20 03:49:59 +00:00
Zhuoyao Zhang
54ec48fad7 Revert "first_stage_mount: Bind mount /system after switch root"
This reverts commit d7e6353a69.

Reason for revert: b/239574953 breaking emulator based test on g3

Change-Id: Ib7d17fe8383937c7764f6612cf89db4fb7e5a4d3
2022-07-19 18:09:42 +00:00
Jiyong Park
35ed22e7c0 Merge "Enhance documentation about SetMmapRndBitsAction" am: ccb1ce32cc
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2156356

Change-Id: I86fbac8de9872ef6733cbd05bb140e1c92820d43
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-19 05:06:30 +00:00
Jiyong Park
a9f856b13b Merge "init: don't touch mmap_rnd_compat_bits on 64-bit only builds" am: 2d79c6c096
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2154914

Change-Id: I1e3ef837b69b85c5a554a9d0f41d319dd986ecb4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-19 05:06:20 +00:00
Jiyong Park
ccb1ce32cc Merge "Enhance documentation about SetMmapRndBitsAction" 2022-07-19 04:41:32 +00:00
Jiyong Park
2d79c6c096 Merge "init: don't touch mmap_rnd_compat_bits on 64-bit only builds" 2022-07-19 04:40:39 +00:00
Jiyong Park
5b16ccb36e Enhance documentation about SetMmapRndBitsAction
Bug: N/A
Test: N/A
Change-Id: I0408158d181ef08831a55e1381477f5b128a5c52
2022-07-19 10:47:47 +09:00
Jooyung Han
6bfcefca0a Merge "Update linker configuration when loading apex" am: 11e757c9cc
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2155096

Change-Id: Ife9943c015595c8d1381716fede99ad0fce2fab1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-18 23:59:47 +00:00
Jooyung Han
11e757c9cc Merge "Update linker configuration when loading apex" 2022-07-18 23:39:56 +00:00
Yi-yo Chiang
c3e43e63fe Merge "first_stage_mount: Bind mount /system after switch root" am: 53f1fab6ac
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2146960

Change-Id: I6f8029284650238dcca3727cb9be81d486a9d314
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-18 10:08:01 +00:00
Yi-yo Chiang
53f1fab6ac Merge "first_stage_mount: Bind mount /system after switch root" 2022-07-18 09:47:56 +00:00
Jooyung Han
626be07153 Update linker configuration when loading apex
On ctl.apex_load <apex_name> control message, init invokes linkerconfig
to update linker configuration for the updated apex.

Bug: 232173613
Test: CtsInitTestCases
Test: VendorApexHostTestCases
Change-Id: I01d975849c3f4efe74205a7b04ebbd6864ba1121
2022-07-18 17:45:15 +09:00
Treehugger Robot
f8415fdc19 Merge "first_stage_mount: Fix log typo "check_at_most_once"" am: 4bc5277152
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2146961

Change-Id: Id41980ebd8e4ec7353def81828f0138374858a49
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-18 06:18:51 +00:00
Jiyong Park
11d7bc52df init: don't touch mmap_rnd_compat_bits on 64-bit only builds
mmap_rnd_compat_bits is for address space randomization of 32-bit
applications on 64-bit system. Configuring it is not only unnecessary
for 64-bit "only" builds, but also can cause a boot failure if the
kernel is built without CONFIG_COMPAT which is the case for Microdroid.

Use ro.product.abilist32 to determine whether 32-bit applications are
supported and if not, don't configure it, but mmap_rnd_bits.

Bug: 237950549
Test: run Microdroid with the kernel built with aosp/2153639

Change-Id: Ifca6fa02f14ad4c7d8f9b2ab8852494c12945c3a
2022-07-18 14:31:13 +09:00
Yi-Yo Chiang
a3832d496b first_stage_mount: Fix log typo "check_at_most_once"
Was "check_most_at_once", should be "check_at_most_once".
Also straighten the if-then-else logic from:
  if (cond) {
    // then
  } else {
    // error...
    return;
  }
to:
  if (!cond) {
    // error...
    return;
  }
  // fallthrough is "then"

Test: Presubmit
Change-Id: I85c1e94c47a727089374d5d05ecd40f4187b66a1
2022-07-18 04:38:02 +00:00
Jooyung Han
db126b9a4e Merge "Return Result<T> from Do(Un)LoadApex()" am: 46fa45d82c
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2155095

Change-Id: Ib73a4ed9cfb73ebd26cd03d2c3119aab5f17c5e2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-16 03:19:31 +00:00
Jooyung Han
a2fe3e577e Return Result<T> from Do(Un)LoadApex()
For consistent error message. This is a preparation step for the
follow-up change: to generate linker configuration in DoLoadApex()

Bug: 232173613
Test: CtsInitTestCases
Change-Id: I27954ae2429e82da1bde1925ef62b277c24129d3
2022-07-16 08:37:06 +09:00
Jooyung Han
000b85449c Merge "init starts servicemanagers in "default" mount ns" am: e89c457157
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2153354

Change-Id: I9fcb98938403626697ea5b515e1f5d2c82fbefd8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-15 00:34:25 +00:00
Jooyung Han
c5fa15e08c init starts servicemanagers in "default" mount ns
servicemanager/hwservicemanager are pre-apexd services but still wants
to see VINTF fragments from APEXes, especially from /data.

Like ueventd, these services need to be started in "default" mount
namespace.

Bug: 237672865
Test: m && boot
Change-Id: I0266c5be5530a1a07f8ffa23a26186d45a55613f
2022-07-14 18:31:21 +09:00
Treehugger Robot
e03286ac40 Merge "Add ctl.apex_(un)load properties to (un)load apex" am: e271146ec8
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2146970

Change-Id: I26a3865aaaae2ded31c84e701a0a6fe3592b65a1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-13 04:20:59 +00:00
Treehugger Robot
e271146ec8 Merge "Add ctl.apex_(un)load properties to (un)load apex" 2022-07-13 04:04:20 +00:00
Treehugger Robot
592de2a382 Merge "Don't kill subcontext if it's null" am: 932e069f0f
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2146830

Change-Id: Ib839545df89ff9b6c6b554d7429c2f6e602a32f3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-11 07:17:30 +00:00
Inseob Kim
5caaa5575e Don't kill subcontext if it's null
We don't initialize subcontext in microdroid. subcontext->pid() will
crash in such case.

Test: atest MicrodroidTests
Change-Id: Ifca65acededbf7f113d8bf16afbb8e2c1aa91b41
2022-07-11 14:34:15 +09:00
Jooyung Han
678f0b4828 Add ctl.apex_(un)load properties to (un)load apex
These props are supposed to be used by apexd when installing an apex
without reboot. During the installation, apexd will unmount the current
one and mount the new one. Since the path and its contents will be
replaced, anything loaded from the apex should be unloaded before
unmounting. After apexd mounts the apex again, then init should re-read
.rc files from the apex.

This change only addes required properties:
- ctl.apex_load <apex_name>
- ctl.apex_unload <apex_name>
- init.apex.<apex_name> = loaded | unloaded

Bug: 232114573
Bug: 232173613
Test: atest CtsInitTestCases
Change-Id: I4a8942d67912e2f11acc51bec756c4e3c218179a
2022-07-07 15:58:33 +09:00
Yi-Yo Chiang
d7e6353a69 first_stage_mount: Bind mount /system after switch root
This ensures /system to be a mountpoint, which allows adb-remount to
change the subtree propagation type of /system and MS_MOVE submounts
under /system.

Test: Add submount under /system and adb remount
Change-Id: Ib281be41eaf86bc3e6b7dfac893e5e27b8374da8
2022-07-06 21:51:35 +08:00
Treehugger Robot
0aa01859e6 Merge "Add lz4 support for VABC" am: 3854a69d39
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2061511

Change-Id: I5e15a317788ea6eba843b2c3c6770d549ea7db48
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-30 00:42:20 +00:00
Kelvin Zhang
5cb1b0295e Add lz4 support for VABC
Add lz4 support in CowWriter/CowReader. Lz4 should offer faster
read/write performance but slightly larger COW sizes.

Download time: Reduced from 1264s to 825s (~35% faster)
Filesystem verification time: from 69s to 59s (~15% faster)
COW Size: 2.59GB to 3.21GB, (~25% regression)
Merge time: 37046ms to 27690ms (~25% faster)
Boot time: LZ4 is 2.7% faster

Overall, LZ4 offers faster read/write performance at the cost of 25%
space regression.

Test: th
Bug: 228478555
Change-Id: Ie521852fb3c9ff8a12e55b764c1eb1838f7b2181
2022-06-29 13:10:55 -07:00
Xin Li
ebe6598a1c Merge tm-dev-plus-aosp-without-vendor@8763363
Bug: 236760014
Merged-In: Ia927c19f544536f78c20ccef5830bd1be0cebf9b
Change-Id: I0267b9eaad470a56db68f3a0b99abfc41192c6d7
2022-06-28 21:23:43 +00:00
Yi-Yo Chiang
01a7dcb240 first_stage_init: Optimize redundant vector copy
```
std::vector<std::string> v2;
for (auto&& e : get_temporary_v1()) { v2.push_back(e); }
```
^^^ This is constructing v2 from a temporary object, which is an
unnecessary manual clone. We should just let copy-elision do its thing:

```
// Give compiler the chance to optimize this with copy-elision...
auto v2 = get_temporary_v1();
```

Also `lp_names` appends an extra ',' at its end. Just use
android::base::Join() here.

Bug: 235111004
Test: Presubmit GSI boot test
Change-Id: Ibe8ce7a29b8521e789aa0a99f7f6d31f3f9c70e9
2022-06-27 16:19:37 +00:00
Eric Biggers
1179b02637 Merge "Rename fscrypt_is_native() to IsFbeEnabled()" am: e5a9a70437 am: 3d3a52a7d4
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2127464

Change-Id: I192f917501e5c04aa9ea80168a20ed688edd2116
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-22 19:07:49 +00:00
Eric Biggers
e5a9a70437 Merge "Rename fscrypt_is_native() to IsFbeEnabled()" 2022-06-22 18:24:38 +00:00
Treehugger Robot
de80927e34 Merge "Promote HWASan tests to presubmit." am: 8874ad6378 am: 5efde0b299
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2130634

Change-Id: I4f6f55c73906c4a41a3fbca444674d169cdd1795
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-21 18:09:49 +00:00
Florian Mayer
4effd2f901 Promote HWASan tests to presubmit.
They have been passing and do not show significant slowdown.

Change-Id: I3eba6ecb746160d75e9a2c9561bceb71a09117d3
2022-06-17 22:29:09 +00:00
Eric Biggers
893b1ae313 Rename fscrypt_is_native() to IsFbeEnabled()
Now that emulated FBE is no longer supported, there is no longer any
distinction between native FBE and emulated FBE.  There is just FBE.

Referring to FBE as "fscrypt" is also poor practice, as fscrypt (the
Linux kernel support for filesystem-level encryption) is just one part
of FBE, the Android feature.

Therefore, rename fscrypt_is_native() to IsFbeEnabled().

Bug: 232458753
Change-Id: Ib4dcdf799833b91d326b4b6f7120b0a3d4f4fc31
2022-06-15 18:52:39 +00:00
Suchang Woo
7d8c25b0c9 ueventd: Wait for runtime apex before running external firmware handler
External firmware handlers cannot run until com.android.runtime.apex is
activated. However, it may be possible to request firmware from the
kernel before apex activation. Waiting for runtime apex is required
before running an external firmware handler.

Test: atest CtsInitTestCases
Change-Id: Id63b7f29084d3cecb901049162d3e5cd0055566f
Signed-off-by: Suchang Woo <suchang.woo@samsung.com>
2022-06-15 17:11:24 +09:00
Treehugger Robot
42ffffd8a1 Merge "Chmod for existing nodes which mode not the same as ueventd.rc" am: a50d431830 am: 79c6750b85
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2063313

Change-Id: Ie057274f2586cb6d2dcbe0a7e5a04d70764c0c70
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-14 17:06:39 +00:00
Treehugger Robot
a50d431830 Merge "Chmod for existing nodes which mode not the same as ueventd.rc" 2022-06-14 14:14:15 +00:00
Yi-yo Chiang
df05b6d488 Merge "Auto enable usb adb if booting with debug ramdisk" am: 155bba8b0c am: 0d9240f898
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2119852

Change-Id: I4bf912c06184106b9effda1e9259ab26362a93c5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-10 13:05:27 +00:00
Yi-Yo Chiang
70c53f5d52 Auto enable usb adb if booting with debug ramdisk
If booting with debug ramdisk (ro.force.debuggable is true), override
the persistent property "persist.sys.usb.config" to always enable adb.
This ensures a consistent debug experience. The developer can expect
that after debug ramdisk (debug boot image) is flashed,
1. Device is rootable with (adb root)
2. adb is enabled automatically
3. no-auth (if $ADB_VENDOR_KEYS is used)

Bug: 223517900
Test: 1. Flash & boot user build, verify device doesn't have usb
  debugging enabled.
  2. Reboot to bootloader and flash vendor_boot-debug.img.
  3. Boot and verify usb debugging is automatically enabled.
  4. Enter Developer Options and manually turn off usb debugging.
  5. Reboot and verify that usb debugging is automatically enabled.
Change-Id: I729e961d645f2dd521ead8ca30b5cb8eb1d9f909
2022-06-08 23:07:13 +08:00
Kean Mariotti
7772fc84f5 Merge "Revert "Set the log callback earlier for showing system property set denials"" am: 526fbe2a37 am: c0e0892a5a
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2118487

Change-Id: I351a3a385c5d1be27258343db342910c5ec0291f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-08 09:50:51 +00:00
Kean Mariotti
526fbe2a37 Merge "Revert "Set the log callback earlier for showing system property set denials"" 2022-06-08 09:07:42 +00:00
Kean Mariotti
3a6040eb71 Revert "Set the log callback earlier for showing system property set denials"
This reverts commit 8c224faa24.

Reason for revert: 235312897

Change-Id: I80684c80bb6f97853449d429bbf948c07d4cb651
2022-06-08 07:57:53 +00:00
Alex Hong
c0b9b5f2d3 Merge "Set the log callback earlier for showing system property set denials" am: af74368a36 am: 219306f683
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1684665

Change-Id: Ic880afd4b9393b6d5e0516c914d00c5ec27de55c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-08 06:11:38 +00:00
Alex Hong
af74368a36 Merge "Set the log callback earlier for showing system property set denials" 2022-06-08 05:37:22 +00:00
Treehugger Robot
c6e1bb2b8c Merge "Added libinit_headers to Android.bp" am: ac9b59ed5a am: e8ee78b0db
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1985237

Change-Id: I3d4364cb1f4ac8a3186ea862cb8a0f317f569059
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-03 09:42:33 +00:00
Treehugger Robot
ac9b59ed5a Merge "Added libinit_headers to Android.bp" 2022-06-03 08:57:08 +00:00
Akilesh Kailash
6e01fe9537 Merge "init: Set oom_score_adj to snapuserd process" am: cb3ef68f22 am: 1aae2b57f6
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2114498

Change-Id: I4b2186888dff2daef99b9fa356802b60906c13fc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-02 21:59:38 +00:00
Akilesh Kailash
4ffe8a3109 init: Set oom_score_adj to snapuserd process
When a process is started as a native service,
oom_score_adj is set to -1000 so that processes
are unkillable by lmkd.

During boot, snapuserd process is not started as a service;
hence, we need to set the oom_score_adj explicitly else in
the event of low memory situation, lmkd can kill the
process thereby device can never boot.

Bug: 234691483
Test: th and OTA on Pixel
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: Ic2c85aa470522b4bc847a16b4f5cebfc528ed3cf
2022-06-02 20:49:03 +00:00
Thiébaud Weksteen
ddbc4fdad1 Merge "Add documentation on mkdir about seclabel" am: 715ecbfb23 am: 46e8d29a4f
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2110586

Change-Id: I2ff96f2a0dece853749315e1b3dcceadc5d34f75
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-01 00:02:16 +00:00