Commit graph

2546 commits

Author SHA1 Message Date
Treehugger Robot
82c88d9b00 Merge "ueventd: don't skip restorecon after the cold boot" 2018-11-02 22:57:27 +00:00
Oleksiy Avramchenko
dd5802a27e ueventd: don't skip restorecon after the cold boot
We need to do restorecon after the cold boot, otherwise the newly
created sysfs nodes won't be labelled.

Bug: 118861992
Test: manual - do insmod, check sysfs nodes are properly labelled
Change-Id: I4bdfb4a68206724a568d8cbb6c644ba8764b5fa7
2018-11-02 15:43:11 +00:00
Evgenii Stepanov
1f47f4add4 Do not hwasanitize init_first_stage.
Current hwasan implementation breaks when stderr (fd 2) is missing.

Bug: 118776698
Test: hwasan boots without serial console
Change-Id: Id095a87212096526a497563adab3d7f2f9fe8ab0
2018-11-01 13:43:50 -07:00
Peter Collingbourne
166ae693d4 Merge "Introduce additional service options for controlling memory cgroups." 2018-11-01 17:55:34 +00:00
Justin Yun
6bab0a9c23 Mount vendor overlay from the system partition
Using overlayfs, the system partition may provide files for older
version of vendor partitions by overlaying on the vendor partition.
Directories in /system/vendor_overlay will be overlaid on the
directories in /vendor to override existing files or provide new
files.

This feature works only if the kernel support overlayfs and has a
patch for override_creds. Otherwise, no-op.

Bug: 114679254
Test: Build and boot: nothing affected without overlayfs, or
                      vendor file is overrided with overlayfs

Change-Id: Iff3a308945299034123ba7bcb40dc787e102730e
2018-11-01 10:26:12 +09:00
Peter Collingbourne
d7157c22af Introduce additional service options for controlling memory cgroups.
The memcg.limit_percent option can be used to limit the cgroup's
max RSS to the given value as a percentage of the device's physical
memory. The memcg.limit_property option specifies the name of a
property that can be used to control the cgroup's max RSS. These
new options correspond to the arguments to the limitProcessMemory
function in frameworks/av/media/libmedia/MediaUtils.cpp; this will
allow us to add these options to the rc files for the programs that
call this function and then remove the callers in a later change.

There is also a change in semantics: the memcg.* options now have
an effect on all devices which support memory cgroups, not just
those with ro.config.low_ram or ro.config.per_app_memcg set to true.
This change also brings the semantics in line with the documentation,
so it looks like the previous semantics were unintentional.

Change-Id: I9495826de6e477b952e23866743b5fa600adcacb
Bug: 118642754
2018-10-31 17:09:59 -07:00
Eric Biggers
82c6ba74e2 Merge "init: use libfscrypt for file-based encryption setup" 2018-10-29 17:19:39 +00:00
Tom Cherry
668f70f6ef Merge "init: fix error messages when an invalid section header is found" 2018-10-26 22:31:52 +00:00
Tom Cherry
0166fd606d init: fix error messages when an invalid section header is found
If a section header such as 'on' or 'service' has an error with it,
the rest of the commands / options are currently reported as errors
since there is no valid parser object to parse them.  For example,

service !@#$%%^&*() /system/bin/false
    user root
    group blah
    blah blah

Generates:

init: /system/etc/init/bad.rc: 2: invalid service name '!@#$%%^&*()'
init: /system/etc/init/bad.rc: 3: Invalid section keyword found
init: /system/etc/init/bad.rc: 4: Invalid section keyword found
init: /system/etc/init/bad.rc: 5: Invalid section keyword found

This change suppresses the extraneous 'Invalid section keyword found'
messages.

Test: faulty error messages are suppressed.
Change-Id: Ieeb2d5b8b7eea33e191a88ce5a0d41701686943f
2018-10-26 12:33:52 -07:00
Tom Cherry
fa79ae87f1 init: allow vendor init to action on any vendor or odm property
Partial revert of "init: if vendor_init can read a property, let it be
a trigger too" (b35f827c97).

We made a mistake when we allowed vendor init to action on any vendor
or odm property, since when a new SELinux label is created for a
vendor property, vendor_init does not automatically get read
permissions for it.

Recently, we tried to use read permissions instead of the built-in
list in init, but that broke due to the above mistaken.  Since we have
already launched with these permissions as is, we must restore them.

