Commit graph

2322 commits

Author SHA1 Message Date
Bowgo Tsai
b1b8dac123 Merge "Adds /dev/block/by-name/<partition> symlinks" am: 98214c81d1
am: d91d5ecd8b

Change-Id: Id5e75503a0fcc0df1e823d02fefb6e05db5de154
2018-05-18 19:02:55 -07:00
Treehugger Robot
98214c81d1 Merge "Adds /dev/block/by-name/<partition> symlinks" 2018-05-19 01:45:21 +00:00
Tom Cherry
4be0c5a21a Merge "init: allow entering of network namespaces" am: 4bfbd8e9a5
am: e2f95984ba

Change-Id: I72f49a3dcd0175fa4a2f0cf363a99846bdacc4b2
2018-05-18 17:36:56 -07:00
Tom Cherry
4bfbd8e9a5 Merge "init: allow entering of network namespaces" 2018-05-19 00:22:58 +00:00
Tom Cherry
aead51b418 init: allow entering of network namespaces
Add the ability to enter a network namespace when launching a service.
Typical usage of this would be something similar to the below:

on fs
  exec ip netns add namespace_name

service vendor_something /vendor/...
  capabilities <lower than root>
  user not_root
  enter_namespace net /mnt/.../namespace_name

Note changes to the `ip` tool are needed to create the namespace in
the correct directory.

Bug: 73334854
Test: not yet
Change-Id: Ifa91c873d36d69db399bb9c04ff2362518a0b07d
2018-05-18 17:19:36 -07:00
Bowgo Tsai
8eec38f4e4 Adds /dev/block/by-name/<partition> symlinks
During uevent processing, some "by-name" symlinks will be created.
    /dev/block/<type>/<device>/by-name/<partition>

<type> can be: platform, pci or vbd.
<device> might be: soc.0/f9824900.sdhci, soc.0/f9824900.sdhci, etc.
<partition> might be: system, vendor, system_a, system_b, etc.

e.g., on a non-A/B device:
    /dev/block/platform/soc.0/f9824900.sdhci/by-name/system
    /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor

On a A/B device:
    /dev/block/platform/soc/1da4000.ufshc/by-name/system_a
    /dev/block/platform/soc/1da4000.ufshc/by-name/system_b
    /dev/block/platform/soc/1da4000.ufshc/by-name/vendor_a
    /dev/block/platform/soc/1da4000.ufshc/by-name/vendor_b

However, those symlinks are "device-specific".

This change adds the "generic" symlinks in ueventd, in addition to
the existing symlinks, when the possible "boot devices" are specified
in device tree. e.g.,

    &firmware_android {
	compatible = "android,firmware";
	boot_devices ="soc/1da4000.ufshc,soc.0/f9824900.sdhci";
    }

The following symlinks will then be created on the aforementioned non-A/B
and A/B devices, respectively.

    /dev/block/by-name/system
    /dev/block/by-name/vendor

    /dev/block/by-name/system_a
    /dev/block/by-name/system_b
    /dev/block/by-name/vendor_a
    /dev/block/by-name/vendor_b

Note that both <type> and <device> are skipped in the newly create symlinks.
It assumes there is no more than one devices with the same <partition>,
which is the assumption of current first stage mount flow.

Finally, when 'boot_devices' in DT is absent, it fallbacks to extract
'boot_devices' from fstab settings. e.g., using 'soc/1da4000.ufshc',
'soc.0/f9824900.sdhci' for a fstab with the following content:

   /dev/block/platform/soc/1da4000.ufshc/by-name/system
   /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor

Bug: 78613232
Test: adb shell ls /dev/block/by-name
Change-Id: Iec920b5a72409b6a2bdbeeb290f0a3acd2046b5d
2018-05-19 07:57:35 +08:00
Bowgo Tsai
14c1dea777 Merge "Removing block device by-num symlinks" am: 6aaa3beb39
am: 3a6bf528be

Change-Id: I5cfe9afb233f2b76a5d153d94d40dd992024fbc2
2018-05-17 18:31:30 -07:00
Bowgo Tsai
95591bd00e Removing block device by-num symlinks
The uevent.partition_num easily collides between partitions, for
example:

  Both /dev/block/sda3 and /dev/block/sdd3 will generate the same symlink:
    /dev/block/platform/soc/1da4000.ufshc/by-num/p3

