Commit graph

76 commits

Author SHA1 Message Date
Bowgo Tsai
eeea724900 Merge changes from topic 'fstab_relocation' am: ac13718d0a am: 8f7125fbee
am: 9fc983315a

Change-Id: Ic62c46c160e9995ff11067300ec5c831301bceb9
2017-03-10 03:17:50 +00:00
Bowgo Tsai
47d342739a fs_mgr: add fs_mgr_read_fstab_with_dt() API
With the early mount support in init, fstab entries of verified partitions
(e.g., /system, /vendor) will be moved into device tree in kernel image.

Those early mount fstab entries will be removed from the fstab file to
prevent duplicated and/or inconsistent settings.

This change adds a new function: fs_mgr_read_fstab_with_dt(), to return
the combined results from both places. It also removes
fs_mgr_read_fstab_file() from the public APIs and makes it as an
internal function.

Bug: 35811655
Test: early mount /vendor with dm-verity on sailfish

Change-Id: I2fba3614685bf9f852a789cda6f53013e2164e60
2017-03-09 21:15:08 +08:00
Wei Wang
eebe07c539 Merge "fs_mgr: fix const parameter in fs_mgr_do_tmpfs_mount" am: 7a5d535cd2 am: be838ae027
am: 771f642d89

Change-Id: Ie8cd01116a1f0437eee80168dc5f6aa57b08fa55
2017-02-25 05:23:40 +00:00
Wei Wang
4d71bc5350 fs_mgr: fix const parameter in fs_mgr_do_tmpfs_mount
Bug: 35425974
Test: mma, marlin/angler boot
Change-Id: Ibadd04ad3a7c4ea184a6344d566302d577d8fee3
2017-02-24 19:33:53 -08:00
Sandeep Patil
72b689bf34 Merge changes from topic 'early-mount-verity' am: 93072f2ce3 am: 2eb715d866
am: d93e05052a

Change-Id: I014d926e0bf7f560b7fbfa32f11b078dc7b6edc4
2017-02-24 02:23:54 +00:00
Sandeep Patil
c20c0c2cdd early_mount: fs_mgr: move all fstab logic into fs_mgr
With init parsing fstab fragments from kernel separately, the fs_mgr
would completely miss the device tree entries. That leads to things like
'adb remount' to go through without warning for verity even if /system
is verified. This happens because 'verity_update_state' completely
misses the partitions passed to android through the device tree.

solution is to teach fs_mgr about device tree fstab entries and add 2
new public APIs.

1. fs_mgr_read_fstab_dt() - reads device tree and returns fstab
generated from it.

2. fs_mgr_read_fstab_default() - reads both device tree fstab and
/fstab.{ro.hardware} and returns the combined table.

This also reduces the hardcoded /fstab.{ro.hardware} occurence only to
fs_mgr and for eveyone who wants to read the "default" fstab must be
changed to call fs_mgr_read_fstab_default() instead. e.g. adb.

b/27805372

Test: Angler was used since it has 2 early mounted partitions instead of
one. 1 verified and 1 unverified.
- Boot angler successfully without early mount
- Boot angler successfully with /vendor early mount and test if 'adb
remount' warns us about verity
- Boot angler successfully with both /system and /vendor early mounted
and ensure 'adb remount' warns us about verity.
- check partitions.system.verified status after /system early mount ot
ensure it is set to VERITY_MODE_DEFAULT.
- 'adb disable-verity' with early mounted /system doesn't work due to
missing changes in adb

TODO:
change adb to use the new fs_mgr_read_fstab_default() API

Change-Id: I82038d87c7a44488e938acce2cc1082c08f6f73a
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-02-23 16:48:43 -08:00
Sandeep Patil
bb5a8380b0 Merge changes from topic 'early-mount-support' am: 4bd3facbb1 am: e0d7b830f0
am: 5f08cb2aea

Change-Id: I40a70549a545d9d1dd4f007f5fd259102785412c
2017-02-23 07:23:37 +00:00
Sandeep Patil
05ff38ba43 init: early_mount: disallow partitions to be verified at boot
While technically possible, the verification at boot basically will
block init for as long as the entire partition is read while nothing
else is running. Disallow that as this is not going to be used anywhere.

Bug: 27805372
Test: boot angler with verifyatboot fs_mgr option for early mounted
vendor partition. That resulted in a panic() as expected.

Change-Id: I9da5caa163cae8bce6dbfb630f0ed5605ea044a0
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-02-22 11:22:53 -08:00
Sandeep Patil
4129f20aaf fs_mgr: make fs_mgr_setup_verity public API
Consequently this removes the 'early' version of the exact same API.
This is to be used by early mount code where we need to do
1. setup verity
2. create verity device
3. mount partition
as separate steps since that happens during init first stage.

b/27805372

Test: Boot sailfish successfully

