Commit graph

334 commits

Author SHA1 Message Date
bowgotsai
b51722b4e2 fs_mgr: support using libavb to enable dm-verity
external/avb/libavb provides the new Android Verified Boot (AVB) flow.
It has different verity metadata format than previous formats in
fs_mgr_verity.cpp fs_mgr should support using libavb to read the metadata
(a.k.a. HASHTREE descriptor in AVB) to enable dm-verity in kernel.

Two important files in this commit:

 - fs_mgr_avb_ops.c: an implementation of struct AvbOps* for libavb to do
   platform dependent I/O operations, e.g., read_from_partition.

 - fs_mgr_avb.cpp: it reads the metadata (a.k.a. vbmeta images in AVB) from
   all partitions, verifies its integrity against the values of
   androidboot.vbmeta.{hash_alg, size, digest} passed from bootloader in
   kernel command line. Then enable dm-verity for partitions having the
   corresponding HASHTREE descriptor and with an 'avb' fstab flag.

Bug: 31264231
Test: Enable dm-verity on /system partition
Test: Enable dm-verity with FEC on /system partition

Change-Id: I4652806984fe5a30c61be0839135b5ca78323d38
2017-01-25 18:03:20 +08:00
Connor O'Brien
46fec487a9 Add eraseblk and logicalblk fs_mgr flags
When doing a factory reset in recovery, flash erase & logical block
sizes are needed for tuning the parameters of the new userdata image.
Add flags to allow this information to be stored in recovery.fstab

Test: Factory reset marlin & confirm userdata is rebuilt correctly
Bug: 33243520
Change-Id: I6c4414d4e9026be4a3646523656ac151e93015e7
Signed-off-by: Connor O'Brien <connoro@google.com>
2017-01-24 18:43:39 -08:00
Treehugger Robot
d945f27cd6 Merge "fs_mgr: fix clang static analyzer warning" 2017-01-24 20:58:19 +00:00
Jin Qian
8b7eb7bb2a fs_mgr: fix clang static analyzer warning
Pointer from strdup is lost hence triggers mem leak warning from
clang, since ptr returned from basename may not point to start of
duplicated string any more.

Switch to use gnu version of basename which doesn't modify input
string so that strdup is no longer necessary.

Bug: 27126348
Test: compile

Change-Id: I937a68c01c223230932c932bffdd35da6503c3c4
2017-01-20 18:01:49 +08:00
Elliott Hughes
ebeaa67c0c Remove fs_mgr's bogus external/openssl/include LOCAL_C_INCLUDES entry.
Bug: N/A
Test: builds
Change-Id: Icaf095f0c25fae5c1175dbb630bc05c63af72d75
2017-01-15 11:52:35 -08:00
bowgotsai
47aa2a7520 fs_mgr: use std::string for function parameters in fs_mgr_dm_ioctl.cpp
Make the code more C++-ish by replacing char* or char** with
std::string&.

Bug: 31264231
Test: check device can boot with dm-verity
Change-Id: Ie3ca3f449b52959d1a7b2887d722eb5ce366c4f9
2017-01-13 17:39:04 +08:00
bowgotsai
3de625d109 fs_mgr: moves common functions out of fs_mgr_verity.cpp
This commits moves some common functions out of fs_mgr_verity.cpp to be
reused by other verified boot flows. It includes:
 - Move common functions into fs_mgr.c
 - Move dm_ioctl related functions to a new file: fs_mgr_dm_ioctl.cpp

Bug: 31264231
Test: check device can boot with dm-verity

Change-Id: Iaa0d8031efbaae12aa28f872f62d3fc3d3763b51
2017-01-13 10:52:44 +08:00
Alex Deymo
7e0b322978 Merge changes from topic 'host_suffix_cleanup'
* changes:
  Remove "_host" and "_static" suffix from libsparse definition.
  Remove "_static" and "_host" suffix from libext4_utils.
