Commit graph

2862 commits

Author SHA1 Message Date
Tom Cherry
7896e7adcc init: add exec_reboot_on_failure builtin
Add exec_reboot_on_failure builtin and refactor the VDC commands that
had similar functionality.  These will now also reboot in the case
that the program cannot be found or run for any reason.

Test: boots normally, reboots if command is not found or if command
      returns status '1'

Change-Id: I1c99498c2b741512a50188e1a325c25e9ec8fba0
2019-09-04 16:23:15 -07:00
Tom Cherry
0589aa4265 Merge "init: Always reap processes before handling properties" 2019-09-03 16:35:27 +00:00
Martin Stjernholm
0c100685dc Merge changes from topic "art-without-bionic"
* changes:
  Include com.android.runtime in the "runtime" linker namespace.
  Update logic for detecting pre-apexd services to check that the ART APEX is mounted.
  Update paths and names for the new ART APEX.
2019-09-02 10:28:30 +00:00
Treehugger Robot
dec467f271 Merge "Fix typo" 2019-08-31 13:39:37 +00:00
Tom Cherry
905a5df83d init: Always reap processes before handling properties
There is a race that manifests like this:

1) A service dies (not processed by init yet).
2) service_manager processes death notification.
3) service_manager gets checkService and calls init to start service.
4) init gets the ctl.start / ctl.interface_start for the service
   but the service already appears started, so it does nothing.
5) init gets sigchld, but doesn't do anything else to restart the
   service

We can avoid all of this if we already reap pending processes before
handling properties in the main loop of init.  Since reaping the
services calls waitid(), there's no race even if the signalfd for
sigchld hasn't triggered yet.  It also won't cost us much efficiency,
since it's only a single system call.

Test: CF boots, init unit tests pass
Change-Id: Ie24ef406055b283797b41b1821c8ebcccead4db4
2019-08-30 14:20:05 -07:00
Paul Lawrence
b2c2d6907f Fix typo
Test: builds
Change-Id: I4b48e8b3d457382579216482249e734f74768c71
2019-08-30 11:15:58 -07:00
Martin Stjernholm
cacf04351f Update logic for detecting pre-apexd services to check that the ART APEX is
mounted.

Necessary to make e.g. bootanimation work, which depends on (at least)
libandroidicu.so in the ART APEX.

Test: Build & boot
Bug: 135753770
Exempt-From-Owner-Approval: Approved internally
Change-Id: Ibab4f5f7a243d0815b9c70a537bae8d77dee2fbb
Merged-In: Ibab4f5f7a243d0815b9c70a537bae8d77dee2fbb
2019-08-30 17:47:31 +01:00
Martin Stjernholm
df96e1f25c Update paths and names for the new ART APEX.
Test: Build & boot
Test: atest CtsJniTestCases
Bug: 135753770
Exempt-From-Owner-Approval: Approved internally
Change-Id: Ic59b7bc8aae7ce521cf3ec9df4ab72aa611d0b75
Merged-In: Ic59b7bc8aae7ce521cf3ec9df4ab72aa611d0b75
2019-08-30 17:47:31 +01:00
Steven Moreland
9800ad839a init: -1 log for control message error paths.
Fixes: 140136969
Test: check logs
Change-Id: Id80f59927b44d1026c6e3389c80ca96baf0733c4
2019-08-29 16:08:36 +00:00
Tom Cherry
4adbd2905a Merge "Revert "Reland: "init: run property service in a thread""" 2019-08-28 17:50:00 +00:00
Tom Cherry
3da2ba6d4a Revert "Reland: "init: run property service in a thread""
This reverts commit 8efca4bbb3.

Reason for revert: Still broken

