Commit graph

2944 commits

Author SHA1 Message Date
Gavin Corkery
8c92256df5 Store userspace reboot info in /metadata
Store pertinent information about userspace reboot events in the case
of failure. This information is any services which failed to stop
cleanly, the output of the default fstab and /proc/mounts, and
a list of mounts which failed to unmount. This information is only
stored as necessary (i.e. mount information will not be stored if
everything unmounted, even if some services failed to stop).

Added new /metadata/userspacereboot directory to persist this
information. Information older than 3 days will be deleted.

Test: adb reboot userspace with sigterm/sigkill timeouts set to
      very low values
Test: Manual test of storing all other information
Bug: 151820675
Change-Id: I6cfbfae92a7fc6f6c984475cad2c50c559924866
2020-08-21 17:32:34 +01:00
Marco Ballesio
fdc03350f4 init.rc: remove initializations to cg2_bpf path
https://r.android.com/c/1324649/5 moves the cgroup folder to its sysfs
path. Directory access rights are defined by kernel code and sepolicy,
so remove the initialization lines from init.rc.

Test: manually booted the device and verified access rights for
/sys/fs/cgroup
Bug: 154548692

Change-Id: I67284dc651ed529cae69e413b66c6e1292a2d970
2020-08-21 09:18:58 -07:00
Marco Ballesio
1c755e22c8 libprocessgroup: switch freezer to cgroup v2
remove cgroup v1 freezer entries from init.rc, add a new cgroup v2
controller and modify plists to properly interact with it.

Bug: 154548692
Test: manually verified the the cgroup v1 freezer controller isn't
created and a new controller for cgroup v2 is created under the correct
sysfs directory.

Change-Id: I1b811300ade486f88fdbd157255a7f37750cc54d
2020-08-20 15:11:41 -07:00
Marco Ballesio
76eca5b4c1 freezer: allow dynamic changes to freezer.state
create new profiles to allowing thawing and freezing back the freezer
cgroup

Bug: 151225245
Test: Manually verified that using the SetTaskProfiles method on the
profiles thaws and freezes back the freezer cgroup.

Change-Id: I7f3e193ebe79b49c1f6ac52b6138ff4ec26fc570
2020-08-19 13:18:28 -07:00
Jack Yu
6097da8b76 Create folder to store nfc snoop data
Bug: 153704838
Test: nfc snooop could be stored in this folder
Change-Id: I0cb8ea1844e6774d47d3804ed6ddb3b2206be8c8
2020-08-14 17:53:56 +08:00
Jaegeuk Kim
43dca3c8be add generic symlink to access userdata sysfs
This patch adds fixed location to access sysfs entries by introducing:
/dev/sys/fs/by-name/userdata -> /sys/fs/f2fs/dm-<num>
/dev/sys/block/by-name/userdata -> /sys/block/dm-<num>

Bug: 144277579
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: I1b3768005fc8720694bace05292a1b1171d60e3c
2020-07-27 23:58:36 +00:00
Jaegeuk Kim
8d8edad443 rootdir/init.rc: enable iostat by default
Bug: 152162885
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: If95e30c7d3bfec621dfde9452a6eda5211c64a2b
Merged-In: If95e30c7d3bfec621dfde9452a6eda5211c64a2b
2020-07-25 00:20:47 +00:00
Yifan Hong
30b52007e5 Merge changes from topic "odm_dlkm" am: 3e31ec8392 am: 8c3a7ca939
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1363939

Change-Id: I8cdd4583c894d7fb5168fce1df789f2973a57357
2020-07-17 22:52:14 +00:00
Yifan Hong
e306bce927 rootdir: add odm_dlkm symlinks
Test: builds and boots
Bug: 156020364
Change-Id: I678b787cbf81ea6038936a4059e0bf5adfe3274f
2020-07-15 17:15:49 -07:00
Yifan Hong
a8e5779e18 Merge changes from topic "vendor_dlkm" am: 7ca7680ec5 am: 0c1a242060
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1350785

Change-Id: I7db376a03c329023a626c1130b7a55dc74ae9ae1
2020-07-14 19:47:16 +00:00
Yifan Hong
9374a9c6f7 rootdir: add vendor_dlkm symlinks
Test: builds and boots
Bug: 156020364
Change-Id: I99b0eeda0066d6c885aefe181f233a97507a61a9
2020-07-09 15:06:44 -07:00
Keun-young Park
bf73d615f2 Merge "Start statsd before starting zygote" into rvc-dev am: 163548736a
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11975342

Change-Id: I71ad1f73f19e0ddf7e856ecd981132498f538fea
2020-06-24 21:39:10 +00:00
Keun-young Park
163548736a Merge "Start statsd before starting zygote" into rvc-dev 2020-06-24 21:18:18 +00:00
Nikita Ioffe
a462044ac8 Explicitly call restorecon_recursive on /metadata/apex
On some devices we see a weird in which /metadata/apex will have a wrong
selinux label. This will effectively prevent such devices from getting
any apex updates. Since we haven't figured out a root cause for this
bug, it's safer to explicitly call restorecon on /metadata/apex to make
sure it's correct.

This change shouldn't affect a normal boot flow, since /metadata/apex
will already have a correct label and restorecon_recursive will be a
no-op.

Test: rm -Rf /metadata/apex && \
    mkdir /metadata/apex &&
    mkdir /metadata/apex/sessions
Bug: 149317789
Merged-In: I971ffe35c93bb79d9e71106c24515ec0ee70333a
Change-Id: I971ffe35c93bb79d9e71106c24515ec0ee70333a
(cherry picked from commit cf7b6bad55)
2020-06-24 16:30:03 +01:00
Keun young Park
6423ccd96b Start statsd before starting zygote
- zygote needs statsd for logging boot time event.
- statsd starting later leads into stats logging failure which
  is reported by all child processes of zygote later.
  This brings lots of noise in statsd error.

Bug: 159664734
Test: reboot and check if error log does not show up
  E statsd  : Found dropped events: 1 error -19 last atom tag 240 from uid 10169
Change-Id: Ie585febb50a9668671c8fda41a872595baae8385
2020-06-23 20:40:19 -07:00
Maciej Zenczykowski
ae53160792 Merge "add a new trigger for launching the bpfloader" into rvc-dev am: 227635182f
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11976442

Change-Id: Iff982438e428ca5782f93a010c5ffd5ca15217ab
2020-06-24 03:10:31 +00:00
Maciej Zenczykowski
227635182f Merge "add a new trigger for launching the bpfloader" into rvc-dev 2020-06-24 02:52:51 +00:00
Maciej Żenczykowski
c1ca9f75f9 add a new trigger for launching the bpfloader
Test: built and booted
Bug: 150040815
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Merged-In: If80758b3d7bf499d428880efa5ed555076bfc291
Change-Id: If80758b3d7bf499d428880efa5ed555076bfc291
2020-06-23 14:08:27 -07:00
Nikita Ioffe
d9469bdcd5 Merge "Explicitly call restorecon_recursive on /metadata/apex" into rvc-dev am: 6a8602a8c9
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11955299

Change-Id: Ibbf598ea7aac33a50fc5c7b1cab87317284e7de5
2020-06-22 21:52:04 +00:00
Nikita Ioffe
cf7b6bad55 Explicitly call restorecon_recursive on /metadata/apex
On some devices we see a weird in which /metadata/apex will have a wrong
selinux label. This will effectively prevent such devices from getting
any apex updates. Since we haven't figured out a root cause for this
bug, it's safer to explicitly call restorecon on /metadata/apex to make
sure it's correct.

This change shouldn't affect a normal boot flow, since /metadata/apex
will already have a correct label and restorecon_recursive will be a
no-op.

Test: rm -Rf /metadata/apex && \
    mkdir /metadata/apex &&
    mkdir /metadata/apex/sessions
Bug: 149317789
Change-Id: I971ffe35c93bb79d9e71106c24515ec0ee70333a
2020-06-22 16:56:38 +00:00
Maciej Żenczykowski
6c72c16e3d add a new trigger for launching the bpfloader
Test: built and booted
Bug: 150040815
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If80758b3d7bf499d428880efa5ed555076bfc291
2020-06-22 01:11:39 -07:00
Tim Murray
e95e2ca22c Merge "Move zygote64 into the top-app stune group." into rvc-dev am: 4dc1d5f3de
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11884893

Change-Id: I05d064f1c4f7241a5c9efc09ee6af33985a1f857
2020-06-18 19:37:18 +00:00
Tim Murray
e2318a2fce Move zygote64 into the top-app stune group.
Improve app startup performance before the new app is in the top-app
cpuset.

Test: boots, zygote64 in top-app stune group
Bug: 159201879

Change-Id: I3aad4b4b1d2f54db9e7ba86db8a655d8552bad0a
2020-06-18 10:43:01 -07:00
Treehugger Robot
620a7053c5 Merge "init.rc: chmod pagetypeinfo to 440 to be captured in BRs" am: a5032be8e0 am: f9537f222b
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1335693