2017-01-12 21:23:11 +00:00
Alex Deymo
b0c395955d Remove "_host" and "_static" suffix from libsparse definition.
This now combines all the "libsparse" libraries into the same soong
target. A minor side-effect of this change is that the libsparse
static library depends on the libz shared library instead of the libz
static library. This minor change has no effect since targets using
the static libsparse library need to explicitly include either the
static libz or the shared one.

Bug: 34220783
Change-Id: I8f41586cf4c3336791cfa57ab4f5ae59a76d7ffa
2017-01-11 19:15:11 -08:00
Alex Deymo
705353ae27 Remove "_static" and "_host" suffix from libext4_utils.
Bug: 34220783
Change-Id: I967dbaa9c48ad1feed2369c3a40f745b86a350f8
2017-01-11 14:05:42 -08:00
Prashant Malani
17f248d2e4 fs_mgr: Fix disable-verity for verifyatboot partitions
This allows a remount to be performed on partitions which have been
verified at boot, without causing the verity service to complain of
"corrupted" blocks that could have been modified as a result of a
remount (while the verity checksum remained unchanged).

(cherry picked from commit dd78ae75ff)

Bug: 32638755
Test: Compile
Change-Id: I77cf7dd20ee5c5f5dac80f73f292e32583fe5906
2017-01-11 22:05:16 +08:00
Prashant Malani
2cdc67eed5 fs_mgr: Add support for at-boot verification
Running dm-verity on heavily accessed partitions leads to performance
slowdowns, especially on low-RAM and slow-CPU devices.

This patch introduces a flag to allow an entire verified partition to be
read once at boot, to check for corruptions. If the reads are
successful, we can mount the partition as raw & read-only, and if not,
we can revert to mounting it as a verity partition, just like before.

Usage of this flag will entail a slowdown of time-to-boot, but should
lead to improvements in runtime performance.

(cherry picked from commit 34543c03e6)

Bug: 32433608
Test: Compile
Change-Id: I97717683a00ad6fa347e63b72b1a9bf1d2946315
2017-01-11 22:00:25 +08:00
Keun-young Park
22e8199175 e2fsck: drop -f when TARGET_USES_MKE2FS is enabled
- Drop forced (-f) e2fsck check when the product has
  enabled new ext4 generation by setting TARGET_USES_MKE2FS.
- The new generation tool is supposed to give better stability,
  thus justifying dropping -f.
- This should help reducing boot-up time as full check (-f) can
  increase boot-up time significantly depending on amount of data.

bug: 32246772
Test: many reboots
Change-Id: I631525bf7504bbfb025e170c8d24ad9d3ef3532e
2017-01-10 10:17:57 -08:00
Treehugger Robot
abc26ed753 Merge "fs_mgr: add verify_dev flag to fs_mgr_setup_verity()" 2017-01-10 04:00:19 +00:00
forfun
c5c0306424 modify a minor error in mount_with_alternatives
Test: when called with end_idx = null

Change-Id: I7e5d298f496847acb4aefbaad66cd98e907467bc
Signed-off-by: forfun <forfun414@gmail.com>
2016-12-16 07:02:57 +00:00
Hung-ying Tyan
ecfce13ce2 fs_mgr: add verify_dev flag to fs_mgr_setup_verity()
Bug: 33682519
Test: Tested on bullhead with https://android-review.googlesource.com/#/c/315463.
Change-Id: Ie12230c6f77a2834c179e44b59817292d58726f7
2016-12-16 15:00:05 +08:00
Jeff Sharkey
6d89610d1a Add fs_mgr option to enable/disable quotas.
To support upcoming disk usage calculation optimizations, this change
adds a new 'quota' mount flag.  As part of mounting an ext4 device,
we now enable/disable the quota feature using tune2fs to match the
requested value in the fstab.

When changing the quota status, we force a fsck pass on the device
before actually mounting it to prime the quota data structures which
are stored in hidden inodes.

