Commit graph

1474 commits

Author SHA1 Message Date
Tom Cherry
1f49801ab1 Merge "init: handle sys.powerctl immediately" am: 14ed55bae8 am: e6bfb53196
am: 8972f887d2

Change-Id: I3af0841fc3c23e2758ec5f330e9ba03f7695d50f
2017-04-18 18:33:17 +00:00
Tom Cherry
14ed55bae8 Merge "init: handle sys.powerctl immediately" 2017-04-18 18:14:18 +00:00
Tom Cherry
98ad32a967 init: handle sys.powerctl immediately
Currently if a process sets the sys.powerctl property, init adds this
property change into the event queue, just like any other property.
The actual logic to shutdown the device is not executed until init
gets to the action associated with the property change.

This is bad for multiple reasons, but explicitly causes deadlock in
the follow scenario:

A service is started with `exec` or `exec_start`
The same service sets sys.powerctl indicating to the system to
shutdown
The same service then waits infinitely

In this case, init doesn't process any further commands until the exec
service completes, including the command to reboot the device.

This change causes init to immediately handle sys.powerctl and reboot
the device regardless of the state of the event queue, wait for exec,
or wait for property conditions.

Bug: 37209359
Bug: 37415192

Test: Init reboots normally
Test: Update verifier can reboot the system
Change-Id: Iff2295aed970840f47e56c4bacc93001b791fa35
2017-04-17 16:40:06 -07:00
Tom Cherry
c4b1a2f230 Merge "ueventd: create classes for dev and sys permissions" am: ffa38cfc1e am: e29fa61725
am: b7ef4726ff

Change-Id: I2b64de1007adb68ef3364f0ed6bbd51b297d292e
2017-04-17 21:56:27 +00:00
Tom Cherry
cc054c9da8 ueventd: create classes for dev and sys permissions
Create classes for dev and sys permissions and store these permissions
in std::vector instead of the C list.

Test: boot bullhead
Test: init unit tests

Change-Id: I874039a3db29b4c70149506da8e407123ab7eca2
2017-04-17 19:33:04 +00:00
Bowgo Tsai
6e69b2ea2a Merge "Set libavb version into system property for Treble OTA" am: e8311491da am: 7b08869382
am: 6f3ec3d759

Change-Id: I2c97b605e75c479e485ac36e1e90c039467df04e
2017-04-15 06:07:10 +00:00
Bowgo Tsai
1a898c25f9 Set libavb version into system property for Treble OTA
Set ro.boot.avb_version to "AVB_VERSION_MAJOR.AVB_VERSION_MINOR".
During Treble OTA match, the major version must be the same as that in
the avb metadata on disk, while the minor version can be equal or
greater to that in the avb metadata on disk.

See how avb versioning work on the following link:

  https://android-review.googlesource.com/#/c/342757/

Also renames AvbHashtreeDisabled() -> hashtree_disabled().

Bug: 35322304
Test: Early mount with AVB, checks [ro.boot.avb_version]: [1.0] exists.
Test: Not enable AVB, checks [ro.boot.avb_version] doesn't exists.

Change-Id: I5aaf476ca53c4fe817779518ba14b68ebcfdc6d6
2017-04-15 09:47:31 +08:00
Elliott Hughes
77fc053638 Merge "Revert "Send property_service AVC messages to the kernel audit system"" am: eea60804f6 am: aee26df200
am: 246a7e57b8

Change-Id: Ibf1c376d96c1d9000b44b89432d6c959d050309b
2017-04-15 00:29:22 +00:00
Elliott Hughes
eea60804f6 Merge "Revert "Send property_service AVC messages to the kernel audit system"" 2017-04-15 00:13:47 +00:00
Tom Cherry
d374d59c09 Merge changes I9d0482d1,Ib82833be am: b87f1c1728 am: 43473d3a54
am: dfb81ce15a

Change-Id: Iadacb505e72b41ee3845ad48dda192094ca6f53e
2017-04-14 21:56:25 +00:00
Elliott Hughes
d8f9356bec Revert "Send property_service AVC messages to the kernel audit system"
This reverts commit 8adb4d9d12.

Change-Id: I0db29617f323ef31ca5a270d02b7668092e9c9e1
2017-04-14 12:53:19 -07:00
Tom Cherry
1ab8f55344 ueventd: convert platform_names from C list to std::vector
Also simplify this code a bit.

There's only one consumer that removes the /devices/platform prefix,
so have them handle it instead of storing two copies of the string.

Remove an unneeded search for '/' in get_character_device_symlinks()
as a / will always be the next character after a parent path, by
nature of FindPlatformDevice().

Test: boot bullhead
Test: init unit tests