Change-Id: Id9735c5b6677e25f29ea817da30a3df84bee9fed
2020-06-16 08:50:38 +00:00
Martin Liu
0abd0d6aa5 init.rc: chmod pagetypeinfo to 440 to be captured in BRs
Bug: 158928824
Test: Try BR
Change-Id: I2fa42780b77d86a234ae8b53d7264fbfd6a7906c
2020-06-15 15:24:43 +00:00
Elliott Hughes
cec2d69a0b Merge "Remove zygote configuration for 32-bit primary, 64-bit secondary." 2020-06-10 23:52:34 +00:00
Elliott Hughes
409bca11de Remove zygote configuration for 32-bit primary, 64-bit secondary.
Bug: https://issuetracker.google.com/138812821
Test: treehugger
Change-Id: I67c59f1956cec7ea46ded6e0a772ac1226e2a7b3
Merged-In: I67c59f1956cec7ea46ded6e0a772ac1226e2a7b3
2020-06-10 22:52:52 +00:00
Elliott Hughes
326f8e27db Remove zygote configuration for 32-bit primary, 64-bit secondary.
Bug: https://issuetracker.google.com/138812821
Test: treehugger
Change-Id: I67c59f1956cec7ea46ded6e0a772ac1226e2a7b3
2020-06-10 00:24:48 +00:00
Rick Yiu
11d167b575 Fine tune blkio setting to improve boot time
Bug: 133200996
Test: boot time test
Change-Id: I5262c28596adb7e849b202b8a163c190818f271a
Merged-In: I5262c28596adb7e849b202b8a163c190818f271a
2020-06-09 04:34:40 +00:00
Rick Yiu
20570fa261 Merge "Fine tune blkio setting to improve boot time" am: cb63bed8b5 am: 30ec7c391c
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1322741

Change-Id: Id247a8523cf5a2dbb53e42b77c77af5406e02051
2020-06-06 00:41:19 +00:00
Rick Yiu
ad74d8dee0 Fine tune blkio setting to improve boot time
Bug: 133200996
Test: boot time test
Change-Id: I5262c28596adb7e849b202b8a163c190818f271a
2020-06-04 14:28:19 +08:00
Mohammad Samiul Islam
6e51de9840 Merge "Create /metadata/staged-install dir to store staged install failure reasons" into rvc-dev am: 000226f1d5
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11408963

Change-Id: I3b8fd6a68aad1300eaeb2dd03415b90216b3fa61
2020-06-03 10:19:32 +00:00
Mohammad Samiul Islam
000226f1d5 Merge "Create /metadata/staged-install dir to store staged install failure reasons" into rvc-dev 2020-06-03 09:57:18 +00:00
Martijn Coenen
4ff6531bc5 Merge changes from topic "fusectl" into rvc-dev am: 6030f2f016
Change-Id: I4888400ae48f4061e938832f49c8d1e453798244
2020-05-29 14:54:54 +00:00
Martijn Coenen
dd0440f4e5 Abort FUSE filesystem when Zygote restarts.
The FUSE filesystem is implemented by a Zygote child. If Zygote dies,
all of its children die along with it, including the FUSE daemon. The
FUSE filesystem is cleaned up automatically whenever the /dev/fuse file
descriptor of the FUSE daemon is closed. However, due to the way the
binder driver holds on to the 'struct files' of processes in the kernel,
the closing of FDs of all of Zygote's children is serialized.

That in turn means that, if a process has a file with dirty pages on
FUSE, and that FD is closed *before* the FUSE FD, the FUSE kernel driver
will happily issue a request to the FUSE daemon to serve that request.
But since the FUSE userspace daemon is already dead, it will never get
served. And because the closing of all FDs is serialized, we will never
close the FUSE fd to unblock this request.

Solve this particular case by manually aborting the FUSE filesystem when
Zygote restarts. Because we now explicitly close the FUSE fd, the FUSE
filesystem will be cleaned up, all outstanding requests to it will be
cancelled, and new ones will be skipped.

Bug: 153411204
Test: kill zygote manually
Change-Id: I2cb6c1a03cc1a932461ff33558894a428ff35180
2020-05-28 19:11:01 +02:00
Martijn Coenen
959dcf106d Mount fusectl filesystem.
To allow us to manually abort FUSE filesystems.

Bug: 153411204
Test: inspect /sys/fs/fuse/
Change-Id: I150597635d62932aa70ee696b4d978c822e6ea8d
2020-05-28 16:25:45 +02:00
Mohammad Samiul Islam
d192d5471c Create /metadata/staged-install dir to store staged install failure reasons
Bug: 146343545
Test: presubmit
Change-Id: I513d403f67643929bb8f90212c1054fb3024f12a
2020-05-20 18:55:13 +01:00
Nikita Ioffe
ae6cab0406 Merge "Make /data/apex/active world readable" 2020-05-13 20:15:12 +00:00
Orion Hodson
b0efc1f6c7 Merge "Add libnativehelper.so to public libraries" am: 2f448104d7 am: 278c9794ec
Change-Id: I8b9e113b50ad18bf54043cd619c41cc4dc52ff06
2020-05-04 07:43:37 +00:00
Orion Hodson
2f448104d7 Merge "Add libnativehelper.so to public libraries" 2020-05-04 07:23:19 +00:00
Kyle Lin
106d6fe775 rootdir: init.rc: mount tracefs
Bug: 153849221
Test: build and try to capture the trace by perfetto and systrace
Change-Id: Ie8a13e12038bd66afcd264079a2c5f25daaa20ee
Merged-In: Ie8a13e12038bd66afcd264079a2c5f25daaa20ee
(cherry picked from commit 9d19a05422)
2020-04-30 22:04:37 +08:00
Treehugger Robot
fd44bc6518 Merge "rootdir: init.rc: mount tracefs" am: a5fa1ae859 am: 8535d19357
Change-Id: I2770f5ef2a48f0430519c626d7d24464f93e30de
2020-04-30 03:16:44 +00:00
Kyle Lin
9d19a05422 rootdir: init.rc: mount tracefs
Bug: 153849221
Test: build and try to capture the trace by perfetto and systrace
Change-Id: Ie8a13e12038bd66afcd264079a2c5f25daaa20ee
2020-04-30 02:15:42 +08:00
Orion Hodson
e123b3ca5a Add libnativehelper.so to public libraries
Bug: 150252746
Bug: 151443957
Test: m & boot
Change-Id: If595a8af164cddb7d9471aa54607f878b3b4ed8c
2020-04-29 17:48:40 +01:00
Nikita Ioffe
b8591b5ace Make /data/apex/active world readable
This will allow Phonesky to read APEXes under /data/apex/active.

Test: adb shell su 10114 dd if=/data/apex/active/com.android.tzdata@300000000.apex of=/dev/null
Bug: 154635217
Merged-In: I5278897413ca0e32aed9d1c7f82e48138bc51404
Change-Id: I5278897413ca0e32aed9d1c7f82e48138bc51404
2020-04-24 23:40:34 +01:00
Nikita Ioffe
fb4ac314ec Merge "Make /data/apex/active world readable" into rvc-dev am: e343f439a3
Change-Id: Ic976bf67ad7bb28547903cc64617b250b3c35004
2020-04-24 21:59:40 +00:00
Nikita Ioffe
e343f439a3 Merge "Make /data/apex/active world readable" into rvc-dev 2020-04-24 21:44:40 +00:00
Oli Lan
7c59fc4fb4 Observe new apexd status value of "activated" as required.
- Cherry pick of aosp/1228482

As of aosp/1224611, there is a new step in the preparation of APEXes
where init calls back into apexd after DE user data is unencrypted to
allow DE apex data to be snapshotted or restored.

aosp/1228581 introduces a new apexd.status value of "activated" that
is set once APEXes are activated but before this snapshot has occurred.

init may execute "perform_apex_config" once this has occurred, so this
CL changes init to wait for "activated" rather than "ready" before
doing this.

Bug: 148672144
Test: build & flash, check boot completes and check in logs that init
waits on the correct status value.
Merged-In: I339580bf593d3b09a5dff749ac2a5d1952bcb210
Change-Id: I71b62c9dd2f7951811606002f38612784d3d9086
2020-04-22 12:37:27 +00:00
Nikita Ioffe
71278019d1 Make /data/apex/active world readable
This will allow Phonesky to read APEXes under /data/apex/active.