Changing quota state and priming the data structures needs to happen
before we actually mount the device, so fs_mgr is the best place to
place this logic.

Test: builds, boots, enables and disables quota
Bug: 27948817
Change-Id: I7ccbf97cbc4a679bdd7a31a77be4b99aa9a88e66
2016-12-15 16:35:50 -07:00
liminghao
9a0fd1d5d3 fs_mgr: support to reserved some blocks for an ext2/3/4 partition.
These reserved blocks used to root or claim to CAP_SYS_RESOURCES process.

Change-Id: I4893bdb08399bf31a7640d4a63f4952cd636576f
Merged-In: I4893bdb08399bf31a7640d4a63f4952cd636576f

Signed-off-by: liminghao <liminghao@xiaomi.com>
2016-12-15 16:26:53 -07:00
Jin Qian
960584eeb0 Merge "fs_mgr: change MF_MAX_COMP_STREAMS define to match internal master"
am: 72662414f6

Change-Id: I2d761ee4db65f6c5c98f3cea2f58588e4bc66ec5
2016-11-22 18:47:38 +00:00
Jin Qian
0067e03251 fs_mgr: change MF_MAX_COMP_STREAMS define to match internal master
Change-Id: I53a8c6158b4dd1bf5e14ef0a842b7f43ca8bae31
2016-11-18 16:38:40 -08:00
Peter Enderborg
3c4dfb6fc4 Merge "Add support for max_comp_streams option for zram"
am: a9ea1e4d99

Change-Id: I0ef7127e1352b7dc9ae226bee7fe340d864f97ab
2016-11-18 23:25:21 +00:00
Peter Enderborg
4d217f02d3 Add support for max_comp_streams option for zram
With this option the fstab can include a parameter for zram
the enables more streams for kernels that does not have
dynamic stream task handling.

Test: Made sure max_comp_streams is set according to fstab.
Change-Id: I22e158a075a8a86b4e80d3b13989896929c0d223
2016-11-18 21:19:25 +00:00
Jin Qian
905948ed74 fs_mgr: fix clang static analyzer warning
Pointer from strdup is lost hence triggers mem leak warning from
clang, since ptr returned from basename may not point to start of
duplicated string any more.

Switch to use gnu version of basename which doesn't modify input
string so that strdup is no longer necessary.

Bug: 27126348

Change-Id: Iadb5cf343437a1e27e588ee067b084897633ea07
Merged-In: I937a68c01c223230932c932bffdd35da6503c3c4
2016-11-08 20:07:31 +00:00
Wei Wang
496e667966 Merge "Make sure wait for the dm device"
am: d70a5feb60

Change-Id: If1e188c32548995413e49c1f7edece8d2c526bb2
2016-10-26 22:35:28 +00:00
Wei Wang
dba750e0e0 Make sure wait for the dm device
Bug: 32408249
Test: on m/s
Change-Id: I65fa4fec94c82ef51d2c8d0aabf9e90b8448f27f
2016-10-26 13:40:23 -07:00
Mark Salyzyn
82ce1f1ff2 fs_mgr: use __android_log_is_debuggable()
am: e528be5e7d

Change-Id: I3dbe3e0f6e3076a24af3fd868907ad7e688517e5
2016-10-18 16:46:19 +00:00
Mark Salyzyn
e528be5e7d fs_mgr: use __android_log_is_debuggable()
Test: compile and boot smoke test
Bug: 27566046
Bug: 31456426
Change-Id: Ibf4774f742e5a5b7db75d17642ff483a4a0fc0c5
2016-10-14 11:12:24 -07:00
Tao Bao
6efc7a787b Merge "Update the header path for ext4_utils." am: 5bc3ce85cf am: 148b85b050
am: 2815ac5584

Change-Id: I966296de6eb4ff7518b9cfcd5853fe919765b826
2016-10-10 22:14:48 +00:00
Tao Bao
6d881d6db4 Update the header path for ext4_utils.
Test: `mmma system/core`