Change-Id: I3b37b1b00ff4b19f2eec2d8bd72042463d47cee3
2019-08-28 17:47:49 +00:00
Treehugger Robot
88bba95989 Merge "init: set SetKptrRestrict before early-init" 2019-08-28 17:44:55 +00:00
Tom Cherry
34f2537393 Merge "Reland: "init: run property service in a thread"" 2019-08-28 15:01:34 +00:00
Tom Cherry
15c8760403 Merge "ueventd: parallelize restorecon /sys" 2019-08-28 14:58:12 +00:00
Ravi Kumar Siddojigari
33783fc29c init: set SetKptrRestrict before early-init
As part of debugging long run issue we are enabling
module info as part of debug build under the config key
DEBUG_MODULE_LOAD_INFO , But doing so can lead to info leak
as modules/dlkm are loaded in early-init and setting the
kptr_restriction is done after early-init.

So moving setting of kptr_restrict much before early-init.

Bug: 138641073

Change-Id: Ic3c0ca57a94c8b20136a15331dd646bd8825b625
2019-08-28 14:28:08 +02:00
Josh Gao
b245609059 Merge "Mark some tests as requiring root." 2019-08-28 02:40:03 +00:00
Bongkyu Kim
5aa6197d5f ueventd: parallelize restorecon /sys
generate subdir for /sys and /sys/devices, handle restorecon in parallel.

This reduces coldboot time on our target about 300ms.

Change-Id: I9c3d0e97aacff0ca127880d936dfd5fcc2aee125
2019-08-28 09:55:09 +09:00
Tom Cherry
a5c2aed35f Merge "init: send property_set failures to the audit netlink socket" 2019-08-27 23:23:00 +00:00
Josh Gao
6cad139bcc Mark some tests as requiring root.
Bug: http://b/140123924
Test: mma
Change-Id: I3ad277179018631c50d9295cdb173dd9dfa7ac59
2019-08-27 16:09:32 -07:00
Paul Crowley
309d6dde31 Merge changes I1c1445ba,Ic0c8b163
* changes:
  Straighten out do_mkdir
  Convert fscrypt_set_directory_policy to C++
2019-08-27 02:26:25 +00:00
Yifan Hong
8d168c3321 Merge "init: Add first-stage init support for snapshot-based partitions." 2019-08-27 01:56:41 +00:00
Tom Cherry
8efca4bbb3 Reland: "init: run property service in a thread"
It's been a long standing issue that init cannot respond to property
set messages when it is running a builtin command.  This is
particularly problematic when the commands involve IPC to vold or
other daemons, as it prevents them from being able to set properties.

This change has init run property service in a thread, which
eliminates the above issue.

This change may also serve as a starting block to running property
service in an entirely different process to better isolate init from
handling property requests.

Test: CF boots, walleye boots, properties are set appropriately
Change-Id: I13b8bf240c9fcb1d2d5890a8be2f0ef74efd4adf
2019-08-26 17:08:41 -07:00
Treehugger Robot
e3cd3badbd Merge "Move fscrypt_init_extensions into system/core" 2019-08-26 23:24:54 +00:00
Tom Cherry
8180b48c4c init: send property_set failures to the audit netlink socket
Bug: 139816248
Test: see audit messages for failed property set during property file
      reading

Change-Id: I2b6a0448aa4cb494e924070928b0fd0eb5d5c998
2019-08-26 14:53:18 -07:00
Tom Cherry
eb94026231 Merge "Revert "init: run property service in a thread"" 2019-08-26 19:47:02 +00:00
Paul Crowley
1b4e7328ad Straighten out do_mkdir
Use lstat(), and then make only the system calls needed to fix the
directory up.

Bug: 140027478
Test: boots twice, no worrying log messages.
Change-Id: I1c1445baae3ec1c1ce17626ede388aa04d5f7781
2019-08-26 12:06:59 -07:00
Paul Crowley
285e5d6d08 Convert fscrypt_set_directory_policy to C++
Bug: 140027478
Test: compiles, boots
Change-Id: Ic0c8b163fe37b11787cab49cc2eea38a1de377e9
2019-08-26 11:55:36 -07:00
Paul Crowley
052f31c678 Move fscrypt_init_extensions into system/core
Bug: 140027478
Test: treehugger
Change-Id: I9f8b76a501be0b261b6fdd1da98447601e0fd32b
2019-08-26 10:33:17 -07:00
Tom Cherry
f451426205 Revert "init: run property service in a thread"
This reverts commit 26f5e7da3a.

