Commit graph

2636 commits

Author SHA1 Message Date
Treehugger Robot
60fc999722 Merge "init: Remove the obsolete restorecon for /sbin files." 2019-01-18 19:35:26 +00:00
Jiyong Park
60b89aee4c Revert "Identify post-apexd crashing processes"
This reverts commit c661b660fe.
Reason: Breaks some 3p apps.

Bug: 122920047
Test: run the app, login.
Change-Id: Ie56ea5516887b885579764929e82e4fe684a7dcf
2019-01-18 12:30:54 +09:00
Jiyong Park
8b73dfc0a4 Revert "Bionic libs and the dynamic linker are bind mounted"
This reverts commit 2599088ff6.
Reason: Breaks some 3p apps.

Bug: 122920047
Test: run the app, login.
Change-Id: Idea332b1f91e9d2ac6ebd3879da7820c8ba2284f
2019-01-18 12:30:51 +09:00
Jiyong Park
80aec3f0f0 Revert "Don't create separate mount namespaces for pre-apexd processes"
This reverts commit 5ab1300481.

Reason: Breaks some 3p apps.

Bug: 122920047
Test: run the app, login.
Change-Id: Iec3347d7f35fbb6f32fd1192135a0cf87dc123a7
2019-01-18 12:30:39 +09:00
Treehugger Robot
9c334367fd Merge "Re-enable asan on /init." 2019-01-18 01:56:43 +00:00
Tao Bao
a68d8c9ea3 init: Remove the obsolete restorecon for /sbin files.
These files, including their building rules, have been removed in favor
of their dynamically linked versions; we no longer need to explicitly
restorecon the actual files either, for the same reason as in commit
05f96a2561. When doing normal boot, these
files come from system.img, which have been labeled at build time; when
booting recovery, they don't need dedicated labels to be functional.

Test: Build and boot crosshatch.
Test: Factory reset under recovery on taimen (mke2fs).
Test: Factory reset under recovery on crosshatch (make_f2fs).
Change-Id: Icbcd24aad8be1e7f4ba7d379acd5855d256ae106
2019-01-17 14:52:29 -08:00
Treehugger Robot
1945fbef10 Merge "init: dump less debug logs when unmount timeout" 2019-01-17 22:06:50 +00:00
Evgenii Stepanov
dd02fa162d Re-enable asan on /init.
Fixed in the new toolchain.

Bug: 120561310
Test: asan build boots
Change-Id: I722c98467ed0ac5e18441cb659f26cd8a803eee0
2019-01-17 14:05:22 -08:00
Jaegeuk Kim
2fdbdfddac Merge "zram: support zram_writeback" 2019-01-17 21:03:15 +00:00
Jonglin Lee
28a2c9213b init: dump less debug logs when unmount timeout
Dump only uninterruptible tasks instead of all tasks when
unmount timeout. Also dump current CPU stack traces.

Bug: 122858312
Test: Reboot with and without timeout
Change-Id: I1412ace022b6d78e25fbe1337d1082d4be9c19c0
2019-01-17 19:14:46 +00:00
David Anderson
b43440ba79 Merge "init: Add support for GSI installations in first-stage mount." 2019-01-17 18:42:58 +00:00
David Anderson
0e330f12bc init: Add support for GSI installations in first-stage mount.
Bug: 121209697
Test: gsi boots
Change-Id: I69db0f8e999da366e46728b1008602f543cd79f6
2019-01-16 17:45:07 -08:00
Randall Huang
df2faa4238 reboot: only run fsck when detecting filesystem inconsistency
Running fsck when filesystem is in clean state is unnecessary
and causes long shutdown duration.

Bug: 120575926
Test: shutdown
Change-Id: I0562bdad4ac2fb2dd3c9617f96ca3d6279876bd8
Signed-off-by: Randall Huang <huangrandall@google.com>
2019-01-16 16:19:24 +08:00
Jaegeuk Kim
2aedc82f02 zram: support zram_writeback
This patch supports zram_writeback enabled by fstab in two ways.

e.g.,
/dev/block/zram0 none swap defaults
    zramsize=1073741824,max_comp_streams=8,zram_loopback_path=/data/unencrypted/zram_swap

==> loopback size is 512MB by default.

Or,
/dev/block/zram0 none swap defaults
    zramsize=1073741824,max_comp_streams=8,zram_loopback_path=/data/unencrypted/zram_swap,zram_loopback_size=1G

==> loopback size can be specified by "zram_loopback_size=%s" with "GB" or "MB".