Change-Id: I6291d10d6c8d4972aeca55596baa83f555496193
2016-10-09 10:23:36 -07:00
Wei Wang
d61a7e2da4 Split fstab mount into 2 phases
This will make it possible to start some key services before mounting
data partition

Bug: 30118894
Change-Id: Ia9f8cc035de6cc0df9a61605864915efa0266d7f
(cherry picked from commit abfbec342f)
2016-09-06 21:04:26 +00:00
Wei Wang
254f44363b Split fstab mount into 2 phases
This will make it possible to start some key services before mounting
data partition

(cherry picked from commit abfbec342f)

Bug: 30118894
Change-Id: Ia9f8cc035de6cc0df9a61605864915efa0266d7f
2016-09-06 11:39:05 -07:00
Hung-ying Tyan
1263097328 Merge "Mount /vendor and /odm early" am: 35569e9d68 am: 46bfc918d0
am: d1f49a43fd

Change-Id: I6dc53f60771ad0e660e248efdc1b13734fba3061
2016-08-18 05:10:41 +00:00
Hung-ying Tyan
46bfc918d0 Merge "Mount /vendor and /odm early"
am: 35569e9d68

Change-Id: I9b5360bf3036fa88e770d686ab06b8f4cff80d7c
2016-08-18 05:04:43 +00:00
Hung-ying Tyan
99c4a8a6b3 Mount /vendor and /odm early
Right now these two partitions are mounted in the fs stage of the init
process. As a result, many vendor/ODM files needed earlier in the boot
process (e.g., init.<hardware>.rc, fstab.<hardware>.rc,
uevent.<hardware>.rc, SELinux policy files etc) can only live on the root
partition.

To prevent vendors/ODMs from polluting the root partition, this patch makes
it possible to mount the vendor and ODM partitions in the first stage of the
init process. The fstab info of both partitions to be mounted early is
composed from new kernel cmdline arguments android.early.prefix and
android.early.fstab.

For example, with:
android.early.prefix=/sys/devices/1010000.msdc0/mmc_host/mmc0/mmc0:0001/block/mmcblk0/
android.early.fstab=mmcblk0p10+/odm+ext4+ro+verify\nmmcblk0p09+/vendor+ext4+ro+verify

the final fstab string will be:
/sys/devices/1010000.msdc0/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p10 /odm ext4 ro verify
/sys/devices/1010000.msdc0/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p09 /vendor ext4 ro verify

The android.early.prefix is optional. When it is missing, the final fstab
string will be directly converted from android.early.fstab.

This patch also makes sure that the early mounted partitions are dm-verity
enabled so that they are trust worthy to store system files.

BUG=27805372

Change-Id: I3cf32482a5ec65445ba3aedab2164c7ba8f12694
2016-08-17 17:21:35 +08:00
Josh Gao
7480771909 Merge "libcrypto_utils: convert to Soong." am: c1a9a21ffe am: 87ef590bc1
am: a1da027a3c

Change-Id: Ie693d3de13b0df24ea83e70af3fa385a77ed8b33
2016-08-08 18:39:23 +00:00
Josh Gao
87ef590bc1 Merge "libcrypto_utils: convert to Soong."
am: c1a9a21ffe

Change-Id: I9cf76646d4537750c4d4080234d3384fb307e610
2016-08-08 18:33:49 +00:00
Josh Gao
47763c3a09 libcrypto_utils: convert to Soong.
Bug: http://b/30708454
Change-Id: Iaad64272ced766f87e67f2877e990afccc558065
2016-08-05 18:07:36 -07:00
Chih-Hung Hsieh
3afa5a9afa Merge \\\"Fix clang-tidy performance warnings in fs_mgr.\\\" am: 44c909d467 am: be25035ddb
am: aa0628ec50