Change-Id: I9d0482d137b1342ae7509ae993ff99198be814f0
2017-04-14 10:23:52 -07:00
Tom Cherry
e3e48214b7 ueventd: replace char* with std::string in struct uevent
Bug: 36250207

Test: Boot bullhead
Test: Boot sailfish, observe no boot time regression
Test: init unit tests

Change-Id: Ib82833bea56bdafbe1d7a045126aaa91a8725d98
2017-04-14 10:23:52 -07:00
Treehugger Robot
e771b69e72 Merge changes I6a29c678,I76212f65
* changes:
  reboot: fix owner and permissions of last_reboot_reason file
  init.rc: create /data/misc/reboot owned by system
2017-04-14 14:16:20 +00:00
Bowgo Tsai
4d70aa5541 Merge changes from topic 'avb-early-mount' am: d7381375bb am: 04989a7a4b
am: 0b2d83a64b

Change-Id: I3911b1be010b7f79f2b3975a9264eb914044392f
2017-04-14 06:40:58 +00:00
Treehugger Robot
d7381375bb Merge changes from topic 'avb-early-mount'
* changes:
  fs_mgr: support AVB in fs_mgr_update_verity_state()
  init: support early_mount with vboot 2.0 (external/avb/libavb)
2017-04-14 06:20:42 +00:00
Bowgo Tsai
aaf70e77dc fs_mgr: support AVB in fs_mgr_update_verity_state()
fs_mgr_update_verity_state() is invoked by 'verity_update_state' in
init.rc. It will then set property "partition.system.verified" and
"partition.vendor.verified" to verify_mode. We should support this for
AVB as well.

Also change the order of static libs in init to fix the build error
after this change:
  system/extras/ext4_utils/ext4_crypt.cpp:69: error: undefined reference to 'property_get'

Bug: 35416769
Test: Mount /system and /vendor with vboot 2.0 (AVB), check the following properties exist.
      - [partition.system.verified]: [2]
      - [partition.vendor.verified]: [2]
Test: Mount /system and /vendor with vboot 1.0, check the following properties exist.
      - [partition.system.verified]: [0]
      - [partition.vendor.verified]: [0]

Change-Id: I4328d66a8cb93f26e7960e620a0b2292d5f15900
2017-04-14 12:10:49 +08:00
Bowgo Tsai
8bba52fc4b init: support early_mount with vboot 2.0 (external/avb/libavb)
libavb requires verifying AVB metadata on all verified partitions at
once. For example, /vbmeta, /boot, /system and /vendor. We need to
invoke device_init() for those partitions even if we only want to early
mount some of them, like /vendor and /system.

This CL gets all AVB partitions and the early mount partitions from
device tree through "firmware/android/vbmeta" and "firmware/fstab",
respectively. The following is an example to early mount /vendor
partition on bullhead:

firmware {
    android {
        compatible = "android,firmware";
        vbmeta {
            compatible = "android,vbmeta";
            parts = "boot,system,vendor";
            by_name_prefix="/dev/block/platform/soc.0/f9824900.sdhci/by-name"
        };
        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,avb";
            };
        };
    };
};

Bug: 33254008
Test: early mount /vendor with vboot 2.0 (AVB) on bullhead
Test: early mount /system without dm-verity on bullhead
Test: early mount /vendor with vboot 1.0 on sailfish

Change-Id: I89a1f77c97124f309346b33d9e700544b92ecf05
2017-04-14 12:10:20 +08:00
Todd Poynor
a03b4dc574 Merge changes I76212f65,I6a29c678 into oc-dev
am: 5975d4e337

Change-Id: I0441dc1f8a9ff11429a253d0510790b20b42e3b4
2017-04-14 01:37:03 +00:00
Todd Poynor
fc827be3f9 reboot: fix owner and permissions of last_reboot_reason file
Default signature WriteStringToFile creates world-writeable files.
Set owner and group system and remove read/write for non-owner.

Bug: 37251463
Test: Manual: reboot, inspect
Change-Id: I6a29c678168dcae611b120dc52170f4eee7069a9
2017-04-13 18:03:59 -07:00
Todd Poynor
dff584659c reboot: fix owner and permissions of last_reboot_reason file
Default signature WriteStringToFile creates world-writeable files.
Set owner and group system and remove read/write for non-owner.

Bug: 37251463
Test: Manual: reboot, inspect
Change-Id: I6a29c678168dcae611b120dc52170f4eee7069a9
2017-04-13 15:48:11 -07:00
Tom Cherry
aa85663027 Merge changes Ie5ec609a,I5a2ac369,I690137b5 am: 659b78ed10 am: 01b87aac9c
am: 8d9eee4f2b