Bug: 118457755
Test: no denials for vendor init actionable properties on crosshatch
Change-Id: I7a9a560c9a54a177c6b83d28309e2f288f05d400
2018-10-26 08:50:45 -07:00
Eric Biggers
f05da4a4be init: use libfscrypt for file-based encryption setup
The file-based encryption setup code is being refactored into its own
library because it applies to both ext4 and f2fs, not just ext4.  Update
init to use the new location.   For fs_mgr, just remove the include of
ext4_crypt_init_extensions.h since it was unneeded.

Test: built, booted device with f2fs encryption
Change-Id: I392a763e3349f001bdbc09eb9ca975aa3451fd68
2018-10-25 17:10:15 -07:00
Tom Cherry
b35f827c97 init: if vendor_init can read a property, let it be a trigger too
There is a list of 'stable_properties' that vendor_init can use as
property triggers for Treble property compliance.  This list came about
since init parses init scripts before all partitions are mounted and
therefore before all property context files are available, such that
init cannot use the normal SELinux mechanisms for determining if a
given property is vendor_init readable.

Currently though, we require all partitions that would contain
property context files to be mounted during first stage mount, so we
can use the normal SELinux mechanisms here, so this change deprecates
the stable_properties list and moves init to use SELinux to determine
if a property can be a trigger.

Bug: 71814576
Test: vendor_init fails to use non-readable properties as a trigger
Test: vendor_init successfully uses readable properties as a trigger
Change-Id: I6a914e8c212a3418cbf4a8a07215056aad2e0162
2018-10-22 16:16:03 -07:00
Tom Cherry
5083be5d72 Merge "init: Add some ASAN helpers" 2018-10-19 20:41:24 +00:00
Tom Cherry
e0042419f8 init: Add some ASAN helpers
Init is special.

It starts early and does not pick up the Android ASAN options provided
on the environment.  Therefore we pull in /system/asan.options in
explicitly if it exists.  We provide sane defaults that will allow the
system to boot otherwise.

Logging is complicated because it needs to go to the kernel log.
So use sanitizer functions to install log functions.

Bug: 117879229
Test: m && m SANITIZE_TARGET=address
Test: init boots with ASAN enabled
Change-Id: I72c033a1f86ba5d6b2e4f943e7a3acd0d399c8bf
2018-10-19 11:18:58 -07:00
Tom Cherry
7a08c896dd Merge changes Iea270320,Ib9063185
* changes:
  init: allow properties to be used for the keycodes option
  init: use rvalues references for callees of ParseLineSection()
2018-10-19 15:43:43 +00:00
Nick Kralevich
2991949001 Add O_CLOEXEC
Prevent an FD from accidentally leaking across an exec() boundary.

Test: code compiles.
Change-Id: I90ca6e332802700403f401db016cc6c0c72b0ea3
2018-10-18 16:09:40 -07:00
Tom Cherry
791668462a init: allow properties to be used for the keycodes option
Bug: 117828597
Test: bugreport launches with a test property set to appropriate keys
Test: bugreport doesn't launch with the test property unset
Test: no errors seen in build or boot in either of the above cases
Change-Id: Iea27032080a0a7863932b1c1b573857ac66b56b5
2018-10-17 11:30:53 -07:00
Tom Cherry
018a438ff0 init: use rvalues references for callees of ParseLineSection()
ParseLineSection() provides 'args' as an rvalue reference, so its
callers can and should use it as such.  This saves some copying
overhead and cleans up the code a bit.

Test: boot
Change-Id: Ib906318583dc81de9ea585f5f09fdff35403be1b
2018-10-17 11:30:53 -07:00
Tom Cherry
89bf115a70 Merge "init: separate init packaging for mainline" 2018-10-16 20:29:47 +00:00
Tom Cherry
29e5348f18 init: separate init packaging for mainline
With system-as-root, both first and second stage init belong to
system, but without system-as-root, first stage belongs to vendor and
second stage belongs to system.  This change creates two phony
packages to achieve this correctly in the build system.

Bug: 117606184
Test: mainline builds work properly
Change-Id: I19263e76c217c2e70bc06c180be3a460e9144f18
2018-10-16 09:49:00 -07:00
Tom Cherry
ad9e7eaf2d init: clarify some text/README about 'critical' services
'Critical' services have rebooted into bootloader, like all other
catastrophic init crashes, for years now.  Update the text to match.

Test: n/a
Change-Id: Icfc41bf3e383958f14ecfaab9ca187e2c3dc7fd9
2018-10-15 17:21:48 -07:00
Steven Moreland
48aed8f02d init: clarify multiple 'interface' keyword use
This keyword can (and should) be used multiple times when multiple
services are served together. I've documented this here.