Change-Id: I28c0f3cf75c1e225b3d24b77934d055dd9edf854
2016-07-28 17:24:29 +00:00
Chih-Hung Hsieh
be25035ddb Merge \"Fix clang-tidy performance warnings in fs_mgr.\"
am: 44c909d467

Change-Id: Iff90e929bfb2cf1335e5764b99454601eb6316ef
2016-07-28 17:18:36 +00:00
Chih-Hung Hsieh
73da05d354 Fix clang-tidy performance warnings in fs_mgr.
* Use const reference type for for-loop index variables
  to avoid unnecessary copy.

Bug: 30413223
Change-Id: I5514384ef3af77c00aa3e8417acd8d70981e0afb
Test: build with WITH_TIDY=1
2016-07-27 16:12:54 -07:00
Elliott Hughes
6605b0b23a Merge \\\"Make klog_fd thread-safe and make klog_init a no-op.\\\" am: 588b770063 am: 73d363bbc1
am: 7288ac3982

Change-Id: I46bbcb64eecc01ec7bd8bb502237c1b9057befc4
2016-07-08 17:12:48 +00:00
Elliott Hughes
73d363bbc1 Merge \"Make klog_fd thread-safe and make klog_init a no-op.\"
am: 588b770063

Change-Id: I884276a8f8b8209f6e956c5fb410e8265184e1b5
2016-07-08 17:05:25 +00:00
Elliott Hughes
171a829c39 Make klog_fd thread-safe and make klog_init a no-op.
I'll come back and remove klog_init when I've removed other calls to it.

Change-Id: Iad7fd26d853b4ddc54e9abd44516b6f138cbbfcb
Test: booted N9, looked at "adb shell dmesg" output.
2016-06-29 16:16:41 -07:00
Sami Tolvanen
6de58ac5d7 fs_mgr_verity: fix verity_update_state for A/B devices
am: 9af867e7bd

Change-Id: I676d0ece31d3cc23701923e5cda2be2155d0c00e
2016-06-20 19:38:50 +00:00
Sami Tolvanen
9af867e7bd fs_mgr_verity: fix verity_update_state for A/B devices
Use the correct device name when system is mounted as root, and
validate dm-verity status to avoid confusing it with dm-linear.

Bug: 29277442
Change-Id: I36e115189f9a9430bad4bf89f26a376bcb8e8168
2016-06-17 17:17:04 -07:00
Tao Bao
df4a278398 Merge \\\"fs_mgr: Track the bootloader_message struct change.\\\" am: 4d34653720 am: 6f110854ce
am: e96a44e26c

Change-Id: Icbd6307328440c7c615e6af51a6e9ea4945e3d7d
2016-06-14 16:27:37 +00:00
Tao Bao
e96a44e26c Merge \\"fs_mgr: Track the bootloader_message struct change.\\" am: 4d34653720
am: 6f110854ce

Change-Id: I45831ba35a17b68afd3adda55120e78f6a10779d
2016-06-14 16:22:59 +00:00
Tao Bao
4d34653720 Merge "fs_mgr: Track the bootloader_message struct change." 2016-06-14 16:09:16 +00:00
Tao Bao
96c9f2d047 fs_mgr: Track the bootloader_message struct change.
A/B-specific info (slot_suffix) has been moved into struct
bootloader_message_ab.

Bug: 29193360
Change-Id: Ic655e23a2d74366e713807add15a6e9d04535cf5
2016-06-09 15:13:15 -07:00
Sami Tolvanen
98f1ea00e5 fs_mgr: validate corrected signatures
If signature verification fails and we have an error corrected
signature available, attempt to verify that instead.

Needs changes from
  Ie913c21ba1d07d6df4c6feeb7226b2ec963f4d19

Bug: 28943429
Change-Id: I7d48701916fe430b17aa05acb120f22a1802733d
(cherry picked from commit 830126637a)
2016-06-08 09:42:59 -07:00