Test: adb shell su 10114 dd if=/data/apex/active/com.android.tzdata@300000000.apex of=/dev/null
Bug: 154635217
Change-Id: I5278897413ca0e32aed9d1c7f82e48138bc51404
2020-04-21 21:14:59 +01:00
Jaegeuk Kim
fc80e8c42b Merge "rootdir/init.rc: enable iostat by default" into rvc-dev am: 418f28dbe4
Change-Id: I256d5b864a824c36eb77e3d767c89488876059bf
2020-04-16 00:58:14 +00:00
Jaegeuk Kim
418f28dbe4 Merge "rootdir/init.rc: enable iostat by default" into rvc-dev 2020-04-16 00:48:11 +00:00
Nikita Ioffe
0a5ed30d7e Merge "Manually unmount /data_mirror mounts in the right order" am: 9cd3c84dc1 am: 6cdf64a2ef
Change-Id: I6d7e3f2ebf77a29c5f54ea3ad4c284df551403c2
2020-04-07 18:03:26 +00:00
Nikita Ioffe
a680e261e6 Manually unmount /data_mirror mounts in the right order
Test: atest CtsUserspaceRebootHostSideTestCases
Bug: 152823078
Change-Id: I57ff9182807630d8cbcf3ca6374fdd6dc6379da5
Merged-In: I57ff9182807630d8cbcf3ca6374fdd6dc6379da5
(cherry picked from commit bf66f433d6)
2020-04-07 18:54:48 +01:00
Nikita Ioffe
bf66f433d6 Manually unmount /data_mirror mounts in the right order
Test: atest CtsUserspaceRebootHostSideTestCases
Bug: 152823078
Change-Id: I57ff9182807630d8cbcf3ca6374fdd6dc6379da5
2020-04-07 15:43:10 +00:00
Jaegeuk Kim
767c723c25 rootdir/init.rc: enable iostat by default
Bug: 152162885
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: If95e30c7d3bfec621dfde9452a6eda5211c64a2b
2020-04-02 05:06:00 +00:00
Jaegeuk Kim
701add4103 Merge "rootdir: init.rc: use default dirty writeout policy" am: a76ee8b929 am: 6fa02ca30a
Change-Id: Icec865962b9463d9303d2367b97f074b3b17e8cb
2020-03-31 16:19:48 +00:00
Jaegeuk Kim
58ff5075ac rootdir: init.rc: use default dirty writeout policy
This patch removed the old writeout policy tune which was never touched since
2009. In the meantime, most of Android devices are equipped with over 4GB DRAM
and very fast flash storages like UFS, which becomes more like desktop or
servers in 2009. So, it'd be worth to go back to use the default kernel configs.

Bug: 129751503
Change-Id: Idb58f5b01bbc4afd270cffba5b8912ea3565819f
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2020-03-31 01:49:13 +00:00
Jeffrey Huang
c262d79974 Add new directory for stats metadata
Also reordered the directories in alphabetical order

Test: m -j
Bug: 149838525
Merged-In: I1a918d189d8bcb394ec6f818d033dbf7e4518713
Change-Id: I4b10a01ed6b3285aec6d87765f225c41ec55be96
2020-03-19 10:13:11 -07:00
Automerger Merge Worker
ab43bfb170 Merge "freezer: allow dynamic changes to freezer.state" into rvc-dev am: 3eb99ecf0f
Change-Id: Ic3db6564a360117d748fabcec29106e695e737a8
2020-03-17 16:24:31 +00:00
Marco Ballesio
c1e763a95b freezer: allow dynamic changes to freezer.state
create new profiles to allowing thawing and freezing back the freezer
cgroup

Bug: 151225245
Test: Manually verified that using the SetTaskProfiles method on the
profiles thaws and freezes back the freezer cgroup.

Change-Id: I7f3e193ebe79b49c1f6ac52b6138ff4ec26fc570
2020-03-16 09:11:36 -07:00
Eric Biggers
fcdaee4861 Merge "init.rc: disable kernel module autoloading" into rvc-dev 2020-03-13 19:10:19 +00:00
Automerger Merge Worker
35cb5cc14a Merge "init.rc: disable kernel module autoloading" am: e7f014da9c am: 0cef47636d
Change-Id: Ia597709b939a6a1699e364c448430b646a1dcd5e
2020-03-12 21:49:39 +00:00
Eric Biggers
b6545b80a0 init.rc: disable kernel module autoloading
There is a longstanding bug where file-based encryption causes spurious
SELinux denials of module_request because it uses the kernel's crypto
API, and the crypto API tries to autoload kernel modules.

While this sometimes indicate missing kconfig options, it can still
happen even if all needed kconfig options are enabled.  This is because
a crypto algorithm can be a composition like "hmac(sha512)", and the
crypto API will first look for the full composition before it
instantiates it using the components like "hmac" and "sha512".  But
often an implementation of the full composition doesn't exist.

However, as far as I can tell, Android doesn't actually use kernel
module autoloading at all.  First, Android never changes
/proc/sys/kernel/modprobe from the default of "/sbin/modprobe", yet this
isn't where modprobe is located on Android.  Android's SELinux policy
contains a neverallow rule that ensures that only init (not even
vendor_init) can write to this setting, so vendors can't be changing it.

Vendors could potentially be setting CONFIG_STATIC_USERMODEHELPER_PATH,
which overrides the path of all usermode helpers including modprobe.
But this is a relatively new kconfig option, available only in
android-4.14 and later.  Also, for a vendor to actually do this they'd
also need to extend the SELinux policy with a domain_auto_trans rule to
allow their usermode helper to be executed by the kernel.

Android does increasingly use kernel modules, and GKI (Generic Kernel
Image) will require them.  However, the modules are actually inserted by
userspace by 'init', not autoloaded.

It's possible to disable kernel module autoloading completely by setting
/proc/sys/kernel/modprobe to an empty string.  So, let's do that.

This prevents lots of spurious SELinux denials, and allows removing
unnecessary rules to allow or dontaudit the module_request permission.