Reason for revert: bluecross boot stability issue

Bug: 140009641
Change-Id: I7ddb9509dfb2c6f644037129aa9d3fb9ff1740aa
2019-08-26 16:33:40 +00:00
Tom Cherry
88eedafbe1 Merge "Add init_tests to CTS" 2019-08-22 22:53:56 +00:00
David Anderson
c5b3c88f8a Merge "liblp: Support sdcards in PartitionOpener." 2019-08-22 19:12:40 +00:00
Tom Cherry
afe45ab5f2 Merge changes Id9534a59,I3ee81536
* changes:
  init: run property service in a thread
  Revert "init: Handle properties in the background of calling fs_mgr"
2019-08-22 17:24:18 +00:00
Tom Cherry
17b2be05a2 Add init_tests to CTS
Test: atest CtsInitTestCases
Test: Cts in presubmit still passes
Change-Id: Ic16dafbaacfbace904947bd3ce2b8586f981348f
2019-08-22 08:37:55 -07:00
David Anderson
c8edf84d45 init: Add first-stage init support for snapshot-based partitions.
Note that /metadata must now be mounted before CreateLogicalPartitions()
is called. This is because SnapshotManager overrides the default
partitioning scheme, and the only way to tell if a SnapshotManager is
needed is via the metadata partition.

Bug: 139204329
Test: manual test
Change-Id: I812df6c4c0d4d8753b1516f63dc70c5bc3e1c09c
2019-08-21 12:27:56 -07:00
David Anderson
251ec05f01 liblp: Support sdcards in PartitionOpener.
Before ImageManager was introduced, gsid avoided using PartitionOpener
when writing to external media. PartitionOpener couldn't interact with
non-boot devices, because it prepends /dev/block/by-name. We hacked
around this in both gsid and in first-stage init, which manually detects
the problem and prepends /dev/block instead.

After the ImageManager refactoring, sdcard support broke in gsid,
because it started relying on PartitionOpener. Let's fix this by allowing
/dev/block for mmcblk* names in PartitionOpener.

Bug: 139204329
Test: fiemap_image_test gtest
Change-Id: Ic1cbdbe0a18fc09522ee38cc62b35fd8193ce250
2019-08-21 12:27:56 -07:00
Tom Cherry
26f5e7da3a init: run property service in a thread
It's been a long standing issue that init cannot respond to property
set messages when it is running a builtin command.  This is
particularly problematic when the commands involve IPC to vold or
other daemons, as it prevents them from being able to set properties.

This change has init run property service in a thread, which
eliminates the above issue.

This change may also serve as a starting block to running property
service in an entirely different process to better isolate init from
handling property requests.

Test: CF boots, walleye boots, properties are set appropriately
Change-Id: Id9534a5916abb2f7d2a49cda54e33c1b69c50c2f
2019-08-21 08:26:09 -07:00
Yi Kong
0f6537c437 Fix ODR violation
host_init_verifier statically links libprocessgroup, which has shared
dependency on libjsoncpp. Right now it also has shared dependency on
libjsoncpp, resulting in ODR violation:

 ERROR: AddressSanitizer: odr-violation (0x7fce895f3220):
 [1] size=8 'Json::kNullRef' external/jsoncpp/src/lib_json/json_value.cpp:37:22
 [2] size=8 'Json::kNullRef' external/jsoncpp/src/lib_json/json_value.cpp:37:22
 These globals were registered at these points:
 [1]:
 #0 0x56276926ef0d (/usr/local/google/buildbot/src/android/master/out/host/linux-x86/bin/host_init_verifier+0xd1f0d)
 #1 0x7fce894ac1d9 (/lib64/ld-linux-x86-64.so.2+0x101d9)

 [2]:
 #0 0x56276926ef0d (/usr/local/google/buildbot/src/android/master/out/host/linux-x86/bin/host_init_verifier+0xd1f0d)
 #1 0x7fce894ac1d9 (/lib64/ld-linux-x86-64.so.2+0x101d9)