This change remove those by-num symlinks as there seems no effective
user of it.

Bug: 78613232
Test: m init_tests && \
      adb push $OUT/data/nativetest64/init_tests/init_tests /data/. && \
      adb shell /data/init_tests

Change-Id: I8dfa8dc1a2f9fc9296aa30f33e905bf158b501de
2018-05-17 16:29:25 +08:00
David Anderson
b04bc882e6 Merge "init/fs_mgr: prototype first-stage dm-linear support" am: 3e946da535
am: 4bf937157d

Change-Id: I742f493439afa885a54965f3425907fac99253fd
2018-05-15 13:29:01 -07:00
David Anderson
62e5b20b50 init/fs_mgr: prototype first-stage dm-linear support
This adds an API to fs_mgr for reading dm-linear tables out of device trees
and issuing device-mapper ioctls. The device tree code will be
implemented separately. The dm-linear structures in fs_mgr are organized
assuming we may want to pull them from sources other than DT (for
example, text files, binary blobs, or something hardcoded for testing).

File systems which are mounted from these logical partitions have
specific fstab requirements. The block device must be a partition name,
and if Verified Boot is used, that name must match the vbmeta partition name.
Second, the entry must have the "logical" fs_mgr flag. Example fstab
entry:

    vendor  /vendor  ext4  ro  wait,logical

Example fstab entry in device tree:

    vendor {
        compatible = "android,fstab";
        dev = "vendor";
        type = "ext4";
        mnt_flags = "ro";
        fs_mgr_flags = "wait,slotselect,avb,logical";
    };

Bug: 78914864
Test: N/A
Change-Id: I4d8878ea8858f26310119616cadc3ee0dd08566c
2018-05-14 12:43:42 -07:00
Mark Salyzyn
9dd13fa4bb Merge "init: keychord inotify add IN_ONLYDIR" am: c8dd6b74e6
am: 421a05dda4

Change-Id: I9f77324e6ccdf3b67e6779c0a126a3aad9c18fa4
2018-05-14 09:24:52 -07:00
Mark Salyzyn
f187715954 init: keychord inotify add IN_ONLYDIR
some minor cleanup.

Test: manual, boot, check registered chord works
Bug: 64114943
Change-Id: If809075445cfd5b6de0d4debc42cdc9559ddc7c4
2018-05-14 07:18:51 -07:00
Mark Salyzyn
77e59cab82 Merge "init: Add inotify for /dev/input/" am: 7ea8047185
am: 205cf8aefb

Change-Id: Ie108c87d87ee52e83ecaefa042ea9522b1460f35
2018-05-10 13:01:00 -07:00
Mark Salyzyn
44692de855 init: Add inotify for /dev/input/
Since event sources can come and go asynchronously because of delayed
driver instantiation due to initialization or firmware upload, USB
attched devices, kernel module loads, or test automation sources like
monkey, add in inotify on /dev/input/ to support these possibilities.

Test: manual, boot, check registered chord works
Bug: 64114943
Change-Id: Ie598bb6f5bf94b2034ab33cf3be7fa15d3467141
2018-05-10 08:45:24 -07:00
Tom Cherry
ec737fbca3 Merge "Remove unused using statement / host stub" am: 86dade8f6f
am: 841e457494

Change-Id: I1eeefc18fe525dab1e74ba494b5c35650f1f72d7
2018-05-09 17:31:17 -07:00
Treehugger Robot
86dade8f6f Merge "Remove unused using statement / host stub" 2018-05-10 00:07:50 +00:00
Tom Cherry
2fa178a01e Remove unused using statement / host stub
GetIntProperty() isn't used after
Ied46e9346b4ca7931aa4dcf1c9dbc11de0e12d93, so it can be removed.

Test: build
Change-Id: I5736f553db1a615d51b8fe3cbf9b4aee89451076
2018-05-09 15:25:39 -07:00
Steven Moreland
8af3dda509 Merge changes from topic "interface_builtins" am: 4880d44d2a
am: a2404d3029