Or,
/dev/block/zram0 none swap defaults
    zramsize=1073741824,max_comp_streams=8,zram_backing_dev_path=/dev/block/partition

Bug: 74582279
Bug: 122659265
Change-Id: I66a2e6953b4743a34cf732dd0f5b5256c901f247
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2019-01-15 16:07:59 +00:00
Jiyong Park
3b316ee201 Load build sysprops early
*/build.prop files are now loaded much earlier than before; from 'on
post-fs' to the time when the property service is started which is
before init starts the action loop.

This ensures that all processes that are launched by init have a
consistent view of system properties. Previously, the processes that
started before 'on post-fs' were initially with the small number of
sysprops loaded from */default.prop and then suddenly get additional
sysprops from */build.prop while they are executing.

Bug: 122714998
Test: device boots

Change-Id: Ic07528421dfbe8d4f43673cea41175d33cfbf298
2019-01-15 22:40:49 +09:00
Zimuzo Ezeozue
91fa140312 Merge "Identify post-apexd crashing processes" 2019-01-15 10:05:41 +00:00
Steven Moreland
ebae0d3ad9 Merge "Init: error on oneway calls." 2019-01-14 20:50:12 +00:00
Zimuzo
c661b660fe Identify post-apexd crashing processes
I7d47ea1223f7792a834981c729694242ab3f28c9 tried to identify processes that crash
after apexd is ready by introducing an 'updatable' class. However, after
I7ca67755dc0656c0f0c834ba94bf23ba9b1aca68 we now have a pre_apexd_ field we can
reuse instead of introducing a new class type.

Bug: 120598832
Test: Killing a !pre_apexd_ process 4 times in 4mins sets the
ro.init.updatable.crashing prop while killing a pre_apexd_ process reboots
into the bootloader

Change-Id: Icb9f405b9b54d11546bbf6d3bc28212936a78b0e
2019-01-14 16:22:10 +00:00
Steven Moreland
dc1f24777a Init: error on oneway calls.
Before, this process had no threadpool, so it could make blocking
calls, but if it did, they would block forever. Now when this
happens, an error is logged so that we can easily see this happen.

Bug: 36424585
Test: boot
Change-Id: I7d2fa12b6d5a243bdde13ce4d974a444133749f7
2019-01-11 14:41:34 -08:00
Jiyong Park
5ab1300481 Don't create separate mount namespaces for pre-apexd processes
It is causing problem to the sdcardfs. Specifically, re-mounting events
for /mnt/runtime/{runtime|write} done by the vold process (which is a
pre-apexd process) are not being propagated to other mount namespaces.
As a result, SDCard access isn't working.

The propagation problem is a bug in sdcardfs which is fixed by [1].
However, we can't make all Android devices to have the patch at the same
time. Therefore, by default the separate mount namespace is not created
and will be created only for the devices where the kernel patches are in and
ro.apex.bionic_updatable sysprop is set to true.

[1]
d73d07673edbdbe78e1a7d00e7827ba9bfd86a59 ("ANDROID: mnt: Fix next_descendent")
b5858221c1c4f4bdc9ef67eb75ecf22580368820 ("ANDROID: mnt: remount should propagate to slaves of slaves")

Bug: 122559956
Test: m
Test: device boots
Test: sdcard works (e.g. camera can take pictures)
Test: atest android.appsecurity.cts.ExternalStorageHostTest
Change-Id: I7a309bab46356ee5782f34c5963d1760963c0b14
2019-01-11 15:17:04 +09:00
Jiyong Park
2599088ff6 Bionic libs and the dynamic linker are bind mounted
This change makes the bionic libs and the dynamic linker from the
runtime APEX (com.android.runtime) available to all processes started
after apexd finishes activating APEXes.

Specifically, the device has two sets of bionic libs and the dynamic
linker: one in the system partition for pre-apexd processes and another
in the runtime APEX for post-apexd processes. The former is referred as
the 'bootstrap' bionic and are located at
/system/lib/{libc|libdl|libm}.so and /system/bin/linker. The latter is
referred as the 'runtime' bionic and are located at
/apex/com.android.runtime/lib/bionic/{libc|libdl|libm}.so and
/apex/com.android.runtime/bin/linker.