Move host_init_verifier to libjsoncpp_headers to fix the ODR violation.

Bug: 139546461
Bug: 131328001
Test: Run ASAN host_init_verifier
Change-Id: I54a51138d61fff37f092ffaa0758817600a0af9d
2019-08-18 17:57:35 -07:00
Tom Cherry
3707d328a1 Revert "init: Handle properties in the background of calling fs_mgr"
This reverts commit 71bdf2820e.
Test: boot
2019-08-15 13:07:24 -07:00
Tom Cherry
53620ca1b1 Merge "Actually add README contents for ueventd" 2019-08-13 14:48:04 +00:00
Treehugger Robot
b85c72caed Merge "init: first stage init tie stdout and stderr to /dev/kmsg" 2019-08-13 12:48:40 +00:00
Tom Cherry
aefb141c67 Actually add README contents for ueventd
A long time coming

Test: n/a
Change-Id: I6050e74d7497d5a7760f615fe2ad7d5c78a66ab9
2019-08-12 13:13:57 -07:00
Tom Cherry
6fd8d3bb1b init: Allow matching empty property values
When we have a property match along with an event trigger, we
currently don't allow matching empty property values, in other words,
properties that are unset.  For example, the below trigger would never
be run:

on zygote-start && property:persist.sys.fuse=""

That doesn't make sense though, it should be possible to match an
empty property value, so this change allows that trigger to match when
persist.sys.fuse is either empty or not set.

This continues to not match a '*' to an empty property, so

on zygote-start && property:persist.sys.fuse=*

will not run if persist.sys.fuse is empty or unset.

Test: the above triggers run appropriately
Change-Id: Ia57de7b96ad352590d0c82ff4ae95060b7361976
2019-08-12 09:31:42 -07:00
Daniel Norman
0d061b258a Merge "Adds check_interface_{restart,start,stop} check_builtins." 2019-08-06 23:21:29 +00:00
Daniel Norman
d2533c3395 Adds check_interface_{restart,start,stop} check_builtins.
Includes refactoring out interface inheritance hierarchy logic to a new
interface_utils file.

Bug: 137397100
Test: 'm' with an init_rc that misspells an interface in an
interface_start, interface_restart, or interface_stop line.
Change-Id: I9f650289d64ae2b13435a81e1693c7ab5e6e9ecf
2019-08-06 11:10:42 -07:00
Tom Cherry
980cbef0c5 Merge "init: Check onrestart commands" 2019-08-06 15:20:11 +00:00
Tom Cherry
e269a721dc Merge "init: ignore ENOENT from fewer builtins" 2019-08-06 15:19:48 +00:00
Tom Cherry
6737a6bf3f init: Check onrestart commands
Test: have bad users/groups in onrestart chown commands fail the build
Change-Id: Ic7fea6395c1f6e09f06800ba373d402a81cb774c
2019-08-05 15:03:58 -07:00
Daniel Norman
a022e47a0b Merge "Fixes incorrect flag info for the inheritance hierarchy file." 2019-08-02 23:00:27 +00:00
Daniel Norman
e6586c4c8e Fixes incorrect flag info for the inheritance hierarchy file.
Test: n/a
Change-Id: I65d6437f4192d969932e01019826827c98a2669c
2019-08-02 15:22:13 -07:00
Daniel Norman
fb54b74fa0 Merge changes from topic "services_serve_interfaces_test"
* changes:
  Adds new property for service name -> PID.
  Adds a library to parse service info from init_rc files for use in tests.
  Adds a visibility rule for init defaults.
2019-08-02 21:51:17 +00:00