Change-Id: I5cd7d00f71bfd3970189481f381629cedc358c9b
2017-04-13 21:45:58 +00:00
Tom Cherry
659b78ed10 Merge changes Ie5ec609a,I5a2ac369,I690137b5
* changes:
  ueventd: Fix up string handling in handle_*_device_event()
  ueventd: convert mkdir_recursive() to std::string
  ueventd: move subsystem logic from code to ueventd.rc
2017-04-13 21:22:45 +00:00
Jeffrey Vander Stoep
be2bfc55f7 Merge "init: expand generated attributes on sepolicy compile" into oc-dev
am: 57d4c59559

Change-Id: If3230f31ab3d680c411351d61dc68e5963355d33
2017-04-13 18:37:43 +00:00
Jeffrey Vander Stoep
57d4c59559 Merge "init: expand generated attributes on sepolicy compile" into oc-dev 2017-04-13 18:11:08 +00:00
Jeff Vander Stoep
d278253378 init: expand generated attributes on sepolicy compile
Expand auto generated attributes in selinux policy when doing
on-device compile of platform + vendor selinux policy.

Bug: 3650825
Test: Build and boot Marlin
Change-Id: Icc1c3af0b504236ae13fd8a5155c2109befd7688
2017-04-13 17:32:51 +00:00
Martijn Coenen
30ec708335 Merge "restorecon hwservice_contexts." into oc-dev
am: f8952a196c

Change-Id: If828fe3afd399f15fcc351f39dc0cdc7531ed635
2017-04-13 03:43:51 +00:00
Martijn Coenen
f8952a196c Merge "restorecon hwservice_contexts." into oc-dev 2017-04-13 03:34:48 +00:00
Martijn Coenen
6887273a28 restorecon hwservice_contexts.
Test: marlin boots, angler boots
Bug: 34454312
Change-Id: I5da8b0b10a7a4c0e6e0c9aea39004852889e8d97
2017-04-12 18:02:33 -07:00
Dmitri Plotnikov
bcb5e5008c Merge "Passing additional parameter to powerctl" am: e0ab2557d4 am: 0c146e6572
am: cff6544e2e

Change-Id: I6e21babe911996ac0f91e9a61aeb46499c4949c0
2017-04-13 00:52:00 +00:00
Tom Cherry
3fa467338f ueventd: Fix up string handling in handle_*_device_event()
Bug: 36250207

Test: Boot bullhead
Test: Boot sailfish, observe no boot time regression
Test: init unit tests

Change-Id: Ie5ec609a3f74bb03f5920734ada4d7de57508de4
2017-04-12 16:36:53 -07:00
Tom Cherry
060b74baad ueventd: convert mkdir_recursive() to std::string
Bug: 36250207

Test: Boot bullhead
Test: Boot sailfish, observe no boot time regression
Test: init unit tests

Change-Id: I5a2ac369d846e044230b709fd07eb21ad12d47bb
2017-04-12 16:36:44 -07:00
Tom Cherry
780a71e779 ueventd: move subsystem logic from code to ueventd.rc
Test: Boot bullhead
Test: Boot sailfish, observe no boot time regression
Test: init unit tests

Change-Id: I690137b584fcc2b9cd2dd932a2678f75a56d6737
2017-04-12 16:36:20 -07:00
Dmitri Plotnikov
00e1c4f330 Passing additional parameter to powerctl
Test: adb reboot recovery,foo and verify that the parameter reaches bootloader
Change-Id: I9690cf96cf9730e5324b9f5310c3d0341fe25fe2
2017-04-12 14:38:23 -07:00
Dan Cashman
18ff05146f init: use platform sepolicy version indicated by /vendor.
am: 692c3e4d38

Change-Id: I81874aea3896c1156295616f12c211e9423d5ca7
2017-04-12 20:43:31 +00:00
Dan Cashman
692c3e4d38 init: use platform sepolicy version indicated by /vendor.
It's possible, in the event of a platform update, for the platform
SELinux policy to change from the policy on which the vendor SELinux
policy was originally based.  In this case, a different mapping file
to bridge the differences between the new policy and the old needs to
be selected.

Make init choose which mapping policy file to use based on the version
reported in /vendor/etc/selinux/plat_sepolicy_vers.txt.

Bug: 36783775
Test: Force compilation of sepolicy on-device with mapping file changed
to new location and name, using the value reported on /vendor.

Change-Id: I63c883ccb79dd31c92dabe44a55c4ab50a3735e6
2017-04-12 10:45:08 -07:00
Tom Cherry
6289bb1341 Merge "ueventd: remove /dev/log" am: 120add07ab am: 9ae606d659
am: 6c2e8b10fe

Change-Id: Ic257774710a74e72a97f4187e48587150ee3d613
2017-04-12 08:17:29 +00:00
Treehugger Robot
120add07ab Merge "ueventd: remove /dev/log" 2017-04-12 07:58:33 +00:00
Tom Cherry
420a937e3e Merge "ueventd: replace char** links with std::vector<std::string>" am: 162118928e am: a778c81e11
am: ed5f8ca6e9