Bug: N/A
Test: N/A
Change-Id: Ie986c9cac486db346555f359e9ccbed93d8d1d22
2018-10-15 18:00:36 +00:00
Minchan Kim
d37dd4a6f0 Merge "export dumpstatez into stable_properties" 2018-10-12 07:23:23 +00:00
Tom Cherry
4c67290da6 Merge "init: add [[nodiscard]] to Result" 2018-10-11 20:34:04 +00:00
Tom Cherry
d987264625 init: add [[nodiscard]] to Result
It's better to either check these results or explicitly ignore them.
Only a few callers weren't already doing this, so it's relatively
trivial to enforce.

Test: build
Change-Id: I44cdc342e46128f66cac914aaa0b9b4559cacd8c
2018-10-11 10:39:33 -07:00
Minchan Kim
b7f6c5a1cd export dumpstatez into stable_properties
Vendor might want to pause/resume some operations while a bugreport is captured
so that we need to export dumpstatez into stable_properties.h for vendor to get
property event when dumpstatez launch.

Test: confirmed manually with "adb bugreport"
Bug: 117536084
Change-Id: Ib743c5e59ca20cc44470110c814d85e4cbb90c0c
Signed-off-by: Minchan Kim <minchan@google.com>
2018-10-11 18:02:58 +09:00
Wei Wang
b5de088262 init: increase thermal shutdown timeout to 3s
1) increase thermal shutdown timeout to 3s for process to save work
2) respect property "ro.build.shutdown_timeout" in thermal shutdown if
   it is set less than default time - "3s"

Bug: 112432890
Test: Build
Change-Id: Idc2b24dd44c1fab8f9b047fd2468de2ee45ff783
2018-10-09 12:53:30 -07:00
Tom Cherry
64990d5b45 Merge "init: move InitKernelLogging() to first stage init" 2018-10-05 20:41:23 +00:00
Tom Cherry
48e83e629f init: move InitKernelLogging() to first stage init
The kernel opens /dev/console and uses that fd for stdin/stdout/stderr
if there is a serial console enabled and no initramfs, otherwise it
does not provide any fds for stdin/stdout/stderr.  InitKernelLogging()
is used to close these existing fds if they exist and replace them
with /dev/null.

Currently, InitKernelLogging() is only called in second stage init,
which means that processes exec'ed from first stage init will inherit
the kernel provided fds if any are provided.

In the case that they are provided, the exec of second stage init
causes an SELinux denial as it does not have access to /dev/console.
In the case that they are not provided, exec of any further process is
potentially dangerous as the first fd's opened by that process will
take the stdin/stdout/stderr fileno's, which can cause issues if
printf(), etc is then used by that process.

Lastly, simply moving InitKernelLogging() to first stage init is not
enough, since first stage init still runs in kernel context and future
child processes will not have permissions to access kernel context
resources.  Therefore, it must be done for a second time in second
stage init.

Bug: 117281017
Test: no audits when booting marlin.
Change-Id: If27edab5c32b27765e24c32fbed506ef625889de
2018-10-05 10:36:38 -07:00
Chih-Hung Hsieh
747eb149d0 Add noexcept to move constructors and assignment operators.
Bug: 116614593
Test: build with WITH_TIDY=1
Change-Id: I5a7461386946ca623ab509609092aa0ac8418b80
2018-10-05 16:43:47 +00:00
Tom Cherry
5f2a21d244 Merge "init: allow customizable restart and timeout periods for services" 2018-10-05 16:15:23 +00:00
Tom Cherry
73f535e33b init: allow customizable restart and timeout periods for services
Allow services to specify a custom restart period via the
restart_period service option.  This will allow services to be run
periodically, such as a service that needs to run every hour.

Allow services to specify a timeout period via the timeout_period
service option.  This will allow services to be killed after the
timeout expires if they are still running.  This can be combined with
restart_period for creating period services.

Test: test app restarts every minute
Change-Id: Iad017820f9a602f9826104fb8cafc91bfb4b28d6
2018-10-04 19:52:37 -07:00
Mark Salyzyn
e511e3a3b1 fs_mgr: Add fs_mgr_overlayfs_required_devices()
Added fs_mgr_overlayfs_required_devices() as hint to init to make sure
the device gets created before fs_mgr_overlayfs_mount_all().

Test: manual
Bug: 109821005
Change-Id: Iab038f3e0252a357b082bb08db3679512b9badec
2018-10-04 15:15:02 -07:00
Treehugger Robot
02678f32be Merge "Don't hardcode the super partition name." 2018-10-04 19:29:34 +00:00
Treehugger Robot
29e9833e39 Merge "fs_mgr/init: use unique_ptr + CLO_EXEC for setmntent()/fopen()" 2018-10-03 21:22:50 +00:00
Tom Cherry
f274e78eeb fs_mgr/init: use unique_ptr + CLO_EXEC for setmntent()/fopen()
We ran into an issue with an fd leaking due to missing both CLO_EXEC
and fclose() in related code, so let's make sure we're safe here too.

Test: boot
Change-Id: Ief893c936859815c78fa6d7e06cb88ad34aadbac
2018-10-03 13:19:04 -07:00
Treehugger Robot
8bd7d5238f Merge "init: IsDmLinearEnabled() replace with check if logical partitions present in fstab" 2018-10-03 20:03:26 +00:00
Tom Cherry
32638a1ef6 Merge "init: clarify why we mount /mnt/... in first stage init" 2018-10-02 21:55:08 +00:00
Tom Cherry
21824dddeb init: clarify why we mount /mnt/... in first stage init
Test: n/a
Change-Id: I55974fb285c55756536d038f4e20cb45d11906ee
2018-10-02 10:21:03 -07:00
David Anderson
5cbd2e43ee Don't hardcode the super partition name.
If a device has logical partitions but does not use a partition called
"super", we will need this to be configurable. Note that the "slot"
argument is currently unused, but will be necessary for update_engine if
there are A and B super partitions.

Bug: 116608795
Test: super partition works
Change-Id: Ieb548a158faeb423f3561230f26d582325efbc6b
2018-10-01 14:13:22 -07:00
Tom Cherry
e3745bc57a Merge "init: use '/system' as the system mount point for force_normal_boot" 2018-09-27 00:35:22 +00:00
Mark Salyzyn
9b1e7a34b9 init: IsDmLinearEnabled() replace with check if logical partitions present in fstab
IsDmLinearEnabled() true if logical partitions present in fstab.

Test: boot on logical device
Bug: 109821005
Change-Id: Ic083b0b8d9f7e9511d78bdc05c9f848521f1feb5
2018-09-26 21:04:24 +00:00
Tom Cherry
c382957789 init: use '/system' as the system mount point for force_normal_boot
We need to keep the right mount points in the fstab for other
processes to access (/ for system-as-root or /system otherwise).
Force_normal_boot devices are defacto not system-as-root,
since they're booting through the recovery ramdisk and therefore must
use /system as the system mount point.

Bug: 114062208
Test: boot pixel from recovery with force_normal_boot
Change-Id: Ib0e4e4f8a29299ecdcd35e8f1415551c4c9745ad
2018-09-26 13:27:16 -07:00
Treehugger Robot
5952034c25 Merge "Set device lock status from kernel command line." 2018-09-26 02:02:13 +00:00
Hridya Valsaraju
5ed32780b4 Set device lock status from kernel command line.
Device is considered to be unlocked if
androidboot.verifiedbootstate is "orange".

Test: adb shell getprop ro.boot.flash.locked

Change-Id: Id3aeec757908ea63a37e28ad880a6c71d53083ac
2018-09-25 15:49:59 -07:00
Treehugger Robot
37d8bbdf9c Merge "fs_mgr: init: adb: add fstab argument to fs_mgr_overlayfs_mount_all" 2018-09-25 20:37:15 +00:00
Treehugger Robot
6544056d54 Merge "Support 'adb reboot fastboot' command conditionally." 2018-09-25 17:17:08 +00:00
Mark Salyzyn
f35db9b11b fs_mgr: init: adb: add fstab argument to fs_mgr_overlayfs_mount_all
Add an fstab argument for fs_mgr_overlayfs_mount_all so that it can
leverage the locally and timely acquired fstab entries.  Affects all
callers, adb and init.

Test: manual
Bug: 109821005
Bug: 115751838
Change-Id: I96e2045d88525a6ce39bef63327a0fcf0704e9bc
2018-09-25 07:30:55 -07:00
Hridya Valsaraju
542582689d Support 'adb reboot fastboot' command conditionally.
Devices not supporting logical partitions do not require the command.

Bug: 78793464
Test: 'adb reboot fastboot' reboots to bootloader for a device
not supporting logical partitions.

Change-Id: I0a7b6d4335040e24efbf461e2dd2d56ab1985b7f
2018-09-25 03:52:12 +00:00
Treehugger Robot
f86e85cb0a Merge "init: Cleanly exit subcontext processes upon init's death" 2018-09-22 00:12:09 +00:00