Note: when the kernel doesn't have CONFIG_ANDROID_BINDERFS enabled, this
change exposes a kernel bug that causes a WARNING in get_fs_type().  To
avoid this WARNING, a kernel fix should be applied too -- currently
under discussion upstream
(https://lkml.kernel.org/r/20200310223731.126894-1-ebiggers@kernel.org).

Bug: 130424539
Bug: 132409186
Bug: 144399145
Bug: 146477240
Bug: 148005188
Bug: 149542343

Test: Tested on cuttlefish and coral:

    - Checked that /proc/sys/kernel/modprobe contains /sbin/modprobe
      before this change, and the empty string after.

    - Checked that if all SELinux rules for module_request are removed,
      there are SELinux denials for module_request before this change
      but none after.

    - Ran lsmod both before and after and verified that the list is the
      same, i.e. checked that this change doesn't break how Android
      actually loads kernel modules.

Change-Id: I4132fe1a491e7b789311afcf693c1f6493fb9dc5
Merged-In: I4132fe1a491e7b789311afcf693c1f6493fb9dc5
2020-03-12 14:20:40 -07:00
Eric Biggers
843f46e674 init.rc: disable kernel module autoloading
There is a longstanding bug where file-based encryption causes spurious
SELinux denials of module_request because it uses the kernel's crypto
API, and the crypto API tries to autoload kernel modules.

While this sometimes indicate missing kconfig options, it can still
happen even if all needed kconfig options are enabled.  This is because
a crypto algorithm can be a composition like "hmac(sha512)", and the
crypto API will first look for the full composition before it
instantiates it using the components like "hmac" and "sha512".  But
often an implementation of the full composition doesn't exist.

However, as far as I can tell, Android doesn't actually use kernel
module autoloading at all.  First, Android never changes
/proc/sys/kernel/modprobe from the default of "/sbin/modprobe", yet this
isn't where modprobe is located on Android.  Android's SELinux policy
contains a neverallow rule that ensures that only init (not even
vendor_init) can write to this setting, so vendors can't be changing it.

Vendors could potentially be setting CONFIG_STATIC_USERMODEHELPER_PATH,
which overrides the path of all usermode helpers including modprobe.
But this is a relatively new kconfig option, available only in
android-4.14 and later.  Also, for a vendor to actually do this they'd
also need to extend the SELinux policy with a domain_auto_trans rule to
allow their usermode helper to be executed by the kernel.

Android does increasingly use kernel modules, and GKI (Generic Kernel
Image) will require them.  However, the modules are actually inserted by
userspace by 'init', not autoloaded.

It's possible to disable kernel module autoloading completely by setting
/proc/sys/kernel/modprobe to an empty string.  So, let's do that.

This prevents lots of spurious SELinux denials, and allows removing
unnecessary rules to allow or dontaudit the module_request permission.

Note: when the kernel doesn't have CONFIG_ANDROID_BINDERFS enabled, this
change exposes a kernel bug that causes a WARNING in get_fs_type().  To
avoid this WARNING, a kernel fix should be applied too -- currently
under discussion upstream
(https://lkml.kernel.org/r/20200310223731.126894-1-ebiggers@kernel.org).

Bug: 130424539
Bug: 132409186
Bug: 144399145
Bug: 146477240
Bug: 148005188
Bug: 149542343

Test: Tested on cuttlefish and coral:

    - Checked that /proc/sys/kernel/modprobe contains /sbin/modprobe
      before this change, and the empty string after.

    - Checked that if all SELinux rules for module_request are removed,
      there are SELinux denials for module_request before this change
      but none after.

    - Ran lsmod both before and after and verified that the list is the
      same, i.e. checked that this change doesn't break how Android
      actually loads kernel modules.

Change-Id: I4132fe1a491e7b789311afcf693c1f6493fb9dc5
2020-03-11 10:01:32 -07:00
Automerger Merge Worker
820ac89354 Merge "Add new directory for stats metadata" am: 3a4e3825f4 am: 17dd7ff06c
Change-Id: I6be0083e3d70c6e87d77af85dbfceec5b45be819
2020-03-09 20:19:08 +00:00
Jeffrey Huang
3a4e3825f4 Merge "Add new directory for stats metadata" 2020-03-09 18:09:21 +00:00
Jeffrey Huang
58c88615f2 Add new directory for stats metadata
Also reordered the directories in alphabetical order

Test: m -j
Bug: 149838525
Change-Id: I1a918d189d8bcb394ec6f818d033dbf7e4518713
2020-03-05 08:53:11 -08:00
Jeffrey Huang
8c20f9e6b5 Merge "Update init.rc for statsd setup" 2020-03-05 16:49:39 +00:00
Automerger Merge Worker
70b6a95619 Fix /data_mirror permission
Test: Able to boot without error
Bug: 150671726

Merged-In: If366d284f4f01ebfa660e85bad57861c120ada7e
Change-Id: I9d85c00d191dcaa46c0182b5a15cd89dcdb9ea5e
(cherry picked from commit 1a5ae50943)
2020-03-05 11:41:34 +00:00
Automerger Merge Worker
f13fd3b82d Merge "Fix /data_mirror permission" am: 541d0d28b1 am: b192a8111a
Change-Id: Id61f223d5427101f7084aa5dedbc2c29b1d0443d
2020-03-05 10:29:49 +00:00
Jeffrey Huang
8dccf3ffd1 Update init.rc for statsd setup
Apexes do not support "on" macros, so we are moving
them into the system partition

Bug: 145923087
Test: m -j
Change-Id: Ic671a51f2ec5b91f2f631bae0f509b4aa2d057b4
Merged-In: Ic84e77269f80097b675d6a1b0d206c2bae7d918d
2020-03-04 15:14:37 -08:00
Ricky Wai
1a5ae50943 Fix /data_mirror permission
Test: Able to boot without error
Bug: 150671726
Change-Id: If366d284f4f01ebfa660e85bad57861c120ada7e
2020-03-04 13:30:09 +00:00
Automerger Merge Worker
31a64ed187 Merge "Observe new apexd status value of "activated" as required." am: 2f11663fc9 am: f53cca4d26
Change-Id: I8ea819407b50d3ce632f5b987507a7807de60bd4
2020-03-02 10:47:07 +00:00
Oli Lan
2f11663fc9 Merge "Observe new apexd status value of "activated" as required." 2020-03-02 10:24:21 +00:00
Howard Ro
0aa2faf8b1 Merge "Revert^2 "Update init.rc for statsd setup"" 2020-02-20 08:00:53 +00:00
Automerger Merge Worker
a7634f5fa6 Merge "Adding new GSI public keys" am: c5c3f54806 am: 63f215d4c5 am: 290bb3368a
Change-Id: I9d1e5ba88c5c410f582f48fdc7cc4a4b88a6f4d4
2020-02-20 06:52:31 +00:00
Treehugger Robot
c5c3f54806 Merge "Adding new GSI public keys" 2020-02-20 06:18:41 +00:00
Howard Ro
78900ad658 Revert^2 "Update init.rc for statsd setup"
77a8d9f64e

Change-Id: Ic8dce44e6e83323381a39682b833acf8feb714a2
2020-02-20 04:57:00 +00:00
Howard Ro
77a8d9f64e Revert "Update init.rc for statsd setup"
Revert "Migrate Statsd to the apex"

Revert "Update statsd binary path for apex"

Revert submission 10356003-statsd_apex

Reason for revert: https://android-build.googleplex.com/builds/quarterdeck?branch=git_master&target=build_test&lkgb=6221366&fkbb=6221428
Reverted Changes:
Ic84e77269:Update init.rc for statsd setup
I6f3fab4b4:Update statsd binary path for apex
Ib4ea98aed:Migrate Statsd to the apex

Change-Id: I0db7f3be927f379b70e0b68bcf1cfdab3f2f1ae0
2020-02-20 04:19:41 +00:00
Jeffrey Huang
8dcbcf13e4 Update init.rc for statsd setup
Apexes do not support "on" macros, so we are moving
them into the system partition

Bug: 145923087
Test: m -j
Change-Id: Ic84e77269f80097b675d6a1b0d206c2bae7d918d
2020-02-19 14:11:16 -08:00
Bowgo Tsai
b697d47eb3 Adding new GSI public keys
Adding two new public keys for R-Developer-GSI and S-Developer-GSI,
respectively.

Bug: 149805495
Test: m r-developer-gsi.avbpubkey
Test: m s-developer-gsi.avbpubkey
Change-Id: Iaa7521ef40b94f13fe3c9c61d276678f47c60b98
2020-02-19 08:50:26 +00:00
Suren Baghdasaryan
cb3003c1bc Merge "Set lowmemorykiller kernel driver parameters before lmkd is started" am: 36ef05cbde am: b3553f8963 am: 355db04b78
Change-Id: I585cac23b8bfe71db2e7a649f4c815a1dd88e091
2020-02-17 10:12:44 +00:00
Treehugger Robot
15c0b798bd Merge "bootstat: enhance last reboot reason property with file backing" am: 7550e6f882 am: ffd276388f am: c0210f1d0e
Change-Id: I6d953d6b9308dc46619e52f81cb5469b22df55d0
2020-02-17 10:12:25 +00:00
Suren Baghdasaryan
36ef05cbde Merge "Set lowmemorykiller kernel driver parameters before lmkd is started" 2020-02-15 01:02:08 +00:00
Mark Salyzyn
ee016ce0b3 bootstat: enhance last reboot reason property with file backing
Helps with support of recovery and rollback boot reason history, by
also using /metadata/bootstat/persist.sys.boot.reason to file the
reboot reason.

Test: manual
Bug: 129007837
Change-Id: Id1d21c404067414847bef14a0c43f70cafe1a3e2
2020-02-14 13:24:16 -08:00
Suren Baghdasaryan
6898682275 Set lowmemorykiller kernel driver parameters before lmkd is started
When kernel lowmemorykiller driver is enabled lmkd detects it by
checking write access to /sys/module/lowmemorykiller/parameters/minfree
parameter. By default this file does not have write access and init
process changes that from "on boot" section of init.rc. However
"on boot" is never executed in the charger mode, therefore lmkd fails
to detect the kernel driver. Fix this by setting lowmemorykiller kernel
driver parameters before lmkd is started.

Bug: 148572711
Test: boot into charger mode with kernel lmk driver enabled
Change-Id: Ifc3ef725b95bdb5f7d801031429dc26bae014d1f
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2020-02-14 01:40:29 +00:00
Zim
e48a55649c Revert "Explicitly disable FUSE"
This reverts commit a3209c5f57.

Should not have been merged into master

Test: m
Bug: 135341433
2020-02-13 19:38:06 +00:00
Automerger Merge Worker
c367388849 Merge changes from topic "snapshotctl_log" am: da8a404473 am: 6d3c0ef08c am: 9345bfb0b2
Change-Id: I0cb4d5a42e43cee95614cc9397faff9b9ad34a84
2020-02-12 18:51:48 +00:00
Yifan Hong
da8a404473 Merge changes from topic "snapshotctl_log"
* changes:
  libsnapshot callstack files readable by dumpstate
  snapshotctl logs readable by dumpstate
  snapshotctl_log dir readable by dumpstate
2020-02-12 18:18:59 +00:00
Zimuzo Ezeozue
6d3fa224af Merge "FUSE flag on by default" 2020-02-12 13:15:48 +00:00
Zimuzo Ezeozue
ec9c803503 Merge "Explicitly disable FUSE" 2020-02-11 21:17:53 +00:00
Yifan Hong
7d28688f96 snapshotctl_log dir readable by dumpstate
Set snapshotctl_log as 0755 so that it is
readable by dumpstate.

Test: bugreport
Bug: 148818798
Change-Id: I6ff52cf0a2e928c74df31aa054ae780f919d6eb0
2020-02-11 10:57:51 -08:00
Zim
a3209c5f57 Explicitly disable FUSE
It is already disabled, but having an explcit value in the prop makes
some code in the system_server, easier.

Will follow up with a cl to explicitly enable it on internal master,
aosp will remain this way since it doesn't have the additional
components to run FUSE.

Test: Freshly wiped and flashed device has persist.sys.fuse set to false
Bug: 135341433
Merged-In: I1493e2806823b5751794a9a17ee248dc72b857ff
Change-Id: Ibb955a543e367aa2f4518d5c1c4d070cd084eca0
2020-02-11 16:56:47 +00:00
Zim
8dacabe6b3 FUSE flag on by default
This will make the FUSE filesystem the default on the build

Test: https://android-build.googleplex.com/builds/forrest/run/L11100000458471772
Bug: 135341433
Change-Id: I1493e2806823b5751794a9a17ee248dc72b857ff
2020-02-11 13:40:34 +00:00
Jerry Chang
9272319714 Merge "Create directory to store pre-reboot information before reboot" 2020-02-11 02:49:29 +00:00
Treehugger Robot
c17c5b00e1 Merge changes I1bf07301,I48e8ebf3
* changes:
  Remove more duplicated symlinks
  Remove duplicated debugfs symlink
2020-02-10 23:10:08 +00:00
Luca Stefani
57909b4c30 Remove more duplicated symlinks
They're all created in rootdir/Android.mk

Test: m
Change-Id: I1bf07301434d8cf4f2e9226071983d7aeaf149ac
2020-02-10 22:23:29 +01:00
Luca Stefani
8c61e7da49 Remove duplicated debugfs symlink
* Currently it's created at build-time in rootdir/Android.mk

Test: m
Change-Id: I48e8ebf3412dfdfc2dff3b4fcf9b72de52726865
2020-02-10 21:56:03 +01:00
Miao Wang
c3991a7150 Add an stune group for NNAPI HAL
- schedtune.prefer_idle 1
 - schedtune.boost 1

Test: mm
Test: configure NNAPI HAL to use nnapi-hal stune
Test: measure perf difference using MLTS benchmark

Change-Id: I5f467c6a58f2c1da40ec8276e101defc808854a3
(cherry picked from commit 1d748feaec)
2020-02-10 11:47:49 -08:00
Nikita Ioffe
15e4f6fe5a Merge "Don't log userspace_reboot.started/finished properties from init" 2020-02-10 17:22:03 +00:00
Nikita Ioffe
c2bc1a3422 Reset dev.bootcomplete property during userspace reboot
Test: adb reboot userspace
Bug: 135984674
Change-Id: I7c6e433c819fc22e88820626768fe8832882386e
2020-02-07 17:42:27 +00:00
Nikita Ioffe
85ff4ab9a4 Don't log userspace_reboot.started/finished properties from init
Instead they will be logged from system_server. This CL just prepares
grounds for logging CL to land.

Test: adb reboot userspace
Bug: 148767783
Change-Id: Ie9482ef735344ecfb0de8a37785d314a3c0417ff
2020-02-07 14:41:39 +00:00
Oli Lan
3cb185e4a1 Observe new apexd status value of "activated" as required.
As of aosp/1224611, there is a new step in the preparation of APEXes
where init calls back into apexd after DE user data is unencrypted to
allow DE apex data to be snapshotted or restored.

aosp/1228581 introduces a new apexd.status value of "activated" that
is set once APEXes are activated but before this snapshot has occurred.

init may execute "perform_apex_config" once this has occurred, so this
CL changes init to wait for "activated" rather than "ready" before
doing this.

Bug: 148672144
Test: build & flash, check boot completes and check in logs that init
waits on the correct status value.

Change-Id: I339580bf593d3b09a5dff749ac2a5d1952bcb210
2020-02-06 11:55:51 +00:00
Jerry Chang
aedac7e625 Create directory to store pre-reboot information before reboot
Bug: 145203410
Test: Built and flashed, checked directory was created
Change-Id: Ic4d43fba62301bde23bec459b5b8b6332be2b6dc
2020-02-06 19:42:42 +08:00
Daniel Rosenberg
02e5e1ea22 Merge "Make /data/media case insensitive" 2020-02-04 23:03:38 +00:00
Yifan Hong
c19b08a66a Merge "Make snapshotctl logging better." 2020-02-04 22:18:33 +00:00
Yifan Hong
12fe03d470 Make snapshotctl logging better.
snapshotctl merge --logcat --log-to-file
- If --logcat, log to logcat
- If --log-to-file, log to /data/misc/snapshotctl_log/
- If both, log to both
- If none, log to stdout

Test: manually test these 4 cases
Bug: 148818798
Change-Id: I44b52936c0d095867acc6ee781c6bec04f6ebd6b
2020-02-04 14:01:24 -08:00
Treehugger Robot
b970633642 Merge "Mount binderfs" 2020-02-04 00:50:10 +00:00
Hridya Valsaraju
b237d76ae5 Mount binderfs
Mount binderfs at /dev/binderfs. Also add symlinks from /dev/binder,
/dev/hwbinder and /dev/vndbinder to /dev/binderfs/binder,
/dev/binderfs/hwbinder and /dev/binderfs/vndbinder respectively.

The symlink commands will fail harmlessly on a kernel
which does not support binderfs since /dev/{binder,hwbinder,vndbinder}
devices will exist on the same.

Bug: 136497735
Bug: 148696163

Test: Cuttlefish boots on Android Common Kernel 4.19 with kernel config
CONFIG_ANDROID_BINDERFS=y.

Change-Id: I8e04340dc4622b0a3c1fc4aa6bbefcb24eefe00b
2020-02-03 22:14:21 +00:00
Treehugger Robot
823beae16a Merge "Revert "Mount binderfs"" 2020-02-03 18:37:40 +00:00
Oli Lan
0460f65f78 Merge "Allow apexd to snapshot and restore DE data." 2020-02-03 17:50:51 +00:00
Oli Lan
a466ca8ff4 Allow apexd to snapshot and restore DE data.
This calls into apexd to allow it to snapshot and restore DE apex data
in the case of a rollback. See the corresponding apexd change for more
information.

Cherry-pick from (unsubmitted) internal CL: ag/10163227

Bug: 141148175
Test: atest StagedRollbackTest#testRollbackApexDataDirectories_DeSys
Change-Id: Ia4bacc9b7b7a77038ba897acbc7db29e177a6433
2020-02-03 11:47:15 +00:00
Zimuzo Ezeozue
294c16024b Merge "Harden /mnt/pass_through paths" 2020-02-03 11:34:52 +00:00
Nikita Ioffe
03aaecbd99 Merge "Don't reset sys.usb.configfs during userspace reboot" 2020-02-03 08:12:38 +00:00
Daniel Rosenberg
ebfe359ca8 Make /data/media case insensitive
Use chattr to apply +F to /data/media
This will fail on devices who do not support casefolding on userdata.

Bug: 138322712
Test: /data/media is set to +F.
Change-Id: Ib341c23a0992ee97b23113b3a72f33a61e583b04
2020-01-31 18:34:03 -08:00
Maciej Żenczykowski
8fda5feb25 Merge "symlink /dev/net/tun -> ../tun" 2020-02-01 01:24:57 +00:00
Greg Kaiser
49a542a979 Revert "Mount binderfs"
This reverts commit 8e50be74ae.

Reason for revert: Several devices did not boot
Test: Local build with this reverted had the device boot
Bug: 148689473
Merged-In: I97e96bd86d02a9fe70c5ef02df85c604b0cfb3c3

Change-Id: Ic4a2990e7c0cb08c374a336422c08d9aad28049d
2020-01-31 23:37:21 +00:00
Treehugger Robot
938379de5b Merge "Mount binderfs" 2020-01-31 18:46:14 +00:00
Zim
a67b40bc2a Harden /mnt/pass_through paths
Only the FUSE daemon (with media_rw gid) needs access to paths on
/mnt/pass_through. And even then, it only needs execute access on the
dirs, since there will always be a bind mount either from sdcardfs or
the lower filesystem on it and that bind mount correctly handles ACLs
for the FUSE daemon.

Test: manual
Bug: 135341433
Change-Id: I999451e095da355e6247e9e18fb6fe1ab8fc45d6
2020-01-31 16:26:13 +00:00
Nikita Ioffe
4f8e05663e Don't reset sys.usb.configfs during userspace reboot
Test: adb reboot userspace (on blueline)
Test: adb reboot userspace (on cuttlefish)
Bug: 147726967
Change-Id: Id4a367e74b418a85e8454e952e12e0723efc9b8a
2020-01-31 15:59:19 +00:00
Maciej Żenczykowski
00a21e3d54 symlink /dev/net/tun -> ../tun
This is the expected location on Linux and this makes 'ip tuntap' work.

Before:
  vsoc_x86_64:/ # ip tuntap add dev tun0 mode tun
  open: No such file or directory
  vsoc_x86_64:/ # ip tuntap add dev tap0 mode tap
  open: No such file or directory
  vsoc_x86_64:/ # ip tuntap list

After:
  vsoc_x86_64:/ # ip tuntap add dev tun0 mode tun
  vsoc_x86_64:/ # ip tuntap add dev tap0 mode tap
  vsoc_x86_64:/ # ip tuntap list
  tap0: tap UNKNOWN_FLAGS:800
  tun0: tun UNKNOWN_FLAGS:800

  $ adbz shell ls -ldZ / /dev /dev/tun /dev/net /dev/net/tun
  drwxr-xr-x 25 root   root u:object_r:rootfs:s0         4096 2020-01-25 09:48 /
  drwxr-xr-x 21 root   root u:object_r:device:s0         1240 2020-01-25 09:48 /dev
  drwxr-xr-x  2 root   root u:object_r:device:s0           60 2020-01-25 09:48 /dev/net
  lrwxrwxrwx  1 root   root u:object_r:device:s0            6 2020-01-25 09:48 /dev/net/tun -> ../tun
  crw-rw----  1 system vpn  u:object_r:tun_device:s0  10, 200 2020-01-25 09:48 /dev/tun

Test: see above
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2aa215711454ce4f8a0ef1f34c17621629060fa1
2020-01-30 03:51:33 +00:00
Hridya Valsaraju
8e50be74ae Mount binderfs
Mount binderfs at /dev/binderfs. Also add symlinks from /dev/binder,
/dev/hwbinder and /dev/vndbinder to /dev/binderfs/binder,
/dev/binderfs/hwbinder and /dev/binderfs/vndbinder respectively.

Bug: 136497735
Test: Cuttlefish boots on Android Common Kernel 4.19 with kernel config
CONFIG_ANDROID_BINDERFS=y.

Change-Id: I349face22a2e73bfd79af0188e41188c323388f7
2020-01-29 17:59:17 -08:00
Alistair Delva
1fad2b39a3 Merge "Correct /sys/kernel/tracing permissions" 2020-01-30 00:08:02 +00:00
Alistair Delva
ebb5b3bd48 Correct /sys/kernel/tracing permissions
In Android kernels >4.4 we will see an empty /sys/kernel/tracing
directory which is notionally where you should mount tracefs if you
don't want to mount debugfs. As we move towards not mounting debugfs,
ensure that the non-legacy location also has adequate permissions to be
read by tracing tools.

Note that this change will be OK even if the board init.rc doesn't mount
tracefs here, because sysfs will always create this directory.

Bug: 148436518
Change-Id: I674587d0f08effdb8471a82e3b1ceec3af8588de
2020-01-29 09:10:50 -08:00
Nikita Ioffe
2d88794a7d Merge "Trigger boot animation on userspace reboot" 2020-01-29 11:24:01 +00:00
Nikita Ioffe
764c1ac8ba Trigger boot animation on userspace reboot
Also reset some more properties to make bootanimation work properly.

Test: adb reboot userspace
Bug: 148172262
Change-Id: I0154d4fe9377c019150f5b1a709c406925db584d
2020-01-28 10:42:44 +00:00
Zim
c1b53de450 Change gid bit of /mnt/media_rw to external_storage
To allow apps with MANAGE_EXTERNAL_STORAGE permission and therefore
external_storage gid to access unreliable volumes directly on
/mnt/media_rw/<volume>, they need access to the /mnt/media_rw path.

This change doesn't break the FUSE daemon, the only process that should
have media_rw gid in R because the FUSE daemon accesses the lower
filesystem from the pass_through bind mounts of the public volume mount
itself so it doesn't need to walk the /mnt/media_rw path itself

Test: With FUSE enabled, a reliably mounted public volume is accessible
on /storage
Bug: 144914977

Change-Id: Ia3fc9e7483894402c14fb520024e2acca821a24d
2020-01-24 22:13:58 +00:00
Oliver Nguyen
38b33c09f9 Merge "Set Clang coverage environment variables." 2020-01-22 22:34:35 +00:00
Treehugger Robot
eba798a767 Merge "Harden /mnt/pass_through permission bits" 2020-01-22 21:30:53 +00:00
Zim
6ca090e6b0 Harden /mnt/pass_through permission bits
It previously had 0755 permission bits

With such permissive bits, an unauthorized app can access a file using
the /mnt/pass_through path for instance even if access via /storage
would have been restricted.

It is now 0700

TODO: Change ACL for /mnt/user from 0755 to 0700 in vold only when
FUSE flag is on. Changing it with FUSE off breaks accessing /sdcard
because /sdcard is eventually a symlink to /mnt/user/0/primary

Test: adb shell ls -d /mnt/pass_through
Bug: 135341433
Change-Id: I3ea9655c6b8c6b4f847b34a2d3b96784a8f4a160
2020-01-22 17:54:45 +00:00
Ryan Savitski
cdebef1d2b Merge "init: add builtin check for perf_event LSM hooks" 2020-01-21 20:40:50 +00:00
Oli Lan
90c523b30b Give x permission on apex data directories.
This gives search (x) permission on the parent apex data
directory /data/misc/apexdata so that directories below it
may be opened. It also gives that permission on the apex
data directories themselves.

Bug: 147848983
Test: Build & flash, check perms are correct
Change-Id: I27c4ea01602002c89d0771a144265e3879d9041a
2020-01-17 11:41:04 +00:00
David Zeuthen
e83f386653 Add user for credstore.
The credstore system daemon is running as an unprivileged user. This
CL adds this user and also creates a directory (/data/misc/credstore/)
where this daemon can store its data.

Bug: 111446262
Test: N/A
Change-Id: I8da2c32dd04fef797870b8a7bbc5e499bed71f9e
2020-01-16 07:32:04 -05:00
Ryan Savitski
f0f7e70186 init: add builtin check for perf_event LSM hooks
Historically, the syscall was controlled by a system-wide
perf_event_paranoid sysctl, which is not flexible enough to allow only
specific processes to use the syscall. However, SELinux support for the
syscall has been upstreamed recently[1] (and is being backported to
Android R release common kernels).
[1] da97e18458

As the presence of these hooks is not guaranteed on all Android R
platforms (since we support upgrades while keeping an older kernel), we
need to test for the feature dynamically. The LSM hooks themselves have
no way of being detected directly, so we instead test for their effects,
so we perform several syscalls, and look for a specific success/failure
combination, corresponding to the platform's SELinux policy.

If hooks are detected, perf_event_paranoid is set to -1 (unrestricted),
as the SELinux policy is then sufficient to control access.

This is done within init for several reasons:
* CAP_SYS_ADMIN side-steps perf_event_paranoid, so the tests can be done
  if non-root users aren't allowed to use the syscall (the default).
* init is already the setter of the paranoid value (see init.rc), which
  is also a privileged operation.
* the test itself is simple (couple of syscalls), so having a dedicated
  test binary/domain felt excessive.

I decided to go through a new sysprop (set by a builtin test in
second-stage init), and keeping the actuation in init.rc. We can change
it to an immediate write to the paranoid value if a use-case comes up
that requires the decision to be made earlier in the init sequence.

Bug: 137092007
Change-Id: Ib13a31fee896f17a28910d993df57168a83a4b3d
2020-01-15 20:58:15 +00:00
Treehugger Robot
ec7be0dc0f Merge "Create /mnt/data_mirror/cur_profiles in init.rc" 2020-01-15 19:47:52 +00:00
Treehugger Robot
e4505960b9 Merge "Disable dm-verity hash prefetching." 2020-01-15 13:13:01 +00:00
Treehugger Robot
f7593a9a2a Merge "[incrementa;] set mode and encryption for /data/incremental" 2020-01-15 02:58:02 +00:00
Songchun Fan
73d9e7d666 [incrementa;] set mode and encryption for /data/incremental
To be consistent with /data/app.

Test: boots
BUG: 137855266
Change-Id: I8aa549155367edfad158924bcf7892ac7bb76f16
2020-01-13 15:04:41 -08:00
Oliver Nguyen
c1f7035c31 Set Clang coverage environment variables.
Bug: 143977934
Test: m CLANG_COVERAGE=true and check LLVM_PROFILE_FILE is set
Change-Id: I5aea5a38b9bec1670bf9c8d11d9c466c3b83e4d8
2020-01-13 14:38:15 -08:00
Martijn Coenen
9226bb304a Disable dm-verity hash prefetching.
Prefetching appears to have a slightly negative effect on boot time, and
actually makes boot time much worse when the available dm-bufio cache
shrinks. Since we anticipate the dm-bufio cache will shrink (because of
an increasing number of APEX dm-verity targets), disable prefetching
completely.

We've run this change on Pixel 2 since August, and haven't observed any
negative effects. Boot time slightly decreased. With the increased
amount of APEXes we already have, this should now result in an even more
significant boot time decrease.

Bug: 136247322
Test: atest google/perf/boottime/boottime-test
Change-Id: Id588669af1b0b9daaf15323dccf33411e03b8633
2020-01-06 09:41:49 +01:00
Kiyoung Kim
24ccfc244b Merge "Update linkerconfig to target out directory" 2020-01-02 04:18:31 +00:00
Nikita Ioffe
1131a211dc Reset sys.shutdown.requested property
Otherwise, if userspace reboot is triggered from the framework, it will
end up in userspace reboot loop until watchdog kicks in triggers full
reboot.

Bug: 135984674
Test: adb shell svc power reboot userspace
Change-Id: I0de451aad4ea236a3ff1c20b317b01c6529b6231
2019-12-30 16:06:35 +00:00
Kiyoung Kim
3b2dbe9d75 Update linkerconfig to target out directory
Current linkerconfig targets for specific output file. However,
linkerconfig will generate more than 1 file based on APEX modules, so it
should take argument for target directory rather than target file. This
change updates linkerconfig's argument to point output directory.

Bug: 146993126
Test: m -j passed & Cuttlefish succeeded to boot
Change-Id: I3a720a047077688582436aabd307adafeafc5398
2019-12-30 18:44:41 +09:00
Kiyoung Kim
3c0e06d829 Merge "Use generated linker config only" 2019-12-27 00:08:06 +00:00
Kiyoung Kim
32082a7e28 Use generated linker config only
Remove prebuilt ld.config.txt to use linker config from generator only,
including legacy and vndk_lite case.

Bug: 139638519
Test: m -j passed

Change-Id: I043d51daca8cde1977236f9fbda919176a18618d
2019-12-24 14:18:53 +09:00
Nikita Ioffe
018ddd7a6f Unify logic for resetting properties before userspace reboot
Since I was there, added two more properties to reset, and switched
ordering of sys.init.updatable_crashing and
sys.init.updatable_crashing_process_name setprops to make sure that
process name is already set when apexd/PackageWatchdog get's notified
about sys.init.updatable_crashing.

Also fixed a typo in what HandleUserspaceReboot function.

Test: adb reboot userspace
Bug: 135984674
Change-Id: I954ec49aae0734cda1bd833ad68f386ecd808f73
2019-12-20 17:55:13 +00:00
Kiyoung Kim
5bc7941be3 Merge "Remove ld.config.recovery.txt build" 2019-12-20 07:10:29 +00:00
Kiyoung Kim
80416f7a80 Merge "Generate linkerconfig per mount namespaces" 2019-12-20 03:30:33 +00:00
Kiyoung Kim
e4d3f2123f Generate linkerconfig per mount namespaces
There are two namespaces from init - bootstrap and default - and those
will have different set of APEX modules. To support difference between
two namespaces, linker config should be generated per namespace and each
namespace should use its own linker configuration. As a first step of
the work, this change will create different mount point for each
namespace, and re-generate linker config after APEX mount from each
namespaces.

Bug: 144664390
Test: m -j passed & tested from cuttlefish
Change-Id: Iac2e222376ec4b0ced6c29eed18b21d39ff0b1ba
2019-12-20 09:46:59 +09:00
Songchun Fan
a1344fa6d7 Merge "[incremental] create /data/incremental in init.rc" 2019-12-19 18:14:06 +00:00
Kiyoung Kim
986e453d9c Remove ld.config.recovery.txt build
Remove ld.config.recovery.txt build as this will be replaced to be
generated from linkerconfig during build time.

Bug: 146414198
Test: m -j passed
Test: Checked linker config generated under recovery's system/etc
Change-Id: I0d2aa121973c4c99e68f44f4e76e4eab74dc2f95
2019-12-19 16:37:43 +09:00
Songchun Fan
284962431b [incremental] create /data/incremental in init.rc
We use /data/incremental to keep all the directories that are mounted on
the Incremental File System.

Since system_server does not have permission to dynamically create dirs
directly under /data, we create /data/incremental in init.rc.

Test: boots
BUG: 136132412
Change-Id: Ic90cc8f652672a8d4459c0cd38db9c0872217af4
2019-12-18 09:26:51 -08:00
Martijn Coenen
0dbb2a75f2 Revert "Have /storage always point to sdcardfs by default."
This reverts commit 5d53bfce2d.

Reason for revert: for consistency, we've decided that for now, all code will have the same view of /storage: FUSE. Will address the TODO here later.

Change-Id: Ia75e23c91fb098f6309c160de2889f06507c3717
2019-12-17 13:45:10 +00:00
Ricky Wai
fdc0986554 Create /mnt/data_mirror/cur_profiles in init.rc
Also, bind mount /data/misc/profiles/cur to /mnt/data_mirror/cur_profiles

Bug: 143937733
Test: Directories are created and mounted
Change-Id: Idcf73b84db84dc671ec5a5025f4b4ec1bc5fd1fc
2019-12-13 17:32:18 +00:00
Martijn Coenen
5d53bfce2d Have /storage always point to sdcardfs by default.
This is a partial revert of change
Idf851b3a42910e0ce8fdd75daea1cce91dd1aa98, and brings us back to the
state we shipped in Q.

The default behavior for now is that we want native daemons to use the
default sdcardfs view, as they did before. Zygote-spawned apps will then
get the correct view assigned to them as they get spawned.

Bug: 146189163
Test: atest AdoptableHostTest
Change-Id: I2248f39e029138962a41a6ead944431414c901ad
2019-12-13 16:52:11 +01:00
rickywai
3014815103 Merge "Create /data_mirror in init.rc" 2019-12-13 14:22:37 +00:00
Treehugger Robot
8afa4a0637 Merge "Adding the AVB public key for Q-Developer-GSI" 2019-12-13 03:13:02 +00:00
Ricky Wai
3cca270e95 Create /data_mirror in init.rc
Mount a tmpfs on top of it, and serve as a mirror of /data/data
and /data/user_de, which will be used when zygote forks and
overlay its CE and DE storage to prevent app can see other applications.

Also, changed /data/user/0 from symlink to bind mount, so
/data_mirror/data_ce/null can just bind to /data/user directly.

Bug: 143937733
Test: Directories are created and mounted
Change-Id: Ic72c47c9d3dc0ffc98510f5bb351eccf76524232
2019-12-12 14:44:44 +00:00
Nikita Ioffe
5183983af2 Merge "Move setprop sys.usb.configfs 0 to on init action" 2019-12-12 02:41:16 +00:00
Kiyoung Kim
597eca8a8c Merge "Move linker config under /linkerconfig" 2019-12-11 02:55:06 +00:00
Nikita Ioffe
c796f918db Move setprop sys.usb.configfs 0 to on init action
This should solve the problem of
`property:sys.usb.config=adb && property:sys.usb.configfs=0` action
being wrongly triggered during userspace reboot.

Also reset some adbd-related property in `on userspace-reboot-requested`
action to make sure that userspace reboot sequence is as close as
possible to normal boot sequence w.r.t adbd.

Test: adb reboot userspace
Test: checked property:sys.usb.config=adb && property:sys.usb.configfs=0
  action is not triggered

Bug: 135984674
Change-Id: Icf40386399ee84d01228020e65f71ba473d72822
2019-12-10 19:16:15 +00:00
Elliott Hughes
3498578c4c Merge "Be more careful about symlinking a file that actually exists on the host." 2019-12-10 17:59:15 +00:00
Bowgo Tsai
bd0853602b Adding the AVB public key for Q-Developer-GSI
Bug: 144399552
Test: m q-developer-gsi.avbpubkey
Change-Id: If140c429c8b8324c0c2364aa67e72e41748b42b4
2019-12-10 13:02:31 +08:00
Oli Lan
4370ff58ae Create directory for snapshots of DE_sys apex data.
This creates the /data/misc/apexrollback directory which will
hold snapshots of DE_sys apex data directories (i.e. it will
hold backups of data from /data/misc/apexdata for particular
apexes).

See go/apex-data-directories for details.

Bug: 141148175
Test: Built and flashed, checked directory was created.
Change-Id: If45377a9b29cc1f52dd08ea1339829e3bb3032e9
2019-12-09 11:12:53 +00:00
Oli Lan
13e51e7f0b Create DE_sys APEX data directories.
This creates the directory /data/misc/apexdata, at the same time as other
directories under /data/misc. Then, when apexd has finished activating
APEXes, a directory is created under /data/misc/apexdata for every
APEX, with the same name as the APEX module name.

See go/apex-data-directories.

APEXes are discovered by scanning the /apex directory. It may be better
to delegate this process to a library, but it is proposed to defer that
change to a future CL.

Bug: 141148175
Test: Built and flashed, checked directories were created.
Change-Id: I639d6f490ae0b97f116ce38ff3ac348bd73aa20e
2019-12-09 11:10:42 +00:00
Kiyoung Kim
99df54be93 Move linker config under /linkerconfig
Currently linker config locates under /dev, but this makes some problem
in case of using two system partitions with chroot. To match system
image and configuration, linker config better stays under /linkerconfig

Bug: 144966380
Test: m -j passed && tested from cuttelfish
Change-Id: Iaae5af65721eee8106311c1efb4760a9db13564a
2019-12-09 19:45:11 +09:00
Elliott Hughes
3af236c693 Be more careful about symlinking a file that actually exists on the host.
Avoids this error on later runs:

  ln: cannot create symbolic link from '/sys/kernel/debug' to 'out/target/product/walleye/root/d/debug': Permission denied

Bug: http://b/145148158
Test: touch * ; mm -j32 -k
Change-Id: I0c1c0c6e7666c0bc3373687d8c1c7bdf0847913f
2019-12-06 17:43:23 -08:00
Jaegeuk Kim
7bf14bb932 Merge "rootdir: init.rc to limit discard size to 128MB" 2019-12-06 21:59:19 +00:00
Jaegeuk Kim
fe9e8a3fa5 rootdir: init.rc to limit discard size to 128MB
In any case, UFS storage suffers from long discard latency.

Change-Id: Iaa8ef6eb862934af43254bd10873a12c3d34e926
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2019-12-05 15:58:18 -08:00
Anton Hansson
3c5cc31824 Run the derive_sdk service
Run this process as early as possible in the boot -- right
after its config has been parsed from the apex. This ensures
the sdk prop is set as early as it can be, should some other
early process need to look at it.

Note: this is unlikely to be the permanent way this gets run,
as it's only needed when apexes update.

Bug: 137191822
Test: boot && adb shell getprop | grep sdk_info
Change-Id: Ia48ef89435ca165333b52d653e3131f71a522747
2019-12-05 15:38:37 +00:00
Martijn Coenen
58bd37f1e3 Merge "Remove bootstrapping the passthrough mount." 2019-11-29 08:41:37 +00:00
Shuo Qian
8834223ff8 Merge "A system folder for emergency number database OTA" 2019-11-27 19:14:50 +00:00
Shuo Qian
f0e65d852a A system folder for emergency number database OTA
Test: Manual; tested with the other CL in the same topic
Bug: 136027884
Change-Id: Ia5675613b9ae19927108d089955d2900d97c892c
2019-11-27 19:04:39 +00:00
Martijn Coenen
cc67ff5add Remove bootstrapping the passthrough mount.
This will be taken care of by vold (when necessary).

Bug: 135341433
Test: device boots, passthrough mount still works
      atest AdoptableHostTest
Change-Id: I5a144eff0e4220fa0154bfa7d62a2dec625c88bc
2019-11-22 13:13:50 +01:00
Nikita Ioffe
c5282e4c6b Merge "Add sysprops for start & end of userspace reboot" 2019-11-14 21:50:59 +00:00
Nikita Ioffe
c0df1874ad Add sysprops for start & end of userspace reboot
There will be useful in debugging/logging events to statsd.

Also as part of this CL, sys.init.userspace_reboot.in_progress property
is now used as a mean of synchronization. It is set directly in
DoUserspaceReboot, to make sure that all the setprop actions triggered
by userspace-reboot-requested were processed.

Test: adb reboot userspace
Test: adb shell getprop sys.init.userspace_reboot.last_started
Test: adb shell getprop sys.init.userspace_reboot.last_finished
Bug: 135984674
Change-Id: I9debcd4f058e790855200d5295344dafb30e496a
2019-11-14 01:38:05 +00:00
Marco Ballesio
726a68cb40 Add support for freezer cgroup
Adds the freezer cgroup to process groups

Change-Id: Ib7a8dbe776ff156ff3827b9a659365384f3e6ac8
Bug: 143308662
Test: manual - frozen processes aren't scheduled for execution until
unfrozen
2019-11-13 20:21:07 +00:00
Tom Cherry
47cdf6c078 Merge "Move init and ueventd scripts from / to /system/etc" 2019-11-13 14:36:47 +00:00
Tom Cherry
c9f5353ad3 Move init and ueventd scripts from / to /system/etc
There is no reason for these scripts to continue to exist in /, when
they are better suited for /system/etc.  There are problems keeping
them at / as well, particularly that they cannot be updated with
overlayfs.

Bug: 131087886
Bug: 140313207
Test: build/boot
Merged-In: I043d9a02ba588ca37ceba2c4e28ed631792b2586
Change-Id: I043d9a02ba588ca37ceba2c4e28ed631792b2586
2019-11-08 10:15:49 -08:00
Suren Baghdasaryan
8106c8e09f Merge changes from topic "native process registration"
* changes:
  init: Add support for native service registration with lmkd
  lmkd: Support process types when registering a process
  lmkd: Add library function to unregister a process
  lmkd: Prepare lmkd to support connection from init process
  lmkd: Restrict process record modifications to the client that created it
2019-11-08 17:25:10 +00:00
Treehugger Robot
7e5fb6b322 Merge "migrate *.libraries.txt from Make to Soong" 2019-11-08 04:04:14 +00:00
Paul Crowley
449282c021 Merge "Make encryption action an argument to mkdir" 2019-11-07 20:06:47 +00:00
Suren Baghdasaryan
c29c2baa69 init: Add support for native service registration with lmkd
init should be able to register native services with lmkd so that they
can be killed when needed. Only processes with oom_score_adjust not
equal to the default -1000 will be registered with lmkd because with the
score that low the process is unkillable anyway.
Inform lmkd when a registered process is killed so that the record can be
removed.
Change init.rc to start lmkd during init phase so that it is there to
register other services.
Replace hardcoded oom_score_adj values with appropriate definitions.

Bug: 129011369
Test: boot and verify native service registration
Change-Id: Ie5ed62203395120d86dc1c8250fae01aa0b3c511
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-11-07 18:19:31 +00:00
Nikita Ioffe
42697d3f18 Make remount into checkpointing for ext4 userdata a no-op
We are going to teamfood userspace reboot soon, and in order to gather
as much data as possible we are fine with ignoring checkpointing for the
devices with ext4 (teamfood will be a very limited set of people that
are aware what they've signed for).

As result of this, we don't need to reset vold and kill zram backing
device. Added a TODO to restore that functionality if needed.

Since I was there, fixed yet another typo in userspace-reboot-resume -_-

Bug: 135984674
Test: adb reboot userspace
Change-Id: I2b7a93aaf738fe9bec9d606d7e11aefb325550b1
2019-11-06 20:12:08 +00:00
Jooyung Han
c2b56dc10e migrate *.libraries.txt from Make to Soong
Migrating these files to soong modules and those modules are defined
under /packages/modules/vndk since they are highly coupled with vndk.

Bug: 141450808
Test: m llndk.libraries.txt
Change-Id: Id33366f604e3e6696a9be95dc50f40d143325697
2019-11-06 16:55:32 +09:00
Paul Crowley
68258e8444 Make encryption action an argument to mkdir
FscryptSetDirectoryPolicy no longer tries to infer the action from the
filename. Well mostly; it still assumes top-level directories in /data
should be encrypted unless the mkdir arguments say otherwise, but
it warns.

Bug: 26641735
Test: boot, check log messages
Change-Id: Id6d2cea7fb856f17323897d85cf6190c981b443c
2019-11-05 16:26:43 -08:00
Josh Gao
594f70ffb8 Move adbd to an apex.
Test: adb shell "su 0 readlink /proc/\`pidof adbd\`/exe"
Change-Id: I84dfe4d1b28b619f98c03a2c8eeef2c783d30af2
2019-11-04 15:52:16 -08:00
Nikita Ioffe
ac692148e5 Fix typo in userspace-reboot-requested trigger
It should userspace-reboot-requested, not userspace-reboot

Test: adb reboot userspace
Bug: 135984674
Change-Id: I1e844b7705eb70ee3702a1dc0432644592666364
2019-11-01 20:56:33 +00:00
Jooyung Han
a18363cb97 Use soong-generated vndk*libraries.txt files
linkerconfig reads vndk-related libraries.txt files. Now these files are
generated by soong.

Bug: 142963962
Bug: 141450808
Test: m && device boots && TH
Change-Id: I98c2f934815238cacd4ec8536ce2f9f24bbf1b32
2019-10-31 11:40:22 +09:00
Treehugger Robot
f77c98a780 Merge "Revert "Revert "Revert "Revert "Use com.android.vndk.current variant for vndk list""""" 2019-10-30 04:29:37 +00:00
Jooyung Han
e5811e8967 Revert "Revert "Revert "Revert "Use com.android.vndk.current variant for vndk list""""
This reverts commit 3cb19a74f2.

Reason for revert: Fix b/143374795

Change-Id: I21dae5ff3c9bf05ac15ac26210d7c8d7f9c46e1c
2019-10-28 21:08:04 +00:00
Greg Kaiser
b6a3d3f9d3 Merge "Revert "Revert "Revert "Use com.android.vndk.current variant for vndk list"""" 2019-10-28 17:12:33 +00:00
Nikita Ioffe
8a603a7f9b Merge "Userspace reboot: Support remounting userdata for f2fs" 2019-10-28 16:28:23 +00:00
Jooyung Han
3cb19a74f2 Revert "Revert "Revert "Use com.android.vndk.current variant for vndk list"""
This reverts commit 74f23d7ae6.

Reason for revert: b/143374795

Change-Id: I35cb387b87d3eb2eb0963b669e359ff538c28c90
2019-10-28 05:07:46 +00:00
Xin Li
128bbfc7be Merge Coral/Flame into AOSP master
Bug: 141248619
Change-Id: I32e18ca4131b81846dca976699df8be71549e4e1
Merged-In: I6b95cf1a731c4dc09a7897f3114e2ad6595d60bb
2019-10-25 10:28:40 -07:00
Nikita Ioffe
12a36076a7 Userspace reboot: Support remounting userdata for f2fs
Test: adb reboot userspace
Test: adb shell /system/bin/vdc startCheckpoint 1;
      adb reboot userspace
Bug: 135984674
Change-Id: I227f2c1cc18495d893decb2df5173fc7a7919df6
2019-10-25 16:27:10 +01:00
Jooyung Han
74f23d7ae6 Revert "Revert "Use com.android.vndk.current variant for vndk list""
This reverts commit 08f2376d70.

Bug: 141451661
Test: m && device boot
2019-10-19 02:32:28 +09:00
Jooyung Han
5d1428b437 Merge "Revert "Use com.android.vndk.current variant for vndk list""
am: 047a7d21d9

Change-Id: Ia4d7f11d7a76c34f42cb9e7bc940f0d9a87156f9
2019-10-17 05:08:27 -07:00
Treehugger Robot
047a7d21d9 Merge "Revert "Use com.android.vndk.current variant for vndk list"" 2019-10-17 11:50:47 +00:00
Jooyung Han
08f2376d70 Revert "Use com.android.vndk.current variant for vndk list"
This reverts commit 82f94d61cb.

Reason for revert: some targets are broken

Bug: 142773030
Change-Id: Ida59c52af3d2fd694855fcee60b5bb0d99c85f8d
2019-10-16 23:47:32 +00:00