Change-Id: Ie64fbebc87bd419f9aba5655a5c223d08b0424e9
2017-04-12 01:15:46 +00:00
Treehugger Robot
162118928e Merge "ueventd: replace char** links with std::vector<std::string>" 2017-04-12 00:57:35 +00:00
Tom Cherry
d4ff8d83d3 ueventd: remove /dev/log
This was marked deprecated in 2014 and removed in 2015, let's remove
the uevent rule now too.

Test: see that logging still works on bullhead
Change-Id: Idaf3f49a1afe7046eba6c976628b9f1c8b3ec094
2017-04-11 21:35:46 +00:00
Keun-young Park
ae56bc7efa Merge "poll umount completion from /proc/mounts" am: 625a098573 am: cb4dadfb08
am: 4c44243c45

Change-Id: Iee3fac59672d5f7f6bfdad35e374fec3f5a29f29
2017-04-11 01:04:55 +00:00
Keun-young Park
0e90dee9e0 poll umount completion from /proc/mounts
- umount operation is asynchronous except for root partition.
  Returning from umount does not guarantee completion of
  umount. Poll /proc/mounts to confirm completion of umount.
- Treat all devices mounting to /data as emulated devices. This is
  future proof when fs other than sdcardfs is used.
- Drop quota sync from sync step. There is no differences in
  frequencies of quota error.
- Run umount in reverse order from mounting order so that any
  hidden dependency can be auto-resolved.
- Add dump of lsof and /proc/mounts when umount fails. lsof only runs
  when selinux is toggled into permissive mode. The dump is enabled
  only for non-user build.
- Keep logcat until vold shutdown in case vold has any error to report.

bug: 36551218
Test: python packages/services/Car/tools/bootanalyze/bootanalyze.py -r -c packages/services/Car/tools/bootanalyze/config.yaml -n 1000 -f -e 20 -w 30

Change-Id: I87b17b966d7004c205452d81460b02c6acf50d45
(cherry picked from commit 2ba5c8103d)
2017-04-10 17:48:19 -07:00
Keun-young Park
2ba5c8103d poll umount completion from /proc/mounts
- umount operation is asynchronous except for root partition.
  Returning from umount does not guarantee completion of
  umount. Poll /proc/mounts to confirm completion of umount.
- Treat all devices mounting to /data as emulated devices. This is
  future proof when fs other than sdcardfs is used.
- Drop quota sync from sync step. There is no differences in
  frequencies of quota error.
- Run umount in reverse order from mounting order so that any
  hidden dependency can be auto-resolved.
- Add dump of lsof and /proc/mounts when umount fails. lsof only runs
  when selinux is toggled into permissive mode. The dump is enabled
  only for non-user build.
- Keep logcat until vold shutdown in case vold has any error to report.

bug: 36551218
Test: python packages/services/Car/tools/bootanalyze/bootanalyze.py -r -c packages/services/Car/tools/bootanalyze/config.yaml -n 1000 -f -e 20 -w 30

Change-Id: I87b17b966d7004c205452d81460b02c6acf50d45
2017-04-10 15:41:15 -07:00
Josh Gao
a0ff3d7b6b Merge "crash_dump: during early boot, output to kmsg on userdebug." am: 72ca48e5cb am: 35b7a274ac
am: e80f6668f5

Change-Id: Ic9b44bd3cf50240c1f34edb8aa35a821a75e202c
2017-04-10 21:13:05 +00:00
Josh Gao
72ca48e5cb Merge "crash_dump: during early boot, output to kmsg on userdebug." 2017-04-10 20:51:59 +00:00
Tom Cherry
2e344f9d22 ueventd: replace char** links with std::vector<std::string>
Additionally replace the associated C string parsing with C++ and write
unit tests.

Bug: 33785894
Bug: 36250207
Test: Boot bullhead + unit tests
Change-Id: Iee1f72d248bca3bd2e1227045628935b3dd6195a
2017-04-08 00:05:50 +00:00
Tom Cherry
7dd593a887 Merge "init: clean up more headers" am: 4f6feec25b am: a7d0718907
am: 99b26e5ab1

Change-Id: I6cfffc3c756dd02263adfe1aac1456a70d76ce03
2017-04-07 23:14:51 +00:00
Treehugger Robot
4f6feec25b Merge "init: clean up more headers" 2017-04-07 22:56:32 +00:00
Tom Cherry
f57c0bfab2 init: clean up more headers
We don't need everyone including <sys/system_properties.h>

Test: boot bullhead
Change-Id: I73d507e4f273678eaf15947725741e1e3b966cc6
2017-04-07 13:49:12 -07:00