Change-Id: I6550dc6ae6ec077b7879f1ba640c0f580fd65b63
2018-05-09 12:53:46 -07:00
Steven Moreland
4880d44d2a Merge changes from topic "interface_builtins"
* changes:
  init: ServiceList FindInterface
  builtins: interface_{start, stop, restart}
2018-05-09 19:34:22 +00:00
Mark Salyzyn
e074b8045b Merge changes from topic "b/64114943" am: 98caf20a65
am: 938291c770

Change-Id: I21639c2a682b3005961cba3e342e001ac841e0e5
2018-05-09 10:58:09 -07:00
Steven Moreland
6227e345e7 init: ServiceList FindInterface
FindService can't be used w/ interfaces due
to the fact that multiple interfaces can be
added to any given interface.

Bug: 79418581
Test: boot device, manually use ctl commands
Change-Id: I7c152630462c9b7509473bc190f5b30460fcc2bc
2018-05-08 14:26:44 -07:00
Steven Moreland
612d7a47bd builtins: interface_{start, stop, restart}
e.x.:
interface_start android.hardware.nfc@1.0/default
onrestart interface_restart android.hardware.nfc@1.0/default

Fixes: 79418581
Test: add this to a service, and killing that service, light is restarted
    onrestart interface_restart android.hardware.light@2.0::ILight/default
Change-Id: Ia7ac9380f01038752325cfbe030df1dd4a5665e2
2018-05-08 14:26:22 -07:00
Mark Salyzyn
353bf1f945 init: switch from /dev/keychord to /dev/input/
Replace deprecated /dev/keychord driver with /dev/input/ interface.
Will restrict which nodes are active and relevant, and try to mask
out any unreferenced inputs with EVIOCSMASK if available.

Test: manual, boot, check registered chord works
Bug: 64114943
Change-Id: I2bbf84a6e472d720f02282e10d56795b75ac62d1
2018-05-08 13:19:12 -07:00
Tom Cherry
8ae7375f02 init: use std::function for epoll handling
Also allow unregistering of epoll handlers.

Bug: 64114943
Test: boot
Change-Id: I2abe6a56fd451839931d607dddb91669a7d02ff1
2018-05-08 13:19:12 -07:00
Logan Chien
847ffd6d23 Merge "init: Use sepolicy version instead" am: 751f2fa535
am: 82103ab7d9

Change-Id: I2cf978f20587b7875994777c9154017bf5a3d4aa
2018-05-07 18:57:00 -07:00
Logan Chien
837b2a4c24 init: Use sepolicy version instead
This commit uses vendor sepolicy file version (defined in
`/vendor/etc/selinux/plat_sepolicy_vers.txt`) to determine whether the
source context should be set as `u:r:vendor_init:s0`.

Before this commit, the criterion was `ro.vndk.version` >= 28.  However,
the check in `property_service.cpp` will always be true because
`ro.vndk.version` hasn't been loaded from `/vendor/default.prop`.

Furthermore, under some circumstances, `ro.vndk.version` may be
different from `plat_sepolicy_vers.txt` (e.g. O-MR1 vendor does not
define `ro.vndk.version`).

Bug: 78605339  # high-level bug to combine O-MR1 and P GSI
Bug: 79135481  # the usage of `ro.vndk.version` in init
Test: vts-tradefed run vts -m VtsTrebleVintfTest  # tetheroffload
Change-Id: Ied46e9346b4ca7931aa4dcf1c9dbc11de0e12d93
2018-05-04 15:21:01 +08:00
android-build-prod (mdb)
a27c8ff6fb Merge changes I809d8c2e,I11265375 am: 1d87ffd3f6
am: 8c61bb63c9

Change-Id: I42b39a7516474e8f36eb080a4523498d70fbd6bb
2018-05-03 16:47:24 -07:00
David Anderson
29954f6062 init: refactor first stage to not require fstab
In order to support dm-linear devices, we need an additional first-stage
step to ensure that required devices are created. This must happen before
setting up dm-verity or mounting any first-stage partitions.