Although the two sets are located in different directories, at runtime,
they are accessed via the same path: /system/lib/* and
/system/bin/linker ... for both pre/post-apexd processes. This is done
by bind-mounting the bootstrap or the runtime bionic to the same path.
Keeping the same path is necessary because there are many modules and
apps that explicitly or implicitly depend on the fact that bionic libs
are located in /system/lib and are loaded into the default linker
namespace (which has /system/lib in its search paths).

Before the apexd is started, init executes a built-in action
'prepare_bootstrap_bionic' that bind-mounts the bootstrap bionic to the
mount points. Processes started during this time are provided with the
bootstrap bionic. Then after the apexd is finished, init executes
another built-in action 'setup_runtime_bionic' which again mounts the
runtime bionic to the same mount points, thus hiding the previous mounts
that target the bootstrap bionic. The mounting of the runtime bionic
(which is only for post-apexd processes) is hidden from pre-apexd
processes by changing propagation type of the mount points to 'private'
and execute the pre-apexd processes with a new mount namespace using
unshare(2). If a pre-apexd process crashes and re-launched after the
apexd is on, the process still gets the bootstrap bionic by unmounting
the runtime bionic which effectively un-hides the previous bind-mounts
targeting the bootstrap bionic.

Bug: 120266448
Test: device boots
Test: cat /proc/`pidof zygote`/mountinfo shows that
/system/lib/{libc|libdl|libm}.so and /system/bin/linker are from the
runtime APEX
Test: cat /proc/'pidof vold`/mountinfo shows that the same mount points
are from system partition.

Change-Id: I7ca67755dc0656c0f0c834ba94bf23ba9b1aca68
2019-01-11 15:17:04 +09:00
Treehugger Robot
89e2aa94b7 Merge "Add conditional class starting" 2019-01-11 00:58:18 +00:00
Tom Cherry
82b8e518e3 Merge "Support mounting same mount points with different fstab config" 2019-01-10 23:36:16 +00:00
Tom Cherry
2f171cc69e Merge "init: remove the restriction of arguments" 2019-01-10 18:47:53 +00:00
Tri Vo
b5b7d0a777 Merge "init: don't restorecon root sepolicy files" 2019-01-10 17:38:15 +00:00
LongPing Wei
01cf85bd8e Support mounting same mount points with different fstab config
This commits allows multiple lines in a fstab have the same mount
point for first-stage mount, where the first successful mount will be
used.

This allows us to specify a common/shared fstab, with different
settings (e.g., ext4, squashfs) per line, to mount different types
of images on the same mount point. e.g., allows the device to mount
GSI (ext4) while support mounting the original squashfs system.img.

Sample fstab:
fstab in dt:
android {
    fstab {
        odm_ext4 {
            dev = "/dev/block/by-name/odm";
            mnt_point = "/odm";
            type = ext4;
            mnt_flags = "ro";
            fs_mgr_flags = "slotselect";
        };
        odm_f2fs {
            dev = "/dev/block/by-name/odm";
            mnt_point = "/odm";
            type = f2fs;
            mnt_flags = "ro";
            fs_mgr_flags = "slotselect";
        };
    };
}

fstab in file:
/dev/block/by-name/odm /odm ext4 ro slotselect
/dev/block/by-name/odm /odm f2fs ro slotselect

Test: make & boot & check /proc/mounts
Change-Id: I64892e3007b0cfd7d06dad1cfc664c45305197ee
2019-01-10 22:58:18 +08:00
Haoyu Tang
f32bc7cd29 init: remove the restriction of arguments
X86 Kernel could pass CPU capablity to init as argument. This will cause init
can't start first-stage because unknown argument. Need remove this restriction
of arguments to start init successfully.

Fixes: 122435289
Test: Android init can start successfully

Change-Id: I1d432e25553589dd7f618e42ad238b9372dbe34f
Signed-off-by: Haoyu Tang <haoyu.tang@intel.com>
Signed-off-by: Xihua Chen <xihua.chen@intel.com>
2019-01-10 01:02:29 +00:00
Tri Vo
05f96a2561 init: don't restorecon root sepolicy files
Removing restorecon on root sepolicy files because:
1. Under normal boot the files are properly labeled when creating the
image. Restorecon'ing them successfully would require "adb remount".
2. These restorecon's are not required for recovery to function.

Fixes: 122535196
Test: boot blueline
Change-Id: I20b127e950b16535d4bfa9fd4e626e11228925e7
2019-01-10 00:50:43 +00:00
Daniel Rosenberg
ca00b0edeb Add conditional class starting
This adds the ability to prevent a class from starting
if a certain persistent property has been set to
disallow it.

A class will only load if there is not a property named
persist.init.dont_start_class.[class name] set to 1.

Test: Set a property called persist.dont_start_class.[class]
      to 1. Verify that the given class does not start
Change-Id: I51c70ad635762ed77855d0509e630adb0aec0eb1
2019-01-09 15:18:01 -08:00
Jiyong Park
93318d496c Build init with the bootstrap bionic libs
As bionic libs are moved from /system to the runtime APEX, anything that
is outside of the runtime APEX cannot use private symbols from the
bionic libs.

init is not included in the runtime APEX but is using private bionic
APIs: __system_property_[add|area_init|update|...]. So, it was required
to publicize the private symbols for init.

However, since init is started before the runtime APEX is activated, it
actually cannot use the bionic libs from the runtime APEX, but will use
the bootstrap bionic libs left in /system/bootstrap/lib[64]. Because
init and the bootstrap libs are in the same partition, init doesn't need
to link against the stubs of bionic libs. In order to make this
possible, the new property 'bootstrap' is set to true allow init to use
the bootstrap bionic.

Bug: 120266448
Test: m with https://android-review.googlesource.com/c/platform/bionic/+/849044

Change-Id: If61f25faf9aed4968bf2922859ceb94276ba03fb
2019-01-09 20:41:41 +09:00
Treehugger Robot
97212d36da Merge "Set system property if 'updatable' process crashes too frequently" 2019-01-07 23:55:25 +00:00
Zimuzo
c55a8c6afb Set system property if 'updatable' process crashes too frequently
Critical processes currently cause the device to reboot into recovery when they
crash 4 times in 4mins.

We extend this feature to a new 'updatable' class of init services.
If these services crash 4 times in 4mins, instead of rebooting into bootloader,
we set ro.init.updatable_crashing to '1'. apexd and update_verifier will
listen to that property and try to abort and rollback updates, staged apex
modules and new slots respectively.

Test: Tested manually by marking zygote as updatable and killing zygote
frequently, verified that property is set.
Bug: 120598832
Change-Id: I7d47ea1223f7792a834981c729694242ab3f28c9
2019-01-07 19:26:10 +00:00
Tom Cherry
9a9a4ad84c Merge "ueventd: create a /dev/block/by-name/ symlink without a partition name" 2019-01-05 01:06:16 +00:00
Tom Cherry
a961611a99 init: document the early init boot phase
With all of the changes made to the early init boot phase, the
README.md needs updating for future referencing.

Test: none

Change-Id: Ia572577c683add449a4e091ffd4d1597682e9325
2018-12-27 12:51:32 -08:00
Tom Cherry
2c56d7cdda ueventd: create a /dev/block/by-name/ symlink without a partition name
Create /dev/block/by-name/<device> symlink for block devices that are
boot devices but do not have a partition name given.

Test: boot normally
Change-Id: I8c100b0d30dce02a2dd31aebcfea538b8eed9b19
2018-12-21 09:27:38 -08:00
David Anderson
a1bb982c01 init: Don't fail first stage mount for formattable partitions.
If a partition can be formatted by vold, then it doesn't make sense to
have first-stage mount fail if the partition hasn't been formatted yet.

Bug: 121209697
Test: device boots after fastboot flashall -w
Change-Id: I4a6c794a9912a5e0794983e9514a08f9c23e6ae9
2018-12-20 16:30:40 -08:00
Tri Vo
96b8ce7228 Merge "init: support loading /product/etc/selinux/product_sepolicy.cil" 2018-12-18 21:13:27 +00:00
Tri Vo
d3518cf4c8 init: support loading /product/etc/selinux/product_sepolicy.cil
Bug: 119305624
Test: boot aosp_taimen with product_sepolicy.cil
Change-Id: I2124275de7ffc0058c48f5d5ef16644d5d39da3b
2018-12-14 15:45:16 -08:00
Bowgo Tsai
1f4b4f99ca Allow init to skip mounting /product and /product_services
mainline-core is still in the progress of defining interfaces between
/system, /product, /product_services. Before that was completely done,
just updating /system to GSI usually couldn't boot a device.

Therefore, this CL allows GSI to specify a config file, telling init
not to mount /product and /product_services. And fallback to
/system/product and /system/product_services in the GSI.

Bug: 120208657
Test: boots a device with /system/etc/init/config/skip_mount.cfg and
      checks both /product and /product_services are not mounted.

Change-Id: Ibe2abad30b178a6e552fb21e4b30207fc3ef5523
2018-12-14 21:35:25 +08:00
Tom Cherry
de545a4bb3 Allow specifying vbmeta/parts via fstab
We want to move all information required for first stage mount into
the first stage ramdisk instead of using device tree.  A previous
change allowed reading the fstab from the first stage ramdisk, but
'vbmeta/parts' was still in device tree.  This change allows
specifying the required vbmeta/parts information in the fstab.

The new syntax is that instead of simply specifying 'avb' as an fs_mgr
option, a partition may specify 'avb=<vbmeta partition name>' and that
vbmeta partition will also be initialized by first stage init before
attempting to mount any devices.

Bug: 117933812
Test: boot crosshatch without device tree fstab
Change-Id: Ida1a6da988c10d364b3ccdaa6c5d63e5264d1b27
2018-12-12 13:58:44 -08:00
Tom Cherry
23319ebebf Start using new C++ Fstab class widely
Bug: 62292478
Test: boot
Test: adb-remount-test.sh

Change-Id: Id4715af4c1f03e2cfc67de92d3ea58e933685e51
2018-12-12 17:08:09 +00:00
Tom Cherry
ac1812ddb5 Merge "Update fs_mgr_update_verity_state() for new C++ Fstab" 2018-12-10 17:17:28 +00:00
Tom Cherry
02eff5cccd Update fs_mgr_update_verity_state() for new C++ Fstab
Bug: 62292478
Test: boot and check verity state
Change-Id: I4912a16ada9a6d72480d7ac905654b764c5d18b6
2018-12-07 14:14:54 -08:00
Tom Cherry
e29101077c ueventd: allow configuring SO_RCVBUF(FORCE) for the ueventd socket
Some configurations won't allow ueventd to have CAP_NET_ADMIN, so the
new default size of 16M is not possible for those.  Those
configurations also won't need such a large buffer size, so this
change allows devices to customize the SO_RCVBUF(FORCE) size for the
uevent socket.

This is done by adding the line 'uevent_socket_rcvbuf_size <size>' to
your device's ueventd.rc file.  <size> is specified as a byte count,
for example '16M' is 16MiB.

The last parsed uevent_socket_rcvbuf_size line is the one that is
used.

Bug: 120485624
Test: boot sailfish
Test: ueventd unit tests
Change-Id: If8123b92ca8a9b089ad50318caada2f21bc94707
2018-12-06 13:35:52 -08:00
Tom Cherry
05735591f8 Merge "init: disable asan" 2018-12-06 03:14:58 +00:00
Tom Cherry
c12e205ec5 Fix /init -> /system/bin/init symlink creation race
A symlink for TARGET_ROOT_OUT as a post install command of a package
that is also installed to TARGET_ROOT_OUT.  We hijack init.rc which
satisfies this requirement for this symlink.

Bug: 120402274
Bug: 120460755
Bug: 120509320
Bug: 120554662
Test: symlink is created
Test: make bootimage && ls -la $OUT/root/init
Change-Id: I6f1ac06ef152c36d7d7db4618d49a008338da39b
2018-12-05 23:42:07 +00:00
Tom Cherry
f8315f073f init: disable asan
Asan requires /proc to be mounted, which means it fundamentally cannot
be used with first stage init.  Given that second stage init now
contains the logic for first stage init, asan must be disabled on all
of init until this can be resolved.

Bug: 120424438
Bug: 120561310
Test: Asan builds boot
Change-Id: I24d1a0c8ecb5eb3f77435e6e36432c7b4cb97c6a
2018-12-05 13:52:42 -08:00
Tom Cherry
e1e71b9b98 Merge "init: allow first stage mount to read an fstab" 2018-12-05 20:32:08 +00:00
Alistair Strachan
5d55580fe1 Merge "Handle renamed "super" device correctly" 2018-12-05 00:06:41 +00:00
Alistair Strachan
1906d5f357 Handle renamed "super" device correctly
In the non-retrofit case, the metadata source partition will be
hardcoded as "super", but such a partition may not exist or may have
been overridden by super_partition=<something>. Make this work reliably
by plumbing the resolved metadata block device through, and using it any
time a partition called "super" is requested.

This also fixes a case in the first_stage_mount code that assumed that
detected a non-A/B, non-retrofit case by assuming the metadata source
partition would be called "super".

Bug: 113175337
Test: boot test on cuttlefish
Change-Id: I8ce1defb902e257eeb7170d697b378eba31faee3
2018-12-04 11:21:34 -08:00