Change-Id: I01abecfdfa210d3e240a291ddcb3d2e9ed39ede6
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-02-22 11:22:53 -08:00
Sandeep Patil
56f9ada93d fs_mgr: add fs_mgr_do_mount_one() API
This is to be used in early mount case where we will have a fully
prepared fstab_rec. fs_mgr_do_mount() does a lot more checks and
spends time preparing verity / avb devices before it does the actual
mount.

b/33254008

Test: Boot sailfish

Change-Id: I4481b5af8d900c8b7e3355b7513c325d8f2ecff2
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-02-20 09:04:33 -08:00
Sandeep Patil
1ccb3b0050 Merge changes from topic 'pre-early-mount' am: 1549257ff5 am: c027aac7c8 am: 9e140bb206
am: 7f9c89ffcb

Change-Id: Ie4531a9e4457110d3e496bb3ba1b267c211ce5ef
2017-02-14 20:44:26 +00:00
Sandeep Patil
35403ebaf8 init: early_mount: add support to mount non-verity partitions early
This is done by parsing 'androidboot.fstab=<fstab>' kernel cmdline
option to get the fstab file that *only* specifies partitions to be
mounted early (i.e. in init's first stage).

Note that, the same fstab file may not be used as an argument to
mount_all later in the boot as that will cause fs_mgr to fail with
EBUSY.

TODO:
- Possibly add a new mount_mode so the same fstab can be used for
early_mount, 'mount_all --early/--late' etc.
- Add support for dm-verity enabled partitions to mount early.
- Add support for getting fstab arguments through DT instead of kernel
cmdline.

Bug: 27805372

Test:
Boot angler by passing a seperate fstab file using the kernel
cmdline option to mount vendor partition early, remove the vendor
partition entry from the main fstab file for the test.

Boot sailfish by passing a seperate fstab entry via device tree
to mount vendor partition early. Remove vendor partition entry from
the main fstab file for the test

Change-Id: I18785b893c54c8cee960ab44d5e8f83e5d624aa8
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-02-13 11:17:51 -08:00
Eric Biggers
b478f706d7 fs_mgr: allow specifying HEH filenames encryption
Make the fs_mgr changes needed to support specifying aes-256-heh
filenames encryption.  To do this, extend the "fileencryption" fstab
option to have the syntax
fileencryption=contents_encryption_mode[:filenames_encryption_mode].
The previous filenames encryption mode, aes-256-cts, remains supported
and will be used by default if no mode is explicitly specified.

For consistency, also make "aes-256-xts" an alias for the "software"
contents encryption mode.

Bug: 34712722
Change-Id: I74c0f5fe7cddde7055d7b031d96a2916ca611eb7
2017-02-10 16:50:47 -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
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
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
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
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
Chuanxiao Dong
8b1707ec3a Merge "fs_mgr: fix encryptable=footer support" am: b67fed557f am: 7f06a23414
am: aa0318c9e9

* commit 'aa0318c9e9b97b2644c7428313fbeec4f86d12fd':
  fs_mgr: fix encryptable=footer support

Change-Id: Ic8d662bd960a4e40f0a3073ff2442b5d1eb20d99
2016-06-07 17:03:02 +00:00
Chuanxiao Dong
aa0318c9e9 Merge "fs_mgr: fix encryptable=footer support" am: b67fed557f
am: 7f06a23414

* commit '7f06a234140a1dc5c0160fca03b7fcf0fd35939a':
  fs_mgr: fix encryptable=footer support

Change-Id: Iea56bd3856a241100bd23b3a06c3284c47bff5c0
2016-06-07 17:00:16 +00:00
Treehugger Robot
b67fed557f Merge "fs_mgr: fix encryptable=footer support" 2016-06-07 16:49:39 +00:00
Stephen Hines
496e073864 resolve merge conflicts of 5fb629a to nyc-mr1-dev-plus-aosp
Change-Id: I6424b08182637e7885b57119bc5eb6d5e3708c45
2016-05-27 17:01:44 -07:00
Chih-Hung Hsieh
5fb629a212 resolve merge conflicts of e845c04 to nyc-dev-plus-aosp
Change-Id: I423f722dcc3821b9be52613d68640b49cbac70a6
2016-05-27 16:04:21 -07:00
Paul Lawrence
4e898a01fd Make file encryption type available
Bug: 28905864
Change-Id: I5f59f824fd92c32ff87aa730dc5c0f250564c0a9
2016-05-27 09:38:29 -07:00
Chih-Hung Hsieh
c713bce901 Fix misc-macro-parentheses warnings in init and other core modules.
Bug: 28705665
Change-Id: Ice67cebb8c42538f8fb9cf1756678f41a9d68a31
2016-05-18 18:11:49 -07:00
Paul Lawrence
5b8a108ef5 Add fileencrypted=software/ice to fstab options
Bug: 28616054
Change-Id: If9dd4a17641412607ca4e4fed7f7dbf661ff0d25
2016-05-11 07:34:47 -07:00
Daniel Rosenberg
e3a3288ddd resolve merge conflicts of 2857bd1 to nyc-dev
Change-Id: I3dc666cd44deb3e8438c2a482328f79e7a67e81e
2016-04-12 14:28:09 -07:00
Daniel Rosenberg
de551ffee9 Add nofail fstab option
This option allows fs_mgr to ignore mount errors on an optional
partition to allow booting to continue.

Bug: 28071890
Change-Id: I71a2b3c1c573297cab18884b4c4bd7c27ced2901
2016-04-12 14:06:25 -07:00
Daniel Rosenberg
d38e3c522c Add nofail fstab option
This option allows fs_mgr to ignore mount errors on an optional
partition to allow booting to continue.

Bug: 28071890
Change-Id: I71a2b3c1c573297cab18884b4c4bd7c27ced2901
2016-04-07 20:37:31 -07:00
Chuanxiao Dong
d78dff1622 fs_mgr: fix encryptable=footer support
If the userdata partition has the encryptable=footer fstab option,
fs_mgr must leave room for the crypt footer.

Change-Id: Id07818c5d93aafc27577f72fb0a780f26db51b16
Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.com>
Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
2016-03-08 17:20:26 +01:00
Paul Lawrence
1098aacde4 Distinguish between unencrypted and unencryptable
Set ro.crypto.state flag to unencrypted and unsupported accordingly

Bug: 18002358
Change-Id: I1f88ce9704c5505d7b63256e2ebe5f8441c79ad0
2016-03-04 15:52:33 -08:00
Paul Lawrence
69080180ce Remove code to handle non-default file encryption
Change-Id: I6d986853929c0237c0d958329b8e9aab47907a00
2016-02-02 10:34:40 -08:00
Paul Lawrence
b262d6864e Add developer option to convert from FDE to FBE
This set of changes adds the screen that offers this conversion,
and the plumbing so the option is only available on suitable
devices.

It does not implement the conversion mechanism.

Change-Id: Idbe5ef5d5fad197cc8187e1b288c57feef2c2c0b
2015-11-04 05:09:32 -08:00
Ed Tam
e498c7ca2c resolved conflicts for merge of d0b6de41 to master
Change-Id: I1d1f6b1cdbd7ee441682c4258a11fb3198ca7d94
2015-04-13 18:01:33 -07:00
Ed Tam
438443e742 resolved conflicts for merge of 79f33846 to lmp-mr1-dev-plus-aosp
Change-Id: I24c60a2747931917a3ea09b953905ce0f4145280
2015-04-13 16:29:05 -07:00
Chris Fries
79f3384652 fs_mgr: introduce fs_mgr_format to format wiped partitions
Move fastboot's format logic into fs_mgr, to consolidate the knowledge
about how to do this (and when to wipe metadata).

Try to format these formattable paritions if they are wiped.

If formatting fails, we will fall out to let recovery mode handle it.

Bug: 20082763
Change-Id: I397cc197550e78d932e8a154fd234695c46dbe7b
2015-04-10 15:01:16 -07:00
Sami Tolvanen
856006047b am 93c4b6c8: am ddaebb24: am 284c5cb2: Merge "Set verity mode as the verified property value"
* commit '93c4b6c85ac4350029e1a78c16663f61c777ac14':
  Set verity mode as the verified property value
2015-04-07 10:02:26 +00:00
Sami Tolvanen
284c5cb2a1 Merge "Set verity mode as the verified property value" 2015-04-07 08:45:24 +00:00
Paul Lawrence
c410b3bd63 Revert "Revert "Adding e4crypt support""
Fix build break caused by original change

This reverts commit 84b0bab58f.

(cherry picked from commit bbb4c85bdcc9a1bce315ed9d61a228bb1b992a1c)

Change-Id: If0ead0f2656b69f33f72c64b03a05784455a4143
2015-04-01 13:48:06 -07:00
Paul Lawrence
b8c9d273a0 Revert "Revert "Adding e4crypt support""
Fix build break caused by original change

This reverts commit 84b0bab58f.

Change-Id: I99fbd7c3d1ed92db1f546033c8493bb71a327924
2015-03-31 13:02:13 -07:00
Sami Tolvanen
454742392f Set verity mode as the verified property value
Set the verity mode as the value for partition.%s.verified to make it
easier for userspace to determine in which mode dm-verity was started.

Change-Id: Icc635515f8a8ede941277aed196867351d8387cb
2015-03-31 09:12:00 +01:00
Sami Tolvanen
b042a2e8bd am c28e2598: am 3fdc2f2b: am d33c6c0e: Merge "Use structured format for verity metadata"
* commit 'c28e2598af394834dbf6532f1cf252705fabd76b':
  Use structured format for verity metadata
2015-03-26 16:27:46 +00:00
Paul Lawrence
84b0bab58f Revert "Adding e4crypt support"
This reverts commit 6095afc115.

Change-Id: Icedfe0036223d7f42eaaefc4a35ad0f2efb14e4e
2015-03-26 14:53:19 +00:00