This patch refactors FirstStageMount so that having a compatible fstab
is optional. This will let us use InitRequiredDevices on systems that
would not otherwise perform first-stage mounts.

Bug: 78914864
Test: non-AVB devices still boot
Change-Id: I11265375a9900d983da8cabcc77d32c503ded02e
2018-05-02 12:23:15 -07:00
Bowgo Tsai
0537233531 Merge "First-stage mount: avoid triggering a FATAL error" am: 78393951de
am: d8829d7a4f

Change-Id: I4f8c500e04245bf9be3913be5710d47f635b53e0
2018-05-01 19:35:34 -07:00
Bowgo Tsai
8fe363f260 First-stage mount: avoid triggering a FATAL error
Related AOSP changes:
  1. https://android-review.googlesource.com/#/c/platform/system/core/+/405009/
  2. https://android-review.googlesource.com/#/c/platform/system/core/+/532637/

The second CL raises a FATAL error when it detects fstab-dt has no content
during first-stage mount. However, with the first CL, the fstab-dt entry
might be "skipped" when bootloader sets the status property to a value
other than "ok"/"okay". (e.g., to skip mounting /vendor on upgrading
devices which have no vendor partition).

Use LOG(INFO) when there is nothing to mount here. The later stages
should trigger a FATAL error when some important files in those
partitions are not available, e.g., SEPolicy files.

Bug: 78441220
Test: boot a device
Change-Id: Iae2f47d455679298bdb067d96b771a30c1a82e6f
2018-05-01 16:39:36 +08:00
Elliott Hughes
da6a06548a Merge "Add test_suites lines." am: 4e6f3d9603
am: d16019bd7d

Change-Id: Ie9535898e31c62e1baa9c70a7257ab39fcddc93e
2018-04-28 09:14:34 -07:00
Elliott Hughes
40fdf3f4ab Add test_suites lines.
Bug: N/A
Test: builds
Change-Id: Ic5e2b9206bcfcb53c774989013b5db6aab462e42
2018-04-27 16:12:06 -07:00
Steven Moreland
aa5b1b93e8 Merge "init: clarify documentation for disabled" am: 9feca7c249
am: 9261ab0080

Change-Id: I691877348cc5e4702584bda41f3d67fbf4365e8c
2018-04-24 18:16:06 -07:00
Steven Moreland
8cb36868a4 init: clarify documentation for disabled
Services can be started by name or interface name now.

Bug: N/A
Test: N/A
Change-Id: I9fef619e7c27d458193311f7cd7fca4dcf8c8e72
2018-04-24 16:24:58 -07:00
Luis Hector Chavez
4ce56af101 Merge "init: Use android::base::boot_clock instead of /proc/uptime" am: 8e73e6f242
am: c12004dd23

Change-Id: I3a5a13cefa2baadfb50771664727712f9dd5b803
2018-04-19 10:59:22 -07:00
Treehugger Robot
8e73e6f242 Merge "init: Use android::base::boot_clock instead of /proc/uptime" 2018-04-19 17:43:07 +00:00
Paul Crowley
6ed4cd9cde Merge "Set property for metadata encryption on first boot" am: def249956c
am: 533870c48f

Change-Id: Ia1e25e29fdb3196a8c6dafd41271c253bd24ce59
2018-04-18 17:32:09 -07:00
Treehugger Robot
def249956c Merge "Set property for metadata encryption on first boot" 2018-04-19 00:17:42 +00:00
Paul Crowley
e383334457 Set property for metadata encryption on first boot
Bug: 77335096
Test: device boots twice with and without metadata encryption
Change-Id: Iaed78288cb37865ba23833721b73b11414e7e862
2018-04-18 14:42:45 -07:00
Tri Vo
4640149fd5 Merge "Add /mnt/vendor rw mount point for vendor partitions." 2018-04-18 19:32:32 +00:00
Tom Cherry
8ee01a9d76 Merge "init: add sigstop option for debugging services from their start" am: b41879111d
am: f0d28c85b6

