Commit graph

1351 commits

Author SHA1 Message Date
Alex Klyubin
753cc4d810 Merge "Include correct type of SELinux policy" am: 0ab93fdf3a am: 18a826024b
am: b049bdc72a

Change-Id: I5a4b6bb22a62ca8bff45ac81b116ae2fe7896613
2017-03-03 04:02:17 +00:00
Treehugger Robot
0ab93fdf3a Merge "Include correct type of SELinux policy" 2017-03-03 03:50:49 +00:00
Keun-young Park
5e0a9a37ff Merge "use ro.persistent_properties.ready for persistent props ready" am: 22cc398d76 am: 37bdcfcbdb
am: 6ca378ba56

Change-Id: I46264839055316ee88decfd6081e6548557bd3e6
2017-03-02 22:48:52 +00:00
Keun-young Park
22cc398d76 Merge "use ro.persistent_properties.ready for persistent props ready" 2017-03-02 22:41:30 +00:00
Alex Klyubin
b51f9abf45 Include correct type of SELinux policy
This makes the build system include split SELinux policy (three CIL
files and the secilc compiler needed to compile them) if
PRODUCT_FULL_TREBLE is set to true. Otherwise, the monolitic SELinux
policy is included.

Split policy currently adds around 400 ms to boot time (measured on
marlin/sailfish and bullhead) because the policy needs to be compiled
during boot. This is the main reason why we include split policy only
on devices which require it.

Test: Device boots, no additional SELinux denials. This test is
      performed on a device with PRODUCT_FULL_TREBLE set to true, and
      on a device with PRODUCT_FULL_TREBLE set to false.
Test: Device with PRODUCT_FULL_TREBLE set to true contains secilc and
      the three *.cil files, but does not contain the sepolicy file.
      Device with PRODUCT_FULL_TREBLE set to false contains sepolicy
      file but does not contain the secilc file or any *.cil files.
Bug: 31363362

Change-Id: I419aa35bad6efbc7f936bddbdc776de5633846fc
2017-03-02 13:25:17 -08:00
Alex Klyubin
e310332227 Merge "Use split SELinux policy at boot, if available" am: 056eca201b am: a3ccbe6abc
am: 9000f0f868

Change-Id: Ic04767bd6ad22abe98556f0da17c7d820f9ae61c
2017-03-02 01:18:23 +00:00
Treehugger Robot
056eca201b Merge "Use split SELinux policy at boot, if available" 2017-03-02 01:02:15 +00:00
Keun-young Park
404906d59a use ro.persistent_properties.ready for persistent props ready
- for security reason, only notify ready state instead of
   passing time info to hidl clients

Bug: 35178781
Bug: 34274385
Test: reboot

Change-Id: I2d64bd6da81139945bd0224079af9376f1d90da7
2017-03-01 23:16:10 +00:00
Alex Klyubin
16696e201b Use split SELinux policy at boot, if available
This modifies init's loading of SELinux policy into the kernel to
load the split (platform/system vs non-platform/vendor) policy if it's
present. If the split policy is not present, the usual monolithic
policy is loaded into the kernel, same as before.

Split policy is loaded by first compiling it from CIL form using
secilc compiler into the conventional monolithic/compiled form which
is then loaded into the kernel.

The build system has not yet been modified to place split policy onto
devices. Thus, this commit currently has no effect. For testing split
policy, build plat_sepolicy.cil, nonplat_sepolicy.cil, and
mapping_sepolicy.cil, and place them into the root directory of the
device.

The following tests were performed for a device with monolithic policy
and for the same device with split policy.

Test: Device boots, no new denials
Test: Play Movies plays back movies
Test: Load ip6.me im Chrome
Bug: 31363362
Change-Id: I9a75a48ac88f3392abc36669f91b0803e88cd147
2017-03-01 14:07:40 -08:00
Bowgo Tsai
9cce616cea Merge "init: skip early mount in recovery mode" am: 8951c1313d am: 6befc485c7
am: f00d05610b

Change-Id: I8a7dd60f99cfcda88b01892c129af24e3f61a3aa
2017-03-01 18:36:48 +00:00
Bowgo Tsai
32232724fb init: skip early mount in recovery mode
We don't need early mount in recovery mode for security considerations,
e.g., users should explicitly select 'mount /system' from the recovery
menu. This CL checks the existence of file "/sbin/recovery" and skip
early mount when it is found.

Bug: 35853576
Test: early mount /vendor without dm-verity on sailfish
Test: early mount not happen in recovery mode on sailfish
Change-Id: I69cc96f6fd0de6ce493082921738a958dd571115
2017-03-02 00:30:58 +08:00
Elliott Hughes
b161357b1f Merge "There's no longer a limit to property names." am: b6cb9b0457 am: 734aacf679
am: fc41c88f26

Change-Id: I10b43a27c25cb917736a99877212ec180577d332
2017-03-01 00:10:42 +00:00
Treehugger Robot
b6cb9b0457 Merge "There's no longer a limit to property names." 2017-03-01 00:03:58 +00:00
Keun-young Park
534aa7adab Merge "set ro.boottime.persistent_properties when persisted props are restored" am: 73c6544b08 am: bba9f8a9b2
am: 78a2947a64

Change-Id: I05af48cb79b3eaf9656302c8cdc6b94094b34655
2017-02-28 22:46:38 +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
Bowgo Tsai
d11734e54c Merge "init: early_mount: removing hard-coded paths" am: f719c255fa am: 0d0519c98c
am: cd91377253

Change-Id: I1c5046b384ff5f1022e523dde95903878d33f83c
2017-02-28 01:39:10 +00: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
ef99ced7f8 Merge "Treblize init.rc location" am: 76e9a180a8 am: 9afcdc825d
am: 19e3517a91

Change-Id: If71b2951ff92f83c61c175a03923085c0ea38edd
2017-02-25 02:55:57 +00: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
Sandeep Patil
72b689bf34 Merge changes from topic 'early-mount-verity' am: 93072f2ce3 am: 2eb715d866
am: d93e05052a

Change-Id: I014d926e0bf7f560b7fbfa32f11b078dc7b6edc4
2017-02-24 02:23:54 +00: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
Tom Cherry
db3a4c748a Merge "Check setegid() return values" am: 0d24c8f852 am: fb13dab611
am: 5de0f0ea41

Change-Id: Id04b1cddd4baa137527dd2d50189f01a89a2f646
2017-02-24 01:04:49 +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
Sandeep Patil
bb5a8380b0 Merge changes from topic 'early-mount-support' am: 4bd3facbb1 am: e0d7b830f0
am: 5f08cb2aea

Change-Id: I40a70549a545d9d1dd4f007f5fd259102785412c
2017-02-23 07:23:37 +00: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
fa5b4577cb Merge "Address property service DoS." am: 8d302763ab am: 811971d949
am: 6aaa953ddb

Change-Id: I38d680ccfe949582e3d5b25f5f7e7d53843817ad
2017-02-23 02:37:17 +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
Bin Chen
6fe26a65bd Merge "init: minor fix to READEME.md" am: a20c678d45 am: 9fc353f608
am: fd6496fbeb

Change-Id: I34b6be85b4040adcf9091010fc7cf15e45d6b511
2017-02-22 00:33:14 +00: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
8dcf9bb29b Merge "Set libavb version into system property for Treble OTA" am: b47a22337b am: bfe7cf0e88 am: e8a04c4657
am: 9de7214703

Change-Id: I9d17be858ed8ff66c5b3144ae1d16ab618ffd92a
2017-02-16 10:30:35 +00: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
Sandeep Patil
1ccb3b0050 Merge changes from topic 'pre-early-mount' am: 1549257ff5 am: c027aac7c8 am: 9e140bb206
am: 7f9c89ffcb

Change-Id: Ie4531a9e4457110d3e496bb3ba1b267c211ce5ef
2017-02-14 20:44:26 +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
872a8d6298 Merge "Revert "bootstat: Refactor init/utils/boot_clock into base/chrono_utils."" am: 91cf0bd5c0 am: a967cf817a am: be6efcb5bb
am: 0e690dbed2

Change-Id: If526cb07fe147f64014ab107ff99c031ab310d83
2017-02-14 19:39:49 +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
ad45ace145 Merge "bootstat: Refactor init/utils/boot_clock into base/chrono_utils." am: e968b73e19 am: 07af328555 am: fe65699408
am: 9a7ff0e111

Change-Id: I4a88ecf56b82cbdbe1ab019a2e1cc7c2ab7e9122
2017-02-14 19:10:51 +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
Jorge Lucangeli Obes
b3cd3574ec Merge "Add a sample service for testing init." am: d7b5c7b2da am: 41aa8f07b2 am: 7fec45ee32
am: df6494f050

Change-Id: I7be6b059e1b14acbc7a11b2e51d976c3216a3099
2017-02-10 01:48:28 +00: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