Commit graph

1518 commits

Author SHA1 Message Date
Treehugger Robot
b6cb9b0457 Merge "There's no longer a limit to property names." 2017-03-01 00:03:58 +00:00
Elliott Hughes
b7788fd454 There's no longer a limit to property names.
Bug: http://b/33926793
Test: boots
Change-Id: I8554d7af74e064c114cf817f5a2ba1247fa2a2db
2017-02-28 14:12:54 -08:00
Keun-young Park
7d3202650d set ro.boottime.persistent_properties when persisted props are restored
- allows components relying on persisted props to wait for this property.

bug: 35178781
Test: reboots
Change-Id: I06cbf2a6b375654fcc277a2699fceeb23846a241
2017-02-28 11:31:54 -08:00
Treehugger Robot
f719c255fa Merge "init: early_mount: removing hard-coded paths" 2017-02-28 01:29:13 +00:00
Bowgo Tsai
d4beed22e8 init: early_mount: removing hard-coded paths
Current early mount has some hard-coded paths that are not easy to extend
when we switch verified boot to AVB (external/avb/libavb). This CL uses some
C++ containers to replace those fixed paths.

Bug: 33254008
Test: early mount /vendor with dm-verity on sailfish
Test: early mount /vendor without dm-verity on sailfish
Test: early mount /vendor with dm-verity on bullhead

Change-Id: I32a22fe486d7649e33bb23c9018ddc0428df6069
2017-02-27 13:09:06 +08:00
Jaekyun Seok
4ec72cc25f Treblize init.rc location
Treblization requires to locate partner-specific modules in its own
partition. So their own init.rc file could be located in /odm or
/vendor.
This CL is to support those locations for the init.rc.
Additionally thic CL modified import parser to support importing a
relative path.

Test: building succeeded and tested on sailfish with enabling early
mount.
Bug: 35269867

Change-Id: I1bce924a32c8a2b53fb5d981d35d758cf9ddd9a6
2017-02-25 08:06:12 +09:00
Treehugger Robot
93072f2ce3 Merge changes from topic 'early-mount-verity'
* changes:
  adb: early-mount: fix verity toggle through adb for early mount
  early_mount: fs_mgr: move all fstab logic into fs_mgr
2017-02-24 02:13:50 +00:00
Sandeep Patil
c20c0c2cdd early_mount: fs_mgr: move all fstab logic into fs_mgr
With init parsing fstab fragments from kernel separately, the fs_mgr
would completely miss the device tree entries. That leads to things like
'adb remount' to go through without warning for verity even if /system
is verified. This happens because 'verity_update_state' completely
misses the partitions passed to android through the device tree.

solution is to teach fs_mgr about device tree fstab entries and add 2
new public APIs.

1. fs_mgr_read_fstab_dt() - reads device tree and returns fstab
generated from it.

2. fs_mgr_read_fstab_default() - reads both device tree fstab and
/fstab.{ro.hardware} and returns the combined table.

This also reduces the hardcoded /fstab.{ro.hardware} occurence only to
fs_mgr and for eveyone who wants to read the "default" fstab must be
changed to call fs_mgr_read_fstab_default() instead. e.g. adb.

b/27805372

Test: Angler was used since it has 2 early mounted partitions instead of
one. 1 verified and 1 unverified.
- Boot angler successfully without early mount
- Boot angler successfully with /vendor early mount and test if 'adb
remount' warns us about verity
- Boot angler successfully with both /system and /vendor early mounted
and ensure 'adb remount' warns us about verity.
- check partitions.system.verified status after /system early mount ot
ensure it is set to VERITY_MODE_DEFAULT.
- 'adb disable-verity' with early mounted /system doesn't work due to
missing changes in adb

TODO:
change adb to use the new fs_mgr_read_fstab_default() API

Change-Id: I82038d87c7a44488e938acce2cc1082c08f6f73a
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-02-23 16:48:43 -08:00
Tom Cherry
0506b18a36 Check setegid() return values
The clang static analyzer is complaining that we are not checking the
setegid() return value, so let's add these checks.  We should never
fail to return to AID_ROOT, so fail hard in this case.

Bug: 26962034
Test: Boot bullhead
Test: export WITH_STATIC_ANALYZER=1 and run 'mm' in the project directory
Change-Id: I62e95b045c5734305c71502871b6cf17f152edbc
2017-02-23 13:50:21 -08:00
Treehugger Robot
4bd3facbb1 Merge changes from topic 'early-mount-support'
* changes:
  fs_mgr: add a generic fs_mgr_get_boot_config internal API
  init: early_mount: create device node for verity metadata partition
  init: early_mount: disallow partitions to be verified at boot
  init: early_mount: add support to mount verity enabled partitions early
  fs_mgr: make fs_mgr_setup_verity public API
  fs_mgr: fix the fs_mgr_setup_verity param name
  init: refactor to allow successive device_init calls
  fs_mgr: add fs_mgr_do_mount_one() API
2017-02-23 07:16:18 +00:00
Elliott Hughes
b005d90816 Address property service DoS.
Bug: http://b/35166374
Test: ran new test
Change-Id: I94cf5750f0d2dc87f4a118b2c63b16255ef30fd2
2017-02-22 14:54:15 -08:00
Sandeep Patil
e9da79bd44 init: early_mount: create device node for verity metadata partition
Most devices pass the veritymode through 'androidboot.veritymode' kernel
cmdline partition. However, for those who don't, the verity state is
read from a different block device whose path it passed to "verify="
fs_mgr option in fstab.

This change add support for such a case if the partition that needs to
be mounted early requires this additional block device to load the
verity state from.

Note that, there can only be 1 partition to get the verity state
regardless of the number of partitions we enable verity for.

Bug: 27805372

Test: Test angler by removing the metdata argument in fstab when it
boots fine. Tested by adding the argument when it fails to boot as
veritymode gets set to EIO during early mount due to lack of access to
properties as expected.

TODO: fs_mgr must pull the veritymode from kernel cmdline or device tree
by itself

Change-Id: I9e62b8c1bf2c0ae0365677df697a0cbe9e5810c1
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-02-22 11:30:35 -08:00
Sandeep Patil
05ff38ba43 init: early_mount: disallow partitions to be verified at boot
While technically possible, the verification at boot basically will
block init for as long as the entire partition is read while nothing
else is running. Disallow that as this is not going to be used anywhere.

Bug: 27805372
Test: boot angler with verifyatboot fs_mgr option for early mounted
vendor partition. That resulted in a panic() as expected.

Change-Id: I9da5caa163cae8bce6dbfb630f0ed5605ea044a0
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-02-22 11:22:53 -08:00
Sandeep Patil
0a3e36fbb1 init: early_mount: add support to mount verity enabled partitions early
support mounting partitions early regardless of their "verified" status.
uses the newly exported fs_mgr APIs to split verity setup and mount
operations.

b/27805372

Test:
 Angler:
 - Early mount /vendor without dm-verity
 Sailfish:
 - Early mount /vendor without dm-verity
 - Early mount /vendor with dm-verity

TODO:
 add support for metadata partition used in angler
to load dm-verity data

Change-Id: Ie2768d4d895c19d045293c573773ee7bb03fff99
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-02-22 11:22:53 -08:00
Sandeep Patil
971a460c5b init: refactor to allow successive device_init calls
device_init opens the uevent socket and sehandle when called.
For early_mount however, depending on the fs_mgr flags we may call this
in order to run coldboot for device mapper, dm-verity devices etc.
So the change makes sure we don't try to re-open the uevent socket,
file context handle and selinux status on successive calls to
device_init from within the same process.

b/27805372

Test: Boot saifish successfully

Change-Id: Ifa0e665403211684183efb9be66e4e8d0d86a206
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-02-22 11:22:49 -08:00
Treehugger Robot
a20c678d45 Merge "init: minor fix to READEME.md" 2017-02-22 00:22:28 +00:00
Bin Chen
a08f002c23 init: minor fix to READEME.md
Change-Id: I149c2a8f2053ac4dcc61bea6fa8c57f4c7b73c9e
Signed-off-by: Bin Chen <bin.chen@linaro.org>
2017-02-22 09:38:25 +11:00
bowgotsai
763512795d Set libavb version into system property for Treble OTA
Treble allows framework-only (system.img) OTA. To libavb statically
linked in init/fs_mgr cannot parse the AVB metadata of system.img, add
this property for the Treble OTA match process.

Bug: 35236019
Test: Normal boots, use 'adb shell getprop' to check the property is set.
Test: Recovery boots, press 'Mount system' and use 'adb shell getprop'
      to check the property is set

Change-Id: I552be229c4efd45088d93252ac67176606f75d4d
2017-02-16 05:18:12 +00:00
Treehugger Robot
1549257ff5 Merge changes from topic 'pre-early-mount'
* changes:
  init: fstab: add support to read fstab entries from device tree
  init: early_mount: add support to mount non-verity partitions early
  init: remove the existing early_mount code
  init: refactor: add support for doing early coldboot
  ueventd: make selinux labeling optional for device creation
2017-02-14 20:34:35 +00:00
James Hawkins
c8ac067773 Revert "bootstat: Refactor init/utils/boot_clock into base/chrono_utils."
This reverts commit 7c92e48450.

Mac sdk still broken (despite testing locally).

Change-Id: I7d9206e15997cd0efe081bd3fa17d53d2b20ec32
2017-02-14 19:20:20 +00:00
James Hawkins
7c92e48450 bootstat: Refactor init/utils/boot_clock into base/chrono_utils.
Use this for bootstat and init. This replaces the custom uptime parser in
bootstat.

This is a reland of aosp/332854 with a fix for Darwin.

Bug: 34352037
Test: chrono_utils_test
Change-Id: Ib2567d8df0e460ab59753ac1c053dd7f9f1008a7
2017-02-13 15:47:21 -08:00
Sandeep Patil
fc86f2442f init: fstab: add support to read fstab entries from device tree
for early mount, we need a way to tell init where to find vendor,
odm partitions (also system in case of non-A/B devices). Also, that
needs to be independent of kernel cmdline since the cmdline will likely
exceed its limit.

The change adds support for parse and create fstab entries that can be
directly sent to the fs_mgr for mounting partitions early in init first
stage.

Sample DT entry to mount vendor partition early on angler-

firmware {
    android {
        compatible = "android,firmware";
        fstab {
            compatible = "android,fstab";
            vendor {
                compatible = "android,vendor";
                dev = "/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor";
                type = "ext4";
                mnt_flags = "ro,barrier=1,inode_readahead_blks=8";
                fsmgr_flags = "wait";
            };
        };
    };
};

b/27805372

Test: Boot angler and sailfish with early "vendor" partition mount by
adding aforementioned DT node and enable CONFIG_PROC_DEVICETREE in kernel

Change-Id: I669013e3fdb157e88719436534f63989dec95d60
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-02-13 12:35:39 -08:00
Sandeep Patil
35403ebaf8 init: early_mount: add support to mount non-verity partitions early
This is done by parsing 'androidboot.fstab=<fstab>' kernel cmdline
option to get the fstab file that *only* specifies partitions to be
mounted early (i.e. in init's first stage).

Note that, the same fstab file may not be used as an argument to
mount_all later in the boot as that will cause fs_mgr to fail with
EBUSY.

TODO:
- Possibly add a new mount_mode so the same fstab can be used for
early_mount, 'mount_all --early/--late' etc.
- Add support for dm-verity enabled partitions to mount early.
- Add support for getting fstab arguments through DT instead of kernel
cmdline.

Bug: 27805372

Test:
Boot angler by passing a seperate fstab file using the kernel
cmdline option to mount vendor partition early, remove the vendor
partition entry from the main fstab file for the test.

Boot sailfish by passing a seperate fstab entry via device tree
to mount vendor partition early. Remove vendor partition entry from
the main fstab file for the test

Change-Id: I18785b893c54c8cee960ab44d5e8f83e5d624aa8
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-02-13 11:17:51 -08:00
Treehugger Robot
d7b5c7b2da Merge "Add a sample service for testing init." 2017-02-10 01:40:12 +00:00
Sandeep Patil
44a3ee2cd1 init: remove the existing early_mount code
keeps parts of the code that are still needed for the fs_mgr
+ dt based implementation

b/27805372

Test: boot angler, sailfish without regressions

Change-Id: I1b08f8b7b4f2e67118d328443a5011c0f5ead919
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-02-09 15:39:06 -08:00
Sandeep Patil
957e4ab0b5 init: refactor: add support for doing early coldboot
We don't want to spend time creating devices that are unncessesary
during early (init first-stage) mount. So, refactor the devices code
tha allows us to call into coldboot and has the

- ability to only create devices that are specified by the caller
- ability to stop coldboot cycle when all devices that the caller is
interested in
- ability to run coldboot for a specific syspath
- ability to run ueventd code unmodified

Test: Tested boot on angler, sailfish

Change-Id: Id8f3492380696760414eadc20d624d300c904f8e
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-02-09 15:30:20 -08:00
Jorge Lucangeli Obes
28e980b59c Add a sample service for testing init.
I find myself using something like this every time I add functionality
to init. I cannot possibly be the only one doing this. On the other
hand, if this hasn't been added for so long, maybe there's a reason
for that.

The advantage of using a test service versus modifying an existing
service is that the test service doesn't *require* any permissions or
privileges, so you can add and/or remove whatever you need to test
without breaking the service.

I found it useful to have the service check its own /proc/<pid>/status
from command-line arguments, so that's what the service does.

This CL also adds a .clang-format file for init.

Bug: None
Test: Service runs and exits successfully.

Change-Id: I3e7841a7283158e10c0bf55e0103c03902afb1f0
2017-02-09 18:23:09 -05:00
Treehugger Robot
d54d4c275e Merge "ueventd: source ueventd configs from vendor and odm" 2017-02-09 21:25:44 +00:00
Sandeep Patil
ea23983a9c ueventd: make selinux labeling optional for device creation
This is to setup a way for us to run coldboot during init first stage
and also at ueventd startup. We do not have all of the file context
during the first stage, so the "early" coldboot needs to proceed without
labelling the device nodes. However, the follow up in ueventd must label
these nodes. This change allows us to do both.

b/27805372

Test: Boot angler successfully and compare do before/after comparison of
      the output of 'ls -AclpqRZ /dev' to ensure there are no differences.

Change-Id: I5e88bd7da8a1d2cc41e3abba30dda463ecbde32e
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-02-08 14:40:18 -08:00
James Hawkins
0e3167e203 Revert "bootstat: Remove custom uptime parser in favor of elapsedRealtime."
This reverts commit 26f40c04c3.

This change broke the Darwin SDK target.

Test: none
Change-Id: Ia54fe2c31da8d8fa2825e023b035fb8321dcd457
2017-02-08 14:16:51 -08:00
Sandeep Patil
bf298e6d0c ueventd: source ueventd configs from vendor and odm
While keeping the old /ueventd.$ro.hardware.rc configuration for devices
without early mount or vendor,odm split

b/34967636

Test: Boot angler and sailfish without regressions

Change-Id: I8d671911fd23fb1c0b5624ae209bad86137c88b7
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-02-08 13:51:02 -08:00
James Hawkins
26f40c04c3 bootstat: Remove custom uptime parser in favor of elapsedRealtime.
Refactored init/utils/boot_clock into base/chrono_utils.

Bug: 34352037
Test: none
Change-Id: Ied0c00867336b85922369d7ff37520e3d28fc61e
2017-02-07 15:43:32 -08:00
Wei Wang
2d0fdaaafc init: clean up exec command
Add wait time log for exec service execution time
Fix memory leak when exec service failed to start

Test: on marlin
Bug: 34518530
Change-Id: I01736bd9b1429414f3dc91dd5d02d88a681f0985
2017-02-03 10:40:39 -08:00
Paul Lawrence
c4af05f8a3 Revert "Enable seccomp in init with generated policy"
This reverts commit db929bf9b7.

Seccomp is now inserted at the zygote level, not in init

Bug: 34710876
Test: Boots, seccomp policy in zygote & zygote64 but not init
Change-Id: I9075a79793171a4eaccf6228e9ff3398c791f8bd
2017-02-02 09:27:49 -08:00
Treehugger Robot
d25e4c5819 Merge "init: add wait_for_prop builtin command" 2017-02-02 04:45:36 +00:00
Alex Shlyapnikov
2e71ceb0f4 Expand seccomp whitelist
Add syscalls required by sanitizers.

Bug: 34606909
Test: Make sure Android boots when built with SANITIZE_TARGET='address'
Change-Id: Ifa223fb663a4ff43c8b8df9b7bf9452e41079e2e
2017-02-01 18:03:08 -08:00
Wei Wang
132ac31b47 init: add wait_for_prop builtin command
There are many use cases from vendors to exec service in background and then
use a shell scriprt to wait for the command done.

This CL is to add a wait_for_prop command to suppor those use cases.

Bug: 34746108
Test: on marlin
Change-Id: Ia81290b0928f9d375710d2daa546714f0cd65b72
2017-02-01 16:11:33 -08:00
Treehugger Robot
2cd07e8b97 Merge "Expand seccomp whitelist" 2017-02-01 01:17:43 +00:00
Paul Lawrence
8afdd2aac6 Expand seccomp whitelist
Bug: 34817266
Test: Boots, app starts
Change-Id: I39026064ec6c7130256ae463163c1f7634e3bdd4
2017-01-31 15:26:00 -08:00
Treehugger Robot
301e7e2cdb Merge "Expand seccomp whitelist" 2017-01-31 22:44:44 +00:00
Paul Lawrence
ae3f906093 Expand seccomp whitelist
Bug: 34813887
Bug: 34809883
Bug: 34767389
Bug: 34719286
Test: Device boots, the app in b/34719286 runs when it didn't before
Change-Id: Iad198e3ca620e7a07464b0d182f969bb807bd948
2017-01-31 08:35:00 -08:00
Sandeep Patil
d04b1ac006 Merge "init: split property context into platform & non-platform components" 2017-01-30 19:16:17 +00:00
Elliott Hughes
795798d62c bionic and init don't need to share knowledge of property file locations.
So move them into init.

Bug: http://b/33926793
Test: boots
Change-Id: I5a9601180df589b8c87ac8195a02ee24b531d4da
2017-01-27 16:21:55 -08:00
Treehugger Robot
d0ff90afef Merge "Allow failing app through seccomp policy" 2017-01-27 20:02:56 +00:00
James Hawkins
7dde4fa4e2 Merge "boottime/init: Report ro.boottime.init* properties in milliseconds." 2017-01-27 18:37:22 +00:00
Paul Lawrence
e4ddaa4f2f Allow failing app through seccomp policy
Bug: 34651972
Test: Made sure failing app went to login screen
Change-Id: I111a379f3e8283aa829d9ceb97f95b34bbee4055
2017-01-27 18:32:11 +00:00
James Hawkins
27c052263c boottime/init: Report ro.boottime.init* properties in milliseconds.
* Nanosecond precision ended up being harder to grok.
* This change modifies the Timer class to have duration_ms instead of
duration_ns.

Bug: 34466121
Test: adb logcat | grep bootstat
Change-Id: Ibd1c27dc3cb29d838a956e342281b2fb98d752a6
2017-01-27 08:26:14 -08:00
Paul Lawrence
73f6e44c8b Allow __NR_perf_event_open
Bug: 34732712
Test: strace simpleperf32 record -g runs
Change-Id: Id2ffd1e808587bf809a7ff0303163816a0e8fbce
2017-01-27 08:25:56 -08:00
Sandeep Patil
7a5db4ec7f init: split property context into platform & non-platform components
Bug: 33746484
Test: Successfully boot with original service and property contexts.
Test: Successfully boot with split serivce and property contexts.
Test: 'getprop -Z'
Change-Id: Ib9c087115040c1609aa64a3ed66d4e67e937e33d
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-01-26 15:31:10 -08:00
Paul Lawrence
31b2a9d7a3 Allow __NR_pipe for 32-bit processes
Used by 32-bit debuggers

Bug: 34716063
Test: Make sure a Chrome crash produces a valid stack trace in logcat
Change-Id: Ie42f035da7f19ace403eb2111524f02c0bbfd0d5
2017-01-26 12:31:55 -08:00
Treehugger Robot
0a3c2392c7 Merge "fs_mgr: support using libavb to enable dm-verity" 2017-01-25 18:24:30 +00:00
Robert Sesek
ca2da60206 Ensure property_set connection sockets are CLOEXEC.
When handling a property control message to start a service, the
connection socket was being left open. The child socket FD would then be
inherited by the service from init as "/null".

Bug: 34698883

Test: adb shell start webview_zygote32; adb shell ls -l /proc/<pid>/fd,
      no "/null" FD open.

Change-Id: I25f34e1bfc1414e6143acf23414b05f5a241cace
2017-01-25 08:08:51 -05:00
bowgotsai
b51722b4e2 fs_mgr: support using libavb to enable dm-verity
external/avb/libavb provides the new Android Verified Boot (AVB) flow.
It has different verity metadata format than previous formats in
fs_mgr_verity.cpp fs_mgr should support using libavb to read the metadata
(a.k.a. HASHTREE descriptor in AVB) to enable dm-verity in kernel.

Two important files in this commit:

 - fs_mgr_avb_ops.c: an implementation of struct AvbOps* for libavb to do
   platform dependent I/O operations, e.g., read_from_partition.

 - fs_mgr_avb.cpp: it reads the metadata (a.k.a. vbmeta images in AVB) from
   all partitions, verifies its integrity against the values of
   androidboot.vbmeta.{hash_alg, size, digest} passed from bootloader in
   kernel command line. Then enable dm-verity for partitions having the
   corresponding HASHTREE descriptor and with an 'avb' fstab flag.

Bug: 31264231
Test: Enable dm-verity on /system partition
Test: Enable dm-verity with FEC on /system partition

Change-Id: I4652806984fe5a30c61be0839135b5ca78323d38
2017-01-25 18:03:20 +08:00
Dimitry Ivanov
c9bb0338bc Revert "Revert "New protocol for property_service""
This reverts commit 70c4ecf2b5.
Bug: http://b/33926793
Bug: http://b/34670529
Test: run bionic-unit-tests --gtest_filter=prop*

Change-Id: I75b28146805ff37fbdcf0543ccb515ee5895eb2a
2017-01-24 13:01:13 -08:00
Dimitry Ivanov
17767caed9 Merge "Revert "New protocol for property_service"" 2017-01-24 20:00:44 +00:00
Dimitry Ivanov
70c4ecf2b5 Revert "New protocol for property_service"
This reverts commit dee4bd236b.
Bug: http://b/33926793
Bug: http://b/34670529

Change-Id: Ife3a5a471ee29cb12c2c41efef885ba40b8970e6
2017-01-24 18:38:09 +00:00
Treehugger Robot
9fd1190790 Merge "Allow tkill" 2017-01-24 04:31:26 +00:00
Treehugger Robot
1b3350e4ca Merge "Allow restart_syscall" 2017-01-24 04:08:48 +00:00
Treehugger Robot
571cd23fa8 Merge "init: add ro.boot.init_rc" 2017-01-24 03:59:13 +00:00
Colin Cross
2e253cbcc6 Allow tkill
tkill and tgkill are syscalls that do not have glibc wrappers, but
they are required in order to send a signal to a specific thread.
Non-android software may call them directly with syscall().  Bionic
provides a wrapper for tgkill, so seccomp allows it, but not for
tkill.  Add tkill to the whitelist.

This can be reproduced with:
sleep 1000 & sleep 1 ; strace -p $!
then hit ctrl-C, and the shell will print "Bad system call" because
the strace process died with SIGSYS

Bug: 34586922
Test: repro case is fixed
Change-Id: Ib6962a967f2cc757f2906de7905e75e1b6d6f39f
2017-01-23 17:10:51 -08:00
Colin Cross
47afc6b64e Allow restart_syscall
restart_syscall is used by the kernel whenever a syscall with a
timeout is interrupted.  Whitelist it in seccomp to prevent
processes being killed with SIGSYS when being ptraced.

Bug: 34586922
Test: hwui_unit_tests
Change-Id: Ic47dcad33f3082eb5673c3c67fe17200d4daaf74
2017-01-23 17:05:01 -08:00
Dimitry Ivanov
dee4bd236b New protocol for property_service
New protocol assumes that there is no limit on name or value
and effectively removed limit on property name length.

It also send back a uint32_t with error code (or 0 on success)

Bug: http://b/33926793
Test: mm, boot, run bionic-unit-tests --gtest_filter=prop*
Change-Id: Iac6290398ddc495e03f8fbbc3a79e923eff5df6f
2017-01-23 15:30:05 -08:00
Dave Weinstein
44f7e4f421 Move the kptr_restrict setting from init.rc to init.cpp.
Also ensure that it uses the highest supported value, and
abort if the value is not above a minimum threshold.

Test: Tested against the curent kernel (maximum value of 2,
      set to 0 by the kernel initially) and against a
      modified kernel (maximum value of 4, set to 4 by the
      kernel initially)

Bug: 30368199
Change-Id: I608db577258b68b390ffe96f452e1f7c0bc9ad8a
2017-01-20 09:40:43 -08:00
Treehugger Robot
8dbab358f0 Merge "Load default/build props from each partition" 2017-01-20 03:58:52 +00:00
Treehugger Robot
cfb8800e18 Merge "Enable seccomp in init with generated policy" 2017-01-19 23:26:10 +00:00
Jaekyun Seok
de21de7a42 Load default/build props from each partition
The following files will be loaded additionally.
- /odm/default.prop and /vendor/default.prop for default props.
- /odm/build.prop for build props.

The props files must follow the following priority order.
- /default.prop > /odm/default.prop > /vendor/default.prop
- /system/build.prop > /odm/build.prop > /vendor/buid.prop

Test: tested default/build prop files with enabling early mount, but
didn't test files of odm partition because odm partition doesn't
exist now.
Bug: 34116668
Change-Id: I946d076dae38f2288865dd986fb16d801d4abcc0
2017-01-19 08:45:40 +09:00
Jorim Jaggi
8e81cd6609 Merge "Revert "init: split property context into platform & non-platform components"" 2017-01-18 16:33:32 +00:00
Jorim Jaggi
328cb5d141 Revert "init: split property context into platform & non-platform components"
This reverts commit 871c306855.

Change-Id: I3e14b71e9fc5f37c9691405ce20031451643f9b4
2017-01-18 15:33:26 +00:00
Treehugger Robot
b8e5553887 Merge "init: split property context into platform & non-platform components" 2017-01-18 06:09:02 +00:00
Hung-ying Tyan
959aeb17d5 init: add ro.boot.init_rc
SoC vendors and ODMs need a way to run different init scripts under
different boot modes. This patch adds a new ro.boot.init_rc kernel
cmdline argument to support this.

Bug: 26639863
Test: Tested on bullhead with androidboot.init_rc given a
non-existent .rc file which leads to expected boot failures.
Boot succeeds if androidboot.init_rc is not specified.

Change-Id: I2bca1cc3de6720feced041fe87266fb8afcce8b0
2017-01-18 09:39:36 +08:00
Tao Bao
4c5c9db17b Merge "Revert "init: add ro.boot.init_rc"" 2017-01-17 20:19:23 +00:00
Tao Bao
01519a207c Revert "init: add ro.boot.init_rc"
This reverts commit 7e6d30e5f2.

Bug: 26639863
Bug: 34318089
Change-Id: Ie71d773ee7c6c6a90e8298f8e0798eacba12d0be
2017-01-17 20:16:45 +00:00
Treehugger Robot
0cf5e36c00 Merge "init: add ro.boot.init_rc" 2017-01-14 08:06:09 +00:00
Treehugger Robot
5d05d0e74e Merge "Move to .md files for even trivial documentation." 2017-01-13 19:39:26 +00:00
Elliott Hughes
15f0f504ac Move to .md files for even trivial documentation.
So it's automatically displayed for folks browsing the source.

Bug: N/A
Test: N/A
Change-Id: Ib595ab428054f274a92374728e3e66474ffc5116
2017-01-12 22:40:49 -08:00
Alex Deymo
b0c395955d Remove "_host" and "_static" suffix from libsparse definition.
This now combines all the "libsparse" libraries into the same soong
target. A minor side-effect of this change is that the libsparse
static library depends on the libz shared library instead of the libz
static library. This minor change has no effect since targets using
the static libsparse library need to explicitly include either the
static libz or the shared one.

Bug: 34220783
Change-Id: I8f41586cf4c3336791cfa57ab4f5ae59a76d7ffa
2017-01-11 19:15:11 -08:00
Hung-ying Tyan
7e6d30e5f2 init: add ro.boot.init_rc
SoC vendors and ODMs need a way to run different init scripts under
different boot modes. This patch adds a new ro.boot.init_rc kernel
cmdline argument to support this.

This patch also changes late-init trigger. Now late-init is only
triggered in "normal" boot (where boot mode is not specified). This is
to make AOSP init.rc re-usable in other boot modes as the operations
in late-init are less common.

Bug: 26639863
Test: Tested on bullhead with
  androidboot.init_rc = {non-existent .rc file}
  and/or
  androidboot.init_rc = {none empty string}
  both of which lead to expected boot failures.
  Boot succeeds if androidboot.init_rc is not specified.
Change-Id: Ie5f08c3914f2f825ad3c401fde6741459668c523
2017-01-12 10:08:30 +08:00
Alex Deymo
705353ae27 Remove "_static" and "_host" suffix from libext4_utils.
Bug: 34220783
Change-Id: I967dbaa9c48ad1feed2369c3a40f745b86a350f8
2017-01-11 14:05:42 -08:00
Paul Lawrence
db929bf9b7 Enable seccomp in init with generated policy
Test: Ran script to test performance - https://b.corp.google.com/issues/32313202#comment3
      Saw no significant regression with this change on or off
      Removed chroot from SYSCALLS.TXT - chroot blocked
      Boot time appears reasonable
      Device boots with no SECCOMP blockings
      Measured per syscall time of 100ns
      Empirically counted <100,000 syscalls a second under heavy load

Bug: 32313202
Change-Id: Icfcfbcb72b2de1b38f1ad6a82e8ece3bd1c9e7ec
2017-01-10 10:09:38 -08:00
Sandeep Patil
871c306855 init: split property context into platform & non-platform components
Bug: 33746484
Test: Successfully boot with original service and property contexts.
Test: Successfully boot with split serivce and property contexts.
Test: 'getprop -Z'
Change-Id: I62689b229a67e319c65bf034da804f660f82bd35
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-01-05 13:19:01 -08:00
Treehugger Robot
4a3b03e9e5 Merge "init/service.cpp: fix access check for console" 2017-01-03 23:27:40 +00:00
Nick Kralevich
8adb4d9d12 Send property_service AVC messages to the kernel audit system
The property service uses an SELinux userspace check to determine if a
process is allowed to set a property. If the security check fails, a
userspace SELinux denial is generated. Currently, these denials are only
sent to dmesg.

Instead of sending these denials to dmesg, send it to the kernel audit
system. This will cause these userspace denials to be treated similarly
to kernel generated denials (eg, logd will pick them up and process
them). This will ensure that denials generated by the property service
will show up in logcat / dmesg / event log.

After this patch, running "setprop asdf asdf" from the unprivileged adb
shell user will result in the following audit message:

  type=1107 audit(39582851.013:48): pid=1 uid=0 auid=4294967295
  ses=4294967295 subj=u:r:init:s0 msg='avc: denied { set } for
  property=asdf pid=5537 uid=2000 gid=2000 scontext=u:r:shell:s0
  tcontext=u:object_r:default_prop:s0 tclass=property_service'

Test: manual
Bug: 27878170
Change-Id: I0b8994888653501f2f315eaa63d9e2ba32d851ef
2017-01-03 13:50:13 -08:00
Adrian Salido
24ef8601c2 init/service.cpp: fix access check for console
Commit 9596d2b95d changes how
availability of console is checked by only checking access bits for
the console device. However, in cases where there is no console it
defaults to /dev/console. This device is always enumerated by tty
driver (i.e. file and access bits may be correct), but it doesn't
always map to an underlying console driver. Because the lookup for the
underlying console driver happens during the open system call, checking
only the access bits is not sufficient and need to make sure open
system call is successful, we can safely close the FD afterwards to
avoid FD leaks.

Test: boot device and check console svc doesn't continuously restart
Bug: 33691649
Change-Id: Ia51a8a2f56c345b70db55e95f61a057a98b52895
2017-01-03 13:11:29 -08:00
Jorge Lucangeli Obes
77f0e9fda8 init: Make 'write_file' return bool to match 'read_file'.
The mismatch of return values makes reasoning about the correctness of
CLs like https://android-review.googlesource.com/317923 quite hard.

Bug: 33941660
Test: Init builds, HiKey boots.
Change-Id: Ia4b8a9af420682997b154a594892740181980921
2016-12-28 14:16:54 -05:00
Paul Crowley
0b8b2303ac Ask the user before wiping if crypto policy fails.
If crypto policy fails, instruct recovery to prompt the user before
wiping all data.

Test: adb shell rmdir /data/ota && adb shell mkdir -p /data/ota/forcefail && adb reboot
Bug: 28693324
Change-Id: I4d09b35a20c513a76c9ba56fe826114449a9ad68
2016-12-21 13:39:23 -08:00
Elliott Hughes
8766ecb78d Merge "Move init bootcharting onto its own thread." 2016-12-17 17:56:15 +00:00
Daniel Cashman
a26a98726e Revert "Compile sepolicy on-device at early boot."
This reverts commit 2fae5d65d5.

Change-Id: Id8bfc0f85d19e98df3759a2fcc6b3a331b4eec29
2016-12-17 00:53:45 +00:00
Elliott Hughes
c249794628 Move init bootcharting onto its own thread.
This reduces the overhead when bootcharting is on (obviously), but also
removes the "do we need to do anything for bootcharting?" check in cases
where we're not bootcharting.

Bug: http://b/23478578
Bug: http://b/33450491
Test: rebooted with bootcharting on/off
Change-Id: Id8746b5023b17d7615679eba0bcd02aee048ef1a
2016-12-16 14:45:17 -08:00
dcashman
2fae5d65d5 Compile sepolicy on-device at early boot.
Compile policy from disparate sources at beginning of init and use to load
rather than relying on prebuilt policy.

Bug: 31363362
Test: Policy builds on-device and boots.
Change-Id: I681ec3f7da351d0b24d1f1e81e8a6b00c9c9d20c
2016-12-16 14:02:31 -08:00
Treehugger Robot
044b18cb7f Merge "capabilities: Check ambient caps, last valid runtime cap." 2016-12-16 19:50:34 +00:00
Jorge Lucangeli Obes
f3f824ee42 capabilities: Check ambient caps, last valid runtime cap.
Partners have expressed interest in using the 'capabilities' keyword
in init, so make the code more resilient:
-Check that ambient capabilities are supported by the kernel.
-Check that the last valid cap at runtime is not higher than what's in
kernel headers.
-Check that the user is not requesting a capability present in kernel
headers but not supported by the kernel at runtime.
-Don't attempt to drop bounding set capabilities not supported at
runtime.

This CL also fixes a small bug where < should have been used instead of
<=, and uses 'static' instead of anonymous namespaces.

Bug: 32438163
Test: Use a test service that uses capabilities.
Test: Apply in internal tree and test with angler and rild.

Change-Id: Ia271cc7eb389d1d526d61f897261e4bac4d19e5d
2016-12-16 13:04:52 -05:00
Elliott Hughes
4ee7861ee1 Merge "Improve init bootcharting." 2016-12-16 17:32:27 +00:00
Treehugger Robot
d9b9ebb887 Merge "init: Specify the data wipe reason." 2016-12-14 21:08:40 +00:00
Tao Bao
fdf1a54f45 init: Specify the data wipe reason.
We should say that if the data wipe is triggered by fs_mgr_mount_all.

Test: mmma system/core/init
Change-Id: I3998d9493611ecc286de0913a95cf22fc41100b5
2016-12-14 12:12:32 -08:00
Treehugger Robot
a95e9aff7c Merge "Remove obsolete __BRILLO__ ifdef." 2016-12-14 19:14:08 +00:00
Jorge Lucangeli Obes
405da69b27 Remove obsolete __BRILLO__ ifdef.
Confirmed with Brillo TL this is not needed.

Bug: 33620501
Test: Builds, boots on HiKey.
Change-Id: I8d6b7cc2a94e668d63421c456d38fe23877c3cf0
2016-12-14 13:25:25 -05:00
dcashman
41d0b6d3ca Convert missed ERROR() to LOG(ERROR).
commit: f86b5a6b90 converted init to
libbase logging, but the internal resolution, commit:
4dc40842ba missed one.  Convert it.

Test: builds.
Change-Id: Ic190bd8ce232de0acadd980a349de95fa8aed8ad
2016-12-14 08:38:23 -08:00
Elliott Hughes
99dae54874 Fix include order.
(cherry-pick of commit: 79f2b33594)

Test: builds
Change-Id: I865044c8c54591582e7bb1b7a055cf7ba2f17464
2016-12-14 08:16:07 -08:00
Daniel Cashman
baccc40841 Set mmap_rnd_bits to maximum value.
This is a cherry-pick of internal commit:
f611291688 which was a revert of a
revert, specifically a  revert of commit:
c8f026fc9c.

The above revert was meant only for AOSP, since the kernel prebuilts
were not yet available there.  The revert was reverted internally so
that internal builds, which have the appropriate kernel prebuilts,
operated properly.

The very first commit was originally done in nougat-dev and cherry-picked
to AOSP, so it was not picked up again when nougat landed in master.  Add
it now.

Bug: 27681085
Test: Builds and boots.
Change-Id: If1cb6308e61aaaabca5b5bd30df78aab49e7b0d5
2016-12-14 07:48:36 -08:00
Nick Kralevich
9596d2b95d init/service.cpp: fix FD leak for services with consoles
When init starts a service with a console, it tests for the presence of
a readable/writable console device. The test results in a leaked file
descriptor.

Use access() instead of open() to avoid leaking file descriptors.

Bug introduced in 70daa67062.

Test: compiles and device boots
Change-Id: I4efcfa0bb2cdb09f0455bc04a3a91e784bda7962
2016-12-10 12:20:11 -08:00
Elliott Hughes
a3641af22f Improve init bootcharting.
Most notably, there's no longer any need to guess an end time.

Bug: http://b/23478578
Bug: http://b/33450491
Test: rebooted with bootcharting on/off
Change-Id: Icb7d6859581da5526d77dfc5aa4d57c9bfbfd7e2
2016-12-08 17:35:45 -08:00
Elliott Hughes
422a5128dd Merge "The "net.change" property is no longer needed."
am: e209ed7c44

Change-Id: I45a1ce3a1527a72e7ae974fd4dab7b77c6a899ee
2016-12-06 02:49:59 +00:00
Treehugger Robot
e209ed7c44 Merge "The "net.change" property is no longer needed." 2016-12-06 02:46:43 +00:00
Mark Salyzyn
1f22788f9e Merge "init: service file command only opens existing files"
am: bd3f42016d

Change-Id: Id4c0e6b26e8b3295ebfd5387bfad2e8795531175
2016-12-05 21:37:38 +00:00
Elliott Hughes
4f9158119b The "net.change" property is no longer needed.
bionic was the only listener, and it was doing nothing useful when the
property changed, so we've removed that listener.

Bug: http://b/33308258
Test: DNS still works
Change-Id: I15292e8e58e6b87cdad8f73e449ccaf334dff68b
2016-12-05 13:12:48 -08:00
Mark Salyzyn
978fd0ea25 init: service file command only opens existing files
Mixing open or create, along with attribute(MAC) and permissions(DAC)
is a security and confusion issue.

Fix an issue where fcntl F_SETFD was called to clear O_NONBLOCK, when
it should have been F_SETFL.  Did not present a problem because the
current user of this feature does writes and control messages only.

Test: gTest logd-unit-tests and check dmesg for logd content.
Bug: 32450474
Bug: 33242020
Change-Id: I23cb9a9be5ddb7e8e9c58c79838bc07536e766e6
2016-12-05 11:26:39 -08:00
Elliott Hughes
8cf9d66486 Merge "Replace the "coldboot" timeout with a property."
am: e218fc673f

Change-Id: Ibaf1f7ad3a90e5216db04506288df51258e19f4b
2016-12-05 18:04:27 +00:00
Elliott Hughes
331cf2fb7c Replace the "coldboot" timeout with a property.
Also rename init's existing boot-time related properties so they're
all "ro.*" properties.

Example result:

  # Three properties showing when init started...
  [ro.boottime.init]: [5294587604]
  # ...how long it waited for ueventd...
  [ro.boottime.init.cold_boot_wait]: [646956470]
  # ...and how long SELinux initialization took...
  [ro.boottime.init.selinux]: [45742921]

  # Plus one property for each service, showing when it first started.
  [ro.boottime.InputEventFind]: [10278767840]
  [ro.boottime.adbd]: [8359267180]
  [ro.boottime.atfwd]: [10338554773]
  [ro.boottime.audioserver]: [10298157478]
  [ro.boottime.bootanim]: [9323670089]
  [ro.boottime.cameraserver]: [10299402321]
  [ro.boottime.cnd]: [10335931856]
  [ro.boottime.debuggerd]: [7001352774]
  [ro.boottime.debuggerd64]: [7002261785]
  [ro.boottime.drm]: [10301082113]
  [ro.boottime.fingerprintd]: [10331443314]
  [ro.boottime.flash-nanohub-fw]: [6995265534]
  [ro.boottime.gatekeeperd]: [10340355242]
  [ro.boottime.healthd]: [7856893380]
  [ro.boottime.hwservicemanager]: [7856051088]
  [ro.boottime.imscmservice]: [10290530758]
  [ro.boottime.imsdatadaemon]: [10358136702]
  [ro.boottime.imsqmidaemon]: [10289084872]
  [ro.boottime.installd]: [10303296020]
  [ro.boottime.irsc_util]: [10279807632]
  [ro.boottime.keystore]: [10305034093]
  [ro.boottime.lmkd]: [7863506714]
  [ro.boottime.loc_launcher]: [10324525241]
  [ro.boottime.logd]: [6526221633]
  [ro.boottime.logd-reinit]: [7850662702]
  [ro.boottime.mcfg-sh]: [10337268315]
  [ro.boottime.media]: [10312152687]
  [ro.boottime.mediacodec]: [10306852530]
  [ro.boottime.mediadrm]: [10308707999]
  [ro.boottime.mediaextractor]: [10310681177]
  [ro.boottime.msm_irqbalance]: [7862451974]
  [ro.boottime.netd]: [10313523104]
  [ro.boottime.netmgrd]: [10285009351]
  [ro.boottime.oem_qmi_server]: [10293329092]
  [ro.boottime.per_mgr]: [7857915776]
  [ro.boottime.per_proxy]: [8335121605]
  [ro.boottime.perfd]: [10283443101]
  [ro.boottime.qcamerasvr]: [10329644772]
  [ro.boottime.qmuxd]: [10282346643]
  [ro.boottime.qseecomd]: [6855708593]
  [ro.boottime.qti]: [10286196851]
  [ro.boottime.ril-daemon]: [10314933677]
  [ro.boottime.rmt_storage]: [7859105047]
  [ro.boottime.servicemanager]: [7864555881]
  [ro.boottime.ss_ramdump]: [8337634938]
  [ro.boottime.ssr_setup]: [8336268324]
  [ro.boottime.surfaceflinger]: [7866921402]
  [ro.boottime.thermal-engine]: [10281249924]
  [ro.boottime.time_daemon]: [10322006542]
  [ro.boottime.ueventd]: [5618663938]
  [ro.boottime.vold]: [7003493920]
  [ro.boottime.wificond]: [10316641073]
  [ro.boottime.wpa_supplicant]: [18959816881]
  [ro.boottime.zygote]: [10295295029]
  [ro.boottime.zygote_secondary]: [10296637269]

Bug: http://b/31800756
Test: boots
Change-Id: I094cce0c1bab9406d950ca94212689dc2e15dba5
2016-12-03 10:54:26 -08:00
Wei Wang
c746ecbcbe Merge "init: don't wait if we have more work to do"
am: 32ee9fc24a

Change-Id: Ie260a9e3d491b9108dc7681ede5a0e3ceac9ef79
2016-12-01 03:51:19 +00:00
Wei Wang
16db4346a2 init: don't wait if we have more work to do
Bug: 33212253
Test: On marlin
Change-Id: I8502eaa73fac6953d358af01482760b3249cfd67
2016-11-30 18:09:29 -08:00
Elliott Hughes
65016074c2 Merge "init: Fix sync issue on property trigger."
am: 80d2f01fbf

Change-Id: Iae57b79abeb7a372c0e483316d328d5307c66b73
2016-11-30 17:54:31 +00:00
caozhiyuan
b104c502e1 init: Fix sync issue on property trigger.
This issue reproduces in the following senario.
 1. ("", "") is added to queue;
 2. property_triggers_enabled is set to 1;
 3. user defined property is triggered, like sys.usb.config=adb;
 4. ("sys.usb.config", "adb") is added to queue;
 5. main loop interpret ("", "") and queue all current triggers to execution,
    so ("sys.usb.config", "adb") is queued for execution for the first time.
 6. main loop interpret ("sys.usb.config", "adb"), it is queued for
    execution for a second time.
The second time makes ASIT fail.

Bug: http://b/28218187
Change-Id: I230e175e0dca8989f1e5bd812398da90082d0ec1
Signed-off-by: caozhiyuan <cao.zhiyuan@zte.com.cn>
2016-11-29 20:19:17 +00:00
Elliott Hughes
c509c36892 Merge "Revert "init: Reworked how we wait for COLDBOOT_DONE""
am: a10bd47d60

Change-Id: Ibad56dbe843c16863a70552ea27aa3e7ffca0787
2016-11-29 18:14:19 +00:00
Billy Lau
6be1d976f6 Merge "init: Reworked how we wait for COLDBOOT_DONE"
am: 57c31d0f17

Change-Id: I40c0183e3bc22bc85977e4e8db3b4ce6ad76375e
2016-11-29 16:36:37 +00:00
Elliott Hughes
a452660d92 Revert "init: Reworked how we wait for COLDBOOT_DONE"
This reverts commit d36115ef2f.

Change-Id: I599b0eeebf9c062852323f2a4a986b18dd85288a
2016-11-29 16:34:56 +00:00
Billy Lau
d36115ef2f init: Reworked how we wait for COLDBOOT_DONE
Bug: 31800756

Instead of strictly timing out after 1s waiting for COLDBOOT_DONE,
we wait for a considerably longer period of time, which would also
allow slower non-production heavily instrumented debug builds to
boot up.

Upon successful wait, we measure the time taken and record the
value into a system property: ro.cold_boot.duration.

If timeout is still reached, we log an error message and abandon
boot process, rebooting into recovery mode instead.

Change-Id: Ic1df80546d8721b0e8c998ff294d5c5102de4e98
2016-11-22 21:25:02 +00:00
Evgenii Stepanov
4b1a329309 Merge "Revert "Revert "init: create /dev/urandom, /dev/random in first stage."""
am: b6552f376c

Change-Id: I3291276426ad5e1acb457da7ad938958d7f0f461
2016-11-19 00:51:33 +00:00
Evgenii Stepanov
102daa30a3 Revert "Revert "init: create /dev/urandom, /dev/random in first stage.""
This reverts commit 4c8a76e250.

Test: booted angler-userdebug

Change-Id: I2257a44b7cf624065e5653754062a117f3e44c98
2016-11-18 15:09:18 -08:00
Wei Wang
5514c50292 Merge "init: move empty string check to InitTriggers"
am: 9bf10ff61e

Change-Id: I7190f8bd86707b2adc4dbeffa0085ce3a190d680
2016-11-17 19:32:19 +00:00
Wei Wang
9bf10ff61e Merge "init: move empty string check to InitTriggers" 2016-11-17 19:21:47 +00:00
Paul Lawrence
ffa3689107 Merge "Add flags to restorecon_recursive to traverse filesystems"
am: 5fbd1cfd34

Change-Id: I539d7e9d441c7bb3f5602b892408a85436b857e8
2016-11-17 17:55:06 +00:00
Treehugger Robot
5fbd1cfd34 Merge "Add flags to restorecon_recursive to traverse filesystems" 2016-11-17 17:39:53 +00:00
Mark Salyzyn
809dee506e Merge "libcutils: move cutils/files.h to cutils/android_get_control_file.h"
am: 8c41e791ed

Change-Id: Ifbc00285da734859d590153a7c6cfc8e51c014f9
2016-11-17 15:33:02 +00:00
Mark Salyzyn
8c41e791ed Merge "libcutils: move cutils/files.h to cutils/android_get_control_file.h" 2016-11-17 15:22:14 +00:00
Wei Wang
93df4e18a2 init: move empty string check to InitTriggers
Test: mma
Bug: 32838381
Change-Id: I69203734ef7d3640da75f3e3cbe9254bf468d916
2016-11-16 22:24:43 -08:00
Wei Wang
279f3d593f init: fix undefined behavior in ExecuteCommand
am: d67a4abc64

Change-Id: I1ecbb1d083af62dd5e69b4cff19ec411016054f3
2016-11-17 03:54:57 +00:00
Wei Wang
3567c7c9d9 Revert "Revert "init: warn slow action""
am: 8b1d526a72

Change-Id: Ie067e37758ae28fece1732ab7697e2a1286594dc
2016-11-17 03:54:51 +00:00
Wei Wang
2369b1eb80 Merge changes from topic 'slow_log'
* changes:
  init: fix undefined behavior in ExecuteCommand
  Revert "Revert "init: warn slow action""
2016-11-17 03:46:44 +00:00
Mark Salyzyn
52bd37e633 libcutils: move cutils/files.h to cutils/android_get_control_file.h
files.[h|cpp] is bound to be abused with junk, replace with
android_get_control_file.[h|cpp]. Plus some sundry cleanup.

Test: gTest libcutils-tests, logd-unit-tests, liblog-unit-tests,
      logcat-unit-tests and init_tests
Bug: 32450474
Change-Id: Ibd4a7aa4624ea19a43d1f98a3c71ac37805d36b5
2016-11-16 15:56:56 -08:00
Wei Wang
d67a4abc64 init: fix undefined behavior in ExecuteCommand
ExecuteCommand may change command_ vector which leads undefined behavior
This bug is found when adding logs in ExecuteCommand printing our Command class fields

Bug: 32838381
Test: on emulator
Change-Id: I96468bd2192ca80013871a3a6ac4132149363fff
2016-11-16 15:46:19 -08:00
Paul Lawrence
a8d8434c42 Add flags to restorecon_recursive to traverse filesystems
Use to solve the problem of tracefs conditionally being mounted
under debugfs and needing restorecon'd without boot performance
penalty.

Also move skip-ce to a flag for consistency.

Test: Check that trace_mount has correct attributes after boot
Bug: 32849675
Change-Id: Ib6731f502b6afc393ea5ada96fa95b339f14da49
2016-11-16 22:27:45 +00:00
Jeff Sharkey
d1d3bdd16f Only restorecon CE storage after unlocked.
On FBE devices, the filenames inside credential-encrypted directories
are mangled until the key is installed.  This means the initial
restorecon at boot needs to skip these directories until the keys
are installed.

This CL changes the implementation of the "restorecon_recursive"
built-in command to use the new SKIPCE flag to avoid labeling files
in CE directories.  vold will request a restorecon when the keys
are actually installed.

(cherrypicked from commit 1635afe83d)

Bug: 30126557
Test: Cherry-picked from master
Change-Id: I320584574a4d712c493b5bbd8a79b56c0c04aa58
2016-11-16 21:19:17 +00:00
Wei Wang
8b1d526a72 Revert "Revert "init: warn slow action""
This reverts commit 1802d11cc7.

Test: grep init log
Bug: 32712851
2016-11-15 23:58:55 -08:00
Ting-Yuan Huang
1700a162d5 Merge "init: fix memory leaks"
am: a73ba879b1

Change-Id: I3375372ddc23b7440edab0107ff1cbe34d550865
2016-11-16 03:32:40 +00:00
Treehugger Robot
a73ba879b1 Merge "init: fix memory leaks" 2016-11-16 03:25:34 +00:00
Ting-Yuan Huang
09bd41d097 init: fix memory leaks
It's possible that node is not freed before return.

Test: make WITH_TIDY=1 mmma system/core/init

Change-Id: I648eea9dda006d2b2239e169785190817ad31352
2016-11-15 16:55:50 -08:00
Elliott Hughes
3ee9807554 Merge "Switch fastboot/init/libprocessgroup to std::this_thread::sleep_for."
am: f3e731b3c5

Change-Id: I2028bb8835c5e55e1bf8c88c3395253ded9d66d3
2016-11-15 18:09:46 +00:00
Elliott Hughes
f3e731b3c5 Merge "Switch fastboot/init/libprocessgroup to std::this_thread::sleep_for." 2016-11-15 18:02:30 +00:00
Wei Wang
4286801ccb Merge "init: fix BuildTriggersString for empty string"
am: 9b1d5e15ef

Change-Id: Ia344bac744e767ab26d7811ceb2806cce5f28a60
2016-11-15 17:32:13 +00:00
Treehugger Robot
9b1d5e15ef Merge "init: fix BuildTriggersString for empty string" 2016-11-15 17:23:56 +00:00
Nick Desaulniers
ea516950fb Merge "Revert "init: warn slow action""
am: 431c489568

Change-Id: I570911d0940fa6819de6f07e0d88cfadbfb6bdd1
2016-11-15 07:05:12 +00:00
Treehugger Robot
431c489568 Merge "Revert "init: warn slow action"" 2016-11-15 06:58:53 +00:00
Wei Wang
69b9b36c11 init: fix BuildTriggersString for empty string
behavior is undefined if pop_back() on empty std::string

Test: grep init log
Bug: 32712851
Bug: 32838381
Change-Id: I5bfac2fb275036abd0158b78df14019d2e82716d
2016-11-14 20:20:48 -08:00
Elliott Hughes
290a228fdc Switch fastboot/init/libprocessgroup to std::this_thread::sleep_for.
Bug: http://b/32878766
Test: boots
Change-Id: Ie0ddfb7e60f2da5f6eefbb10c83a92e88c137ae3
2016-11-14 17:08:47 -08:00
Nick Desaulniers
1802d11cc7 Revert "init: warn slow action"
This reverts commit b1a309ac1f.

Bug: 32712851
Bug: 32838381
Change-Id: Ib4c47de5ea5b0bad765a43cbff9f73d9978729d4
2016-11-15 00:53:00 +00:00
Elliott Hughes
85599ef5de Merge "Switch ueventd to sendfile(2)."
am: f77d8b0452

Change-Id: Iaf6d923bdf6f19e6c23fa6c4a80817fca59e6813
2016-11-14 21:48:38 +00:00
Elliott Hughes
f77d8b0452 Merge "Switch ueventd to sendfile(2)." 2016-11-14 21:39:25 +00:00
Elliott Hughes
eefaa1f250 Merge "init start time tracking."
am: 601bf9e7c9

Change-Id: Idd707d4694a4339e26884fe72b8f0c08c4100daf
2016-11-14 21:34:24 +00:00
Elliott Hughes
601bf9e7c9 Merge "init start time tracking." 2016-11-14 21:21:00 +00:00
Elliott Hughes
632e99a0d4 Switch ueventd to sendfile(2).
Bug: http://b/32826495
Test: booted and checked dmesg
Change-Id: Idfd813dfe6f512fdbc05b1411c7960e950e2f59b
2016-11-14 11:40:06 -08:00
Keun-young Park
ec2d5d8f04 Merge "fix swapped min / max in priority parsing"
am: 557359863c

Change-Id: Ie8bbb5add66b56ff8641f26a081fe185204b7cc1
2016-11-13 04:52:29 +00:00
Elliott Hughes
9605a945f7 init start time tracking.
With this change, init sets a property "init.start" to show the
CLOCK_BOOTTIME time at which init itself started, and for each service
an "init.svc.<name>.start" property to show the CLOCK_BOOTTIME time at
which that service was most recently started.

These times can be used by tools like bootstat to track boot time.

As part of this change, move init over to std::chrono. Also, rather than
make the command-line argument handling more complex, I've switched to
using an environment variable for communication between first- and
second-stage init, and added another environment variable to pass the
start time of the first stage through to the second stage.

Bug: http://b/32780225
Test: manual
Change-Id: Ia65a623e1866ea688b9a5433d6507926ce301dfe
2016-11-12 11:17:40 -08:00
Keun-young Park
dd34ca45ea fix swapped min / max in priority parsing
- This error led into not handling highest priority,
  which made zygote's priority boost no-op

bug: 32718256
Test: check init log during bootup

Change-Id: I959eb94912a9c1d95bfdb98ee675fdd12cf85699
2016-11-11 18:32:13 -08:00
Vineela Tummalapalli
d1b560c6f9 Merge "Implement Reboot bootloader via bootloader_message"
am: e759c83bde

Change-Id: Id0a0e9e9c10f3df206138f297d2acafa87dc4ebf
2016-11-10 02:52:23 +00:00
Treehugger Robot
e759c83bde Merge "Implement Reboot bootloader via bootloader_message" 2016-11-10 02:43:08 +00:00
Wei Wang
d26107d939 Merge "init: warn slow action"
am: 5782f72711

Change-Id: Ia9c2f08e990d70f9afbe17efbb2646717e8d58f7
2016-11-10 01:01:14 +00:00
Wei Wang
b1a309ac1f init: warn slow action
Slow action that takes longer than 50ms will be warned to user

Test: grep init log
Bug: 32712851
Change-Id: I3a6a881a8dee1807270343b511a47c76dd230392
2016-11-09 15:19:11 -08:00
Mark Salyzyn
900b5027ac Merge "init: errno handling in create_file"
am: bccb521c6b

Change-Id: Ice050c9caeb6c5b53c47c00007b68248fcd4070a
2016-11-09 16:08:54 +00:00
Mark Salyzyn
db69107de6 init: errno handling in create_file
Save errno before resetting global context. Use unique_fd.

Test: gTest init_tests
Bug: 32450474
Change-Id: If45eeaebc3ae379f84bf3ffa3c40194043191854
2016-11-09 08:00:17 -08:00
Vineela Tummalapalli
039734c7de Implement Reboot bootloader via bootloader_message
- Write reboot bootloader message to misc
 - Clarify naming for reboot to recovery

BUG: https://issuetracker.google.com/issues/32474515

Change-Id: I4e42509bfcf572e37c8fc070d6571afe406a48b6
Signed-off-by: Vineela Tummalapalli <vineela.tummalapalli@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
Reviewed-on: https://android.intel.com/548494
2016-11-08 16:45:03 -08:00
Mark Salyzyn
cc46af0fc9 init: service file keyword
am: 62767fe29f

Change-Id: Ib7655bd3a8cbe7e1861e5999c34b02c9efa8b9f7
2016-11-04 14:43:02 +00:00
Mark Salyzyn
62767fe29f init: service file keyword
Solve one more issue where privilege is required to open a file and
we do not want to grant such to the service. This is the service side
of the picture, android_get_control_file() in libcutils is the client.
The file's descriptor is placed into the environment as
"ANDROID_FILE_<path>".  For socket and files where non-alpha and
non-numeric characters in the <name/path> are replaced with _.  There
was an accompanying change in android_get_control_socket() to match
in commit 'libcutils: add android_get_control_socket() test'

Add a gTest unit test for this that tests create_file and
android_get_control_file().

Test: gTest init_tests --gtest_filter=util.create_file
Bug: 32450474
Change-Id: I96eb970c707db6d51a9885873329ba1cb1f23140
2016-11-03 13:34:26 -07:00
Jorge Lucangeli Obes
c406474c54 Merge "init: Add support for ambient capabilities."
am: 043bc971f2

Change-Id: I92b7b0f5397e4d938b9c1f1e74aa2145c2297371
2016-11-02 15:52:56 +00:00
Jorge Lucangeli Obes
24b29132a0 init: Add support for ambient capabilities.
Ambient capabilities are inherited in a straightforward way across
execve(2):

"
If you are nonroot but you have a capability, you can add it to pA.
If you do so, your children get that capability in pA, pP, and pE.
For example, you can set pA = CAP_NET_BIND_SERVICE, and your
children can automatically bind low-numbered ports.
"

This will allow us to get rid of the special meaning for AID_NET_ADMIN
and AID_NET_RAW, and if desired, to reduce the use of file capabilities
(which grant capabilities to any process that can execute the file). An
additional benefit of the latter is that a single .rc file can specify
all properties for a service, without having to rely on a separate file
for file capabilities.

Ambient capabilities are supported starting with kernel 4.3 and have
been backported to all Android common kernels back to 3.10.

I chose to not use Minijail here (though I'm still using libcap) for
two reasons:

1-The Minijail code is designed to work in situations where the process
is holding any set of capabilities, so it's more complex. The situation
when forking from init allows for simpler code.

2-The way Minijail is structured right now, we would not be able to
make the required SELinux calls between UID/GID dropping and other priv
dropping code. In the future, it will make sense to add some sort of
"hook" to Minijail so that it can be used in situations where we want
to do other operations between some of the privilege-dropping
operations carried out by Minijail.

Bug: 32438163
Test: Use sample service.
Change-Id: I3226cc95769d1beacbae619cb6c6e6a5425890fb
2016-11-01 19:56:14 -04:00
Nick Kralevich
ba2a810deb Merge "init: Put init in group AID_READPROC"
am: 995560919c

Change-Id: Id2271f8200b020fe5ccaa82e3ea4b68368a6adf1
2016-10-31 19:21:49 +00:00
Treehugger Robot
995560919c Merge "init: Put init in group AID_READPROC" 2016-10-31 19:13:35 +00:00
Wei Wang
fc60c4694c Merge "Fix log for early_mount"
am: fff1669341

Change-Id: I1624e4ac16b6bab7e6aaddb4ef9def01a5c8d15c
2016-10-31 15:10:21 +00:00
Treehugger Robot
fff1669341 Merge "Fix log for early_mount" 2016-10-31 15:04:38 +00:00
Nick Kralevich
80960d2a9a init: Put init in group AID_READPROC
bootcharts currently only show root's processes, which isn't very
useful. To investigate and track boot duration issues, we need a way for
init to see all the pids. Add init to GID 3009 (aka AID_READPROC)

Ensure that init's children don't inherit this GID by always clearing
supplementary group IDs on fork.

Bug: 32506197
Test: Device boots and /proc/1/status says init is in gid 3009
Test: zygote starts and the Group: line in /proc/ZYGOTEPID/status is empty
Change-Id: Iba90717aaa591f1d6030a379a272aee003600c0a
Not-Tested: bootchart actually works. Speculative fix.
2016-10-29 12:20:00 -07:00
Wei Wang
313b352382 Fix log for early_mount
Test: on device
Bug: 32508724
Change-Id: Ib2908b19f6068012d5597ac4cc590ffb0c063b75
2016-10-28 18:05:36 -07:00
Elliott Hughes
62fd68bb47 Merge "Log when bootcharting ends."
am: cd368c640a

Change-Id: I39e25bb450d601084f5d88d72934d319607a76d9
2016-10-29 00:35:07 +00:00
Elliott Hughes
5ee97e8ec0 Log when bootcharting ends.
Bug: http://b/26863004
Test: bootcharted N9
Change-Id: Ie91a4342d05ac5e7b6a8d37fa729edf36c38912b
2016-10-28 12:30:32 -07:00
Iliyan Malchev
8ef815de68 Merge "init: allow '.' and '@' in service names"
am: d879e0c750

Change-Id: Ib6064fff33f31905c9f2a0b3dc46ac87f29edcf1
2016-10-26 17:36:36 +00:00
Iliyan Malchev
f655480b48 init: allow '.' and '@' in service names
Services implementing HIDL HALs must be named the same as the HIDL
package, e.g. android.hardware.nfc@1.0.  Allow init to accept names
containing '.' and '@'.

Also combined logic for legal property names and legal service names.

Bug: 31458381
Bug: 32109611
Test: Tested creating service nfc@1.0-service which creates property
'init.svc.nfc@1.0-service' with and without this change. This service
successfully started only with this change.

Change-Id: Ie7a4310742bc03498d774d37b3b5fafa7c6068cc
Signed-off-by: Iliyan Malchev <malchev@google.com>
2016-10-26 08:46:24 -07:00
Iliyan Malchev
6b03c273b1 Merge "init: account for "init.svc." prefix in IsValidName"
am: 8cf0bd75f7

Change-Id: I41c9d2472412a4b4cafb23a39598ea0e31619629
2016-10-24 17:38:21 +00:00
Iliyan Malchev
00860da2f0 init: account for "init.svc." prefix in IsValidName
For each service ${service} described in a .rc file, init creates the
property init.svc.${service}.  This implies that service-name lengths
are bound by the maximum size of a property.  This patch accounts for
the "init.svc." prefix and the maximum property-name length when
validating a service name.

Test: pass

Change-Id: I32dffa37363b41a8211f7644600b81973d30a3b2
Signed-off-by: Iliyan Malchev <malchev@google.com>
2016-10-24 08:46:06 -07:00
Yabin Cui
1051e107f2 init: use libbootloader_message.
Bug: 29582118
Change-Id: I6285b29774a11d6dda8496c7c73e4c1d17a672bd
(cherry picked from commit 0b1252cca0)
2016-10-18 11:37:52 -07:00
Elliott Hughes
7948a33f2c resolve merge conflicts of a4398c1 to stage-aosp-master am: 195669febc
am: b2ab1c43cb

Change-Id: I412943235ad6cd908aca04c56aa19a3d2bbb5413
2016-10-14 02:55:55 +00:00
Elliott Hughes
da46b392f1 Move off std::sto* function which abort on failure.
Bug: http://b/31403370
Test: builds, boots, libbase tests pass
Change-Id: I89cd7ca3d8f1c8a1bad0ddf3043439449d19a293
2016-10-13 15:34:05 -07:00
Tao Bao
6efc7a787b Merge "Update the header path for ext4_utils." am: 5bc3ce85cf am: 148b85b050
am: 2815ac5584

Change-Id: I966296de6eb4ff7518b9cfcd5853fe919765b826
2016-10-10 22:14:48 +00:00
Glenn Kasten
af97f66b59 Merge "Traverse /etc/init in a well-defined order" am: db7715c7dd am: 31dcb81e63
am: 010624bd2c

Change-Id: Ie8c3467d5bb286bbdacb8479c62d2f52fef246df
2016-10-09 17:26:37 +00:00
Tao Bao
6d881d6db4 Update the header path for ext4_utils.
Test: `mmma system/core`

Change-Id: I6291d10d6c8d4972aeca55596baa83f555496193
2016-10-09 10:23:36 -07:00
Glenn Kasten
2de796491a Traverse /etc/init in a well-defined order
Bug: 31996208
Test: will need a CTS, not yet done
Change-Id: I5ecc7f0519d42a83065b7b97a31cdb5b33549cda
2016-10-07 13:56:37 -07:00
Wei Wang
46a59f8e07 Merge "Modify log level for service and ueventd" am: 891d0ba904 am: 42335b04b4
am: 06515d3231

Change-Id: Ie15a869062ef43f1c4ef2fb1540836971fa23363
2016-10-05 04:42:16 +00:00
Wei Wang
a285dac9c0 Modify log level for service and ueventd
Bug: 31938558
Test: flash and take a boot log
Change-Id: I5c6823614e1df760128519dfb294f3a44efa6bac
2016-10-04 14:50:48 -07:00
Elliott Hughes
5c54bb548a Merge "Log failed load_properties_from_file calls." am: 57513bd5a3 am: 9abb85ebe0
am: 6d60731271

Change-Id: I603025e42824e11817042d98ad7a7387b83fe99c
2016-10-01 01:23:18 +00:00
Elliott Hughes
5a7ad84ede Log failed load_properties_from_file calls.
These events are _somewhat_ normal, in that not all devices have all
partitions, but not logging anything makes it unnecessarily hard for
folks to debug simple failures.

Bug: http://b/31186390
Test: booted, checked dmesg
Change-Id: I403377c585ea35cfe73b0bed9443b75e3a84dc8d
2016-09-30 16:30:00 -07:00
Wei Wang
d61a7e2da4 Split fstab mount into 2 phases
This will make it possible to start some key services before mounting
data partition

Bug: 30118894
Change-Id: Ia9f8cc035de6cc0df9a61605864915efa0266d7f
(cherry picked from commit abfbec342f)
2016-09-06 21:04:26 +00:00
Wei Wang
254f44363b Split fstab mount into 2 phases
This will make it possible to start some key services before mounting
data partition

(cherry picked from commit abfbec342f)

Bug: 30118894
Change-Id: Ia9f8cc035de6cc0df9a61605864915efa0266d7f
2016-09-06 11:39:05 -07:00
Elliott Hughes
87e43e1627 Merge "Use android::base::Readlink in init." am: 31ea86327e am: 72887a3ff4
am: 0a2148e34d

Change-Id: Ifcd35961c8bf6e5a34f70dbf1717190a519f0b3b
2016-09-02 19:46:38 +00:00
Treehugger Robot
31ea86327e Merge "Use android::base::Readlink in init." 2016-09-02 19:37:02 +00:00
Marco Nelissen
558217ed43 Merge "Allow setting oom_score_adj for services spawned from init" am: b7aef300c4 am: 5969a3f780
am: 25e26708f6

Change-Id: I55c46391eb357a84fb9f1afc66227ef90a82d30b
2016-09-02 14:59:25 +00:00
Josh Gao
fe64538014 Merge "Revert "init: create /dev/urandom, /dev/random in first stage."" am: 37686d446d am: 8196f4cdd9
am: 1181a4a54c

Change-Id: Ib1080f9749ebca0aa7eb73380b1903d170b918bd
2016-09-02 08:52:05 +00:00
Josh Gao
4c8a76e250 Revert "init: create /dev/urandom, /dev/random in first stage."
This reverts commit ab4fbe1b4f.

Bug: http://b/31251721
Change-Id: I43e68d1bd819d0f9f7d107865a33ec892975d956
2016-09-02 08:39:39 +00:00
Josh Gao
b093053868 Merge "init: create /dev/urandom, /dev/random in first stage." am: 9baf4e94fa am: 344e2b307b
am: b9cd3c2213

Change-Id: Ief1121d9e0c8161dd975b9a9f4ce33fb0313cecf
2016-09-01 23:08:30 +00:00
Marco Nelissen
310f6704d0 Allow setting oom_score_adj for services spawned from init
(cherry picked from commit f7adf8e4739812a2a4f194b17f84f4b9df42d04b)

Bug: 29831602
Change-Id: I4d24264bb6e879935a0b2adbb2e49ddf458980cf
2016-09-01 08:23:28 -07:00
Josh Gao
ab4fbe1b4f init: create /dev/urandom, /dev/random in first stage.
Create /dev/random and /dev/urandom in the first stage, so that when we
reexec, arc4random is available for libc initialization.

Bug: http://b/29622562
Change-Id: I5b2071539a17eec609faac91dc28b08eba5ff89b
2016-08-31 15:36:37 -07:00
Elliott Hughes
f39f7f1428 Use android::base::Readlink in init.
Bug: http://b/30988271
Change-Id: Ia0000e9dd7883c31ccbd54fc01bf585c3f8b3fa7
2016-08-31 14:44:41 -07:00
Jorge Lucangeli Obes
6ccc8323b2 Merge "Add description of 'namespace' option." am: 4588ed7b5f am: 52807711fe
am: ce44aa8487

Change-Id: Ib2ef76efd778706992057d8ecbc868e1a1bf65c5
2016-08-31 21:11:18 +00:00
Jorge Lucangeli Obes
cd2518c19c Add description of 'namespace' option.
Bug: None
Change-Id: Ib71005eb9823c7511b07d4060d08411ce3d0a8f0
2016-08-31 15:23:44 -04:00
Elliott Hughes
0426ecaf82 Merge "Most accept/accept4 calls in system/core don't actually want the remote address." am: 299d64144b am: 8615d79d85
am: 66e5e2432a

Change-Id: I5d7b98fa3e9c2d8c16a1aa73e3d5a197dc150c2b
2016-08-23 23:14:44 +00:00
Elliott Hughes
8615d79d85 Merge "Most accept/accept4 calls in system/core don't actually want the remote address."
am: 299d64144b

Change-Id: I3fb9678dfed08f0b1d6e90e547ecae6cdcabc9a1
2016-08-23 23:03:20 +00:00
Elliott Hughes
3dcfa3fb1c Most accept/accept4 calls in system/core don't actually want the remote address.
So don't write the extra code for it or waste the kernel's time
copying it around.

Change-Id: I93de64064c2d4fe58ba5b5322cfa69bf31a76dad
2016-08-23 12:50:00 -07:00
Hung-ying Tyan
1263097328 Merge "Mount /vendor and /odm early" am: 35569e9d68 am: 46bfc918d0
am: d1f49a43fd

Change-Id: I6dc53f60771ad0e660e248efdc1b13734fba3061
2016-08-18 05:10:41 +00:00
Hung-ying Tyan
46bfc918d0 Merge "Mount /vendor and /odm early"
am: 35569e9d68

Change-Id: I9b5360bf3036fa88e770d686ab06b8f4cff80d7c
2016-08-18 05:04:43 +00:00
Hung-ying Tyan
99c4a8a6b3 Mount /vendor and /odm early
Right now these two partitions are mounted in the fs stage of the init
process. As a result, many vendor/ODM files needed earlier in the boot
process (e.g., init.<hardware>.rc, fstab.<hardware>.rc,
uevent.<hardware>.rc, SELinux policy files etc) can only live on the root
partition.

To prevent vendors/ODMs from polluting the root partition, this patch makes
it possible to mount the vendor and ODM partitions in the first stage of the
init process. The fstab info of both partitions to be mounted early is
composed from new kernel cmdline arguments android.early.prefix and
android.early.fstab.

For example, with:
android.early.prefix=/sys/devices/1010000.msdc0/mmc_host/mmc0/mmc0:0001/block/mmcblk0/
android.early.fstab=mmcblk0p10+/odm+ext4+ro+verify\nmmcblk0p09+/vendor+ext4+ro+verify

the final fstab string will be:
/sys/devices/1010000.msdc0/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p10 /odm ext4 ro verify
/sys/devices/1010000.msdc0/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p09 /vendor ext4 ro verify

The android.early.prefix is optional. When it is missing, the final fstab
string will be directly converted from android.early.fstab.

This patch also makes sure that the early mounted partitions are dm-verity
enabled so that they are trust worthy to store system files.

BUG=27805372

Change-Id: I3cf32482a5ec65445ba3aedab2164c7ba8f12694
2016-08-17 17:21:35 +08:00
Josh Gao
7480771909 Merge "libcrypto_utils: convert to Soong." am: c1a9a21ffe am: 87ef590bc1
am: a1da027a3c

Change-Id: Ie693d3de13b0df24ea83e70af3fa385a77ed8b33
2016-08-08 18:39:23 +00:00
Josh Gao
87ef590bc1 Merge "libcrypto_utils: convert to Soong."
am: c1a9a21ffe

Change-Id: I9cf76646d4537750c4d4080234d3384fb307e610
2016-08-08 18:33:49 +00:00
Josh Gao
c1a9a21ffe Merge "libcrypto_utils: convert to Soong." 2016-08-08 18:29:10 +00:00
Josh Gao
47763c3a09 libcrypto_utils: convert to Soong.
Bug: http://b/30708454
Change-Id: Iaad64272ced766f87e67f2877e990afccc558065
2016-08-05 18:07:36 -07:00
Elliott Hughes
3ad2ffc474 Move init's kernel logging into libbase. am: 7bc87a5a78 am: e2a7eb17b5
am: b7252fc35a

Change-Id: Ibfba937cede98ceb8f4b76d3a636e5b8035689c0
2016-08-05 00:35:29 +00:00
Elliott Hughes
e2a7eb17b5 Move init's kernel logging into libbase.
am: 7bc87a5a78

Change-Id: Ie5e359e8bd7dee4c0549072c7e955eeefe57d785
2016-08-05 00:30:00 +00:00
Elliott Hughes
7bc87a5a78 Move init's kernel logging into libbase.
This will let other stuff (such as adbd and recovery) use it too.

Bug: http://b/28467098
Change-Id: Idab51f438ed3edd6fe65a56c4b396eaff5f3833e
2016-08-04 16:09:39 -07:00
Elliott Hughes
54c7d892a1 Merge "Have init kill the process group." am: 9a5300fcb8 am: 963de55342
am: cb647e9318

Change-Id: I4e100673a6104adee4a2414fd694fd350013b934
2016-08-02 23:15:03 +00:00
Elliott Hughes
963de55342 Merge "Have init kill the process group."
am: 9a5300fcb8

Change-Id: I692c5fabfaea39e7ed6c9de5f6ad245330e3442c
2016-08-02 23:10:29 +00:00
Elliott Hughes
1e73024653 Have init kill the process group.
killProcessGroup actually works on cgroups. Kill the POSIX process
group ourselves.

Bug: http://b/29751426
Change-Id: I1a2808488510f4262811b6407bcd0948ad23bc60
2016-08-02 14:20:40 -07:00
Chih-Hung Hsieh
b143c9708c resolve merge conflicts of d072ed3 to nyc-mr1-dev-plus-aosp
Change-Id: Ifdd67548e252fcd73833a9d017aa8205bf749f70
2016-08-01 13:44:54 -07:00
Chih-Hung Hsieh
4c4fa90462 Merge \"Fix clang-tidy performance warnings in syste/core.\"
am: 4efbce14b5

Change-Id: I84f6b0134fae6e9f40710f243f4825e3f31fa15f
2016-08-01 20:23:10 +00:00
Treehugger Robot
4efbce14b5 Merge "Fix clang-tidy performance warnings in syste/core." 2016-08-01 20:13:54 +00:00
Chih-Hung Hsieh
8f7b9e3d39 Fix clang-tidy performance warnings in syste/core.
* Use const reference type for parameters to avoid unnecessary copy.
* Suppress warning of not using faster overloaded string find function.

Bug: 30407689
Bug: 30411878
Change-Id: I6cfdbbd50cf5e8f3db6e5263076d3a17a9a791ee
Test: build with WITH_TIDY=1
Merged-In: Ie79dbe21899867bc62031f8618bb1322b8071525
2016-08-01 11:55:42 -07:00
Chih-Hung Hsieh
cfa32e2d5d Merge \\\"Fix google-explicit-constructor warnings in system/core.\\\" am: 6dc68cb5f9 am: 89cc78b77f
am: e59bc67fa4

Change-Id: I28613acd85ddcbd0b6f285cdfe046b283b49bd83
2016-07-29 17:06:44 +00:00
Chih-Hung Hsieh
89cc78b77f Merge \"Fix google-explicit-constructor warnings in system/core.\"
am: 6dc68cb5f9

Change-Id: I5a010465364b6e14423b19e8c0f9cffa58ee3152
2016-07-29 17:01:17 +00:00
Chih-hung Hsieh
6dc68cb5f9 Merge "Fix google-explicit-constructor warnings in system/core." 2016-07-29 16:57:17 +00:00
Felipe Leme
704fe2d628 resolve merge conflicts of 4acdde9 to nyc-mr1-dev-plus-aosp
Change-Id: I2ed3041dd979368f149b6fccc84621e56c118db8
2016-07-29 16:12:40 +00:00
Dmitry Shmidt
16efc4d63e Merge \\\"ueventd: Remove verbose restorecon_recursive: message\\\" am: 345754313e am: 2d5dfa89ae
am: 45d9f24cd4

Change-Id: I4f981f795101ab784dfa42aa7de698d66a39baac
2016-07-28 22:25:40 +00:00
Dmitry Shmidt
2d5dfa89ae Merge \"ueventd: Remove verbose restorecon_recursive: message\"
am: 345754313e

Change-Id: I8a65176acc859b59e96f22d39e095ce2d154d9cd
2016-07-28 22:19:18 +00:00
Felipe Leme
c64c982e72 Improved keychord logging.
Often a bugreport is accidentally triggered by the combo keys, but there
is nothing in the bugreport to confirm that action because init's
klog level is KLOG_NOTICE_LEVEL.

This change change keychord's INFO messages to NOTICE, and also logs the
case where a service was not launched because ADB was disabled.

BUG: 30440213
BUG: 30345559

Change-Id: I6ccadef1621cb41dcd15e7c1660366f0e147dc7a
2016-07-28 14:11:32 -07:00
Dmitry Shmidt
7eed474db4 ueventd: Remove verbose restorecon_recursive: message
Bug: 30478300

Change-Id: Ife69bb5644c3f65f3a256dc042ae1c7fbfb77729
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
2016-07-28 13:55:39 -07:00
Elliott Hughes
a9f814239b Merge \\\"Fix early init logging.\\\" am: 6d232ab4de am: 1cbd1f5016
am: 7e336c8fe5

Change-Id: Id22974510c241cc8b62c3737de36c1e5941420e3
2016-07-27 15:36:13 +00:00
Elliott Hughes
1cbd1f5016 Merge \"Fix early init logging.\"
am: 6d232ab4de

Change-Id: I437dd3b5243ca7854439c438093e94733579279e
2016-07-27 15:30:45 +00:00
Treehugger Robot
6d232ab4de Merge "Fix early init logging." 2016-07-27 15:28:18 +00:00
Chih-Hung Hsieh
034c475931 Fix google-explicit-constructor warnings in system/core.
* Declare explicit conversion constructors.
* Add NOLINT for implicit conversion constructors.
* Fix also some misaligned indendations.

Bug: 28341362
Change-Id: Idf911f35923b408d92285cc1a053f382ba08c63e
Test: build with clang-tidy
2016-07-26 11:26:01 -07:00
Elliott Hughes
35f5d04620 Fix early init logging.
Remove the /dev/__kmsg__ workarounds (which can then be removed
from sepolicy), and fix confusion in the translation between
android-base logging and kernel logging priorities (in particular,
where 'notice' comes in the hierarchy).

Bug: http://b/30317429
Change-Id: I6eaf9919904b6b55bc402c20bf1a4ae269014bc7
Test: adb shell dmesg | grep init
2016-07-26 09:32:33 -07:00
Elliott Hughes
ef6975b675 Merge \\\"Improve init Service logging.\\\" am: c1d9ac1f85 am: b49e54b1d7
am: 3fca6fba2b

Change-Id: I63433c19e5cdad2299f39118d063d2067c5cd6d6
2016-07-26 15:27:04 +00:00
Elliott Hughes
b49e54b1d7 Merge \"Improve init Service logging.\"
am: c1d9ac1f85

Change-Id: I5eca381c0883015f1d043946db71c20635cc1784
2016-07-26 15:21:38 +00:00
Elliott Hughes
e18e7e5c43 Improve init Service logging.
Say which service.

Don't ignore setpgid failures.

Change-Id: Ifa8eba583cc3cbf3d26763977bf8c3c9835271c6
2016-07-25 18:18:16 -07:00
Jeff Sharkey
91404d9481 Merge \"Only restorecon CE storage after unlocked.\" into nyc-mr1-dev
am: 96f387e8c0

Change-Id: I3a1c31334d32e7bdff8e05558356d2833fcfb831
2016-07-18 16:06:34 +00:00
Amit Pundir
114a00ea03 Merge \\\"init: select usb gadget controller at run time\\\" am: 916f5e873e am: 91272bd435
am: aff2347646

Change-Id: Idbb3ed146b147300d8f472958a5b888c07f5a684
2016-07-15 23:01:34 +00:00
Amit Pundir
91272bd435 Merge \"init: select usb gadget controller at run time\"
am: 916f5e873e

Change-Id: Ifc4ec86c56df0de1ca498f3de392405490690809
2016-07-15 22:53:21 +00:00
Jeff Sharkey
1635afe83d Only restorecon CE storage after unlocked.
On FBE devices, the filenames inside credential-encrypted directories
are mangled until the key is installed.  This means the initial
restorecon at boot needs to skip these directories until the keys
are installed.

This CL changes the implementation of the "restorecon_recursive"
built-in command to use the new SKIPCE flag to avoid labeling files
in CE directories.  vold will request a restorecon when the keys
are actually installed.

Bug: 30126557
Change-Id: I320584574a4d712c493b5bbd8a79b56c0c04aa58
2016-07-15 16:21:42 -06:00
Amit Pundir
d2e74db475 init: select usb gadget controller at run time
Right now we set sys.usb.controller property in init.$platform.usb.rc
to enable ConfigFS gadgets.

Let system detect and set UDC driver name from /sys/class/udc instead.

Change-Id: I99ad49d24dc53b543c5573e209bf00d6c2d91dd4
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2016-07-15 15:01:43 -07:00
Mark Salyzyn
109d7d23c5 init: Add support for ${x.y:-default} expansion
commit 00ede7d262 (init: do
expand_props before calling the builtins) broke logpersist

Bug: 28120456
Bug: 22654233
Bug: 28788401
Change-Id: Ib4d8231665b26ac083b02243177493fab41c8978
2016-07-13 23:55:34 +00:00
Tom Cherry
b79e076e5e init: expand arguments of services when they start
Arguments of commands are expanded based on properties if they contain
${property.name}, however this is not currently done for arguments of
services.

This patch makes it that arguments of services are expanded each time
that the service starts at the point immediately before execve().

Bug: 28788401
Change-Id: Iba581a8377e25a6478d4d2ec2e8b29e181d8640c
2016-07-13 23:54:42 +00:00
Jorge Lucangeli Obes
67410f8578 Merge \\\"Refactor Service::Start method.\\\" am: 82d2bcc21e am: f2ffdac47a
am: 77dbaad7b9

Change-Id: Ief7f4cc5b95b018d8476dd9a35cc76dd384fcbc5
2016-07-11 17:21:18 +00:00
Jorge Lucangeli Obes
f2ffdac47a Merge \"Refactor Service::Start method.\"
am: 82d2bcc21e

Change-Id: Icccd918f1dc02010c9aceb4560dc5ff18849d8a5
2016-07-11 17:13:26 +00:00
Treehugger Robot
82d2bcc21e Merge "Refactor Service::Start method." 2016-07-11 17:08:45 +00:00
Jorge Lucangeli Obes
344d01f99f Refactor Service::Start method.
This CL extracts code from Service::Start into four helper functions,
bringing Service::Start down to 134 lines vs 212 lines originally. This
makes the method a lot easier to follow. There is no change in behaviour.

Also, make error messages consistent (start with lowercase) and
format Service::Start to fit in 100 cols.

Bug: 30035168

Change-Id: If979976fba4d339a336d030f802ca9f169fd012c
2016-07-11 09:57:17 -04:00
Elliott Hughes
6605b0b23a Merge \\\"Make klog_fd thread-safe and make klog_init a no-op.\\\" am: 588b770063 am: 73d363bbc1
am: 7288ac3982

Change-Id: I46bbcb64eecc01ec7bd8bb502237c1b9057befc4
2016-07-08 17:12:48 +00:00
Elliott Hughes
73d363bbc1 Merge \"Make klog_fd thread-safe and make klog_init a no-op.\"
am: 588b770063

Change-Id: I884276a8f8b8209f6e956c5fb410e8265184e1b5
2016-07-08 17:05:25 +00:00
Yabin Cui
1b8159e7ab Merge \"init: use libbootloader_message.\" into nyc-mr1-dev
am: ca4cf4e4af

Change-Id: I8234e796a8b35115ef1ecf33c987882f8fe286cd
2016-06-30 22:55:42 +00:00