Change-Id: If41c3cbbe761642d4138f8a0670191326c66b449
2018-04-18 07:03:36 -07:00
Tom Cherry
b41879111d Merge "init: add sigstop option for debugging services from their start" 2018-04-18 13:51:15 +00:00
Tom Cherry
8f38048f7d init: add sigstop option for debugging services from their start
Test: the examples in README.md
Change-Id: Idb528ea4017f8f4ce62911928c040f4bc558d196
2018-04-17 14:52:49 -07:00
Tri Vo
5026903c7a Merge "Add /mnt/vendor rw mount point for vendor partitions." into pi-dev
am: b35c019d5c

Change-Id: I9541e3e1dcb941d0dd8a8bfcdb8cc637ffecc229
2018-04-17 13:42:12 -07:00
TreeHugger Robot
b35c019d5c Merge "Add /mnt/vendor rw mount point for vendor partitions." into pi-dev 2018-04-17 19:16:55 +00:00
Paul Crowley
08e8aa4e52 Merge "Re-land "If enablefilecrypto or init_user0 fails, reboot into recovery."" am: ca10ecb3ae
am: e72619c947

Change-Id: I739a56c5d1a5508b6ccc45710f4f2bc32fefa86e
2018-04-17 12:14:26 -07:00
Tri Vo
0b66969ba0 Add /mnt/vendor rw mount point for vendor partitions.
Changes to init's behavior during early mount:
1. Mounting of tmpfs on /mnt is moved from init stage to early mount.
2. init creates /mnt/vendor used to mount vendor partitions.
3. If a device tree fstab entry for early mount specifies a mount point
under /mnt/vendor e.g. /mnt/vendor/foo, init will create
/mnt/vendor/foo mount point.

Bug: 64905218
Test: change dt fstab entry to mount persist to /mnt/vendor/persist;
mount point is created correctly, and partition is mounted in early
mount. See go/pag/1069774
Test: device boots with /mnt/vendor and previous contents of /mnt present,
and selinux label "mnt_vendor_file" is applied correctly.
Test: cts-tradefed run commandAndExit cts --skip-all-system-status-check
--primary-abi-only --skip-preconditions -m CtsAppSecurityHostTestCases
-t android.appsecurity.cts.PermissionsHostTest
Change-Id: I3739130739eadf508355c7f2531366fcaed74175
Merged-In: I3739130739eadf508355c7f2531366fcaed74175
(cherry picked from commit b511475664)
2018-04-17 11:19:44 -07:00
Tri Vo
b511475664 Add /mnt/vendor rw mount point for vendor partitions.
Changes to init's behavior during early mount:
1. Mounting of tmpfs on /mnt is moved from init stage to early mount.
2. init creates /mnt/vendor used to mount vendor partitions.
3. If a device tree fstab entry for early mount specifies a mount point
under /mnt/vendor e.g. /mnt/vendor/foo, init will create
/mnt/vendor/foo mount point.

Bug: 64905218
Test: change dt fstab entry to mount persist to /mnt/vendor/persist;
mount point is created correctly, and partition is mounted in early
mount. See go/pag/1069774
Test: device boots with /mnt/vendor and previous contents of /mnt present,
and selinux label "mnt_vendor_file" is applied correctly.
Test: cts-tradefed run commandAndExit cts --skip-all-system-status-check
--primary-abi-only --skip-preconditions -m CtsAppSecurityHostTestCases
-t android.appsecurity.cts.PermissionsHostTest
Change-Id: I3739130739eadf508355c7f2531366fcaed74175
2018-04-17 10:15:07 -07:00
Paul Crowley
c73b21558b Re-land "If enablefilecrypto or init_user0 fails, reboot into recovery."
An earlier such change was reverted in commit e242a97db5.

Bug: 70487538
Test: ensure that angler can boot
Merged-In: Id5f57fce1c9b817a2650e0c848143d8a0d286bf0
Change-Id: Id5f57fce1c9b817a2650e0c848143d8a0d286bf0
2018-04-17 09:03:57 -07:00
Ryan Prichard
bef4ec28c4 Merge "init: use signalfd to catch SIGCHLD" am: 07de83831f
am: 5739bf412f

Change-Id: I5a65a3ec20fd5c14b8cbd5843dabc376124b86b5
2018-04-12 16:07:25 -07:00