Commit graph

236 commits

Author SHA1 Message Date
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
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
Mattias Nissler
35d84096e9 Merge "fs_mgr: Remove incorrect free() on error paths in load_key()" 2016-06-07 21:00:03 +00:00
Treehugger Robot
b67fed557f Merge "fs_mgr: fix encryptable=footer support" 2016-06-07 16:49:39 +00:00
Mattias Nissler
31404e58e9 fs_mgr: Remove incorrect free() on error paths in load_key()
This fixes a bug introduced by
https://android-review.googlesource.com/#/c/212781/ which would make
fs_mgr crash when hitting one of the error paths.

Bug: 28585197
Change-Id: I40e6612e2eb3e6f584e70c608afc6d4378d73c4f
2016-06-07 16:37:48 +02:00
Treehugger Robot
58ea31cc90 Merge "fs_mgr: pass sehandle to ext4 format routine" 2016-06-01 17:30:09 +00: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
Jeremy Compostella
dfd2478bd1 fs_mgr: update block device reference in verity metadata
The dm-verity metadata contains the block device path that is given to
the dm-android-verity driver.  If the device is using slot A/B, this
path is missing the slot suffix.

This patch makes fs_mgr replace all the block device path reference
with the one including the active slot suffix.

Change-Id: Ib624d0d18b12a8a287cac7f15605a2e0fb7c97c6
Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
2016-05-16 16:37:24 +00:00
William Roberts
875476d8ed fs_mgr: pass sehandle to ext4 format routine
When fs_mgr_do_format() is executed, fs_mgr creates a new
blank data file system. However, that filesystem is not
labeled and causes some unlabeled denials on early boot.

Example Denial:
avc: denied { search } for pid=2535 comm="logd" name="/" dev="mmcblk0p9" ino=2 scontext=u:r:logd:s0 tcontext=u:object_r:unlabeled:s0 tclass=dir permissive=1

To correct this, pass sehandle to the internal ext4 routine.
This way the ext4 filesystem will be labeled at creation and
the root inode will have a label.

Change-Id: Ieeecaa8bbc258e6d743d281dd956bdaca98b365f
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-05-13 11:28:24 -07:00
Daniel Rosenberg
e99283103b Merge "Add nofail fstab option" 2016-04-14 00:12:44 +00:00
Mattias Nissler
097b6bbc76 Switch fs_mgr and adb to libcrypto_utils.
Update code and dependencies to use BoringSSL + libcrypto_utils
instead of mincrypt.

Change-Id: Ic75164bd50c84b81b6310e27a67d4b3c174984f9
2016-04-12 23:04:11 +00: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
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
George Burgess IV
e7aa2b2c83 Cleanup uses of sprintf so we can deprecate it.
Also cleans up two instances of open() with useless mode params, and
changes a few uses of snprintf to use sizeof(buffer) instead of
hardcoded buffer sizes.

Change-Id: If11591003d910c995e72ad8f75afd072c255a3c5
2016-03-07 18:40:40 -08:00
Keith Mok
d93adf55df fs_mgr: BLKGETSIZE causes memory corruption
BLKGETSIZE return unsigned long sector size,
but unsigned long is of 8 bytes in 64 bits system.
Passing an integar value will causes stack corruption.
Use BLKGETSIZE64 instead.

Change-Id: I60323e51c6692d4405cf2ed015ab4216c1591f68
2016-02-16 09:51:00 -08:00
Sami Tolvanen
907ec7daa7 Merge "fs_mgr: support upstream dm-verity without error correction" 2015-12-10 20:13:02 +00:00
Sami Tolvanen
0d1214c68e Merge "Set up dm-verity in EIO mode instead of logging mode" 2015-12-10 20:12:49 +00:00
Sami Tolvanen
ff980d22d1 fs_mgr: support upstream dm-verity without error correction
Set up dm-verity even if kernel configuration doesn't have
CONFIG_DM_VERITY_FEC set. Fall back to the always safe EIO
mode if dm-verity doesn't support feature arguments.

Bug: 21893453
Change-Id: I4812bd74801c0abc8da479230f48b752858f9cd8
2015-12-10 01:01:29 +00:00
Elliott Hughes
4f71319df0 Track rename of base/ to android-base/.
Change-Id: Idf9444fece4aa89c93e15640de59a91f6e758ccf
2015-12-04 22:00:26 -08:00
Sami Tolvanen
90f52df257 Set up dm-verity in EIO mode instead of logging mode
If the device is corrupted, set up dm-verity in EIO mode instead of
logging mode. This prevents corrupted blocks from being returned to
user space. Note that restart mode is used by default and a warning
will be displayed to the user after corruption is first detected.

Bug: 19277516
Change-Id: I38966d73eb814836bc34b4bad1192583e5010b36
2015-12-02 14:38:01 +00:00
Sami Tolvanen
25b230c62c fs_mgr: set partition.*.verified property even without state
Set properties on verity_update_state even if verity state management
is not used.

Bug: 24865045
Change-Id: Ic68a9e1a230c959eeb2a769260ff7d8e100cb1e1
(cherry picked from 0eb0516665678aec7712d88b51c96aaf8b312060)
2015-10-30 13:14:38 +00:00
Sami Tolvanen
99e3a927e8 Error correction: Use libfec in fs_mgr
Use libfec to read and parse verity metadata to protect against data
corruption.

Bug: 21893453
Change-Id: I3a3543e0d999316707302b3be8735a7133d22946
2015-10-14 22:12:04 +01:00
Sami Tolvanen
0923453462 Revert "Error correction: Use libfec in fs_mgr"
This reverts commit 3de3a0f351.

Change-Id: I1f121cbc4431b8d8ff146eab29832a8dda1eb8ba
2015-10-14 19:46:16 +00:00
Sami Tolvanen
3de3a0f351 Error correction: Use libfec in fs_mgr
Use libfec to read and parse verity metadata to protect against data
corruption.

Bug: 21893453
Change-Id: Ieee6a1441e2f68148ba635235216e36c69b13db1
2015-10-13 15:53:25 +01:00
Johan Redestig
67b3cad9a0 Switch to android::base::ReadFully
The if (read(...size) != size) pattern is unreliable, switch
to the android base ReadFully which wraps read in a loop.

Change-Id: I2324e4c45da3c9b53b18df6eb09ce69a6604b5d1
2015-10-13 14:49:38 +00:00
Elliott Hughes
246c18caf5 Switch fs_mgr_verity.c to C++.
This is the minimal change just to keep it building, and doesn't
attempt to clean up any of the code.

Change-Id: I975710322ae33d8946497df25bf85b2fe28976a4
2015-10-09 11:52:00 -07:00
Sami Tolvanen
049399e570 am ad2a5a89: Merge "fs_mgr: trigger dm-verity error handling for invalid signatures"
* commit 'ad2a5a89a680804b927fc123e952c5bb5e75b9c8':
  fs_mgr: trigger dm-verity error handling for invalid signatures
2015-09-30 20:04:51 +00:00
Sami Tolvanen
1ada14904d fs_mgr: trigger dm-verity error handling for invalid signatures
Currently, the device doesn't mount verified partitions if the
verity table signature is invalid, which usually means it fails to
boot. This change instead sets up dm-verity with an invalid root
hash and triggers device-specific error handling to recover from
the corruption.

Bug: 24256506
Change-Id: I6d693306fa0e7459c5500b028e433df61ecea6fb
(cherry picked from commit 47caa5c386)
2015-09-25 15:01:33 +01:00
David Zeuthen
77557e9091 am d906b297: Merge "fs_mgr: Error out if unable to determine slot_suffix"
* commit 'd906b2973b9f708b34d4df90a2496753f83199ec':
  fs_mgr: Error out if unable to determine slot_suffix
2015-09-14 15:39:49 +00:00
David Zeuthen
d906b2973b Merge "fs_mgr: Error out if unable to determine slot_suffix" 2015-09-14 15:33:35 +00:00
David Zeuthen
bd0231c96b fs_mgr: Error out if unable to determine slot_suffix
Instead of falling back to suffix _a, we now error out if neither the
kernel commandline nor the misc partition specifies the suffix. It's
cleaner this way.

Change-Id: I3f58928a664433504ebdf8d0ee05a319be5097cf
2015-09-11 12:53:18 -04:00
David Zeuthen
80364b94bc am 6ca11db7: Merge "fs_mgr: Fix ENOMEM behavior when dealing with slotselect."
* commit '6ca11db7b7dc5e141c767b38328c3838a3b90b60':
  fs_mgr: Fix ENOMEM behavior when dealing with slotselect.
2015-09-09 22:52:32 +00:00
David Zeuthen
744a8f87d9 fs_mgr: Fix ENOMEM behavior when dealing with slotselect.
Change-Id: I5460a8d31baa0d4817ff5fcbd9aac272071937f4
2015-09-09 18:03:13 -04:00
David Zeuthen
1c7060e055 resolved conflicts for d8eed7ff to stage-aosp-master
Change-Id: I7fb3ddc07d798f0f98075b9fab0bb88c88249455
2015-09-09 12:40:16 -04:00
David Zeuthen
227ef3c5d2 fs_mgr: Use slot_suffix field from bootloader_message.
This will make fs_mgr look in the misc partition for the A/B suffix to
use if one of more fstab entries is using the slotselect option and the
bootloader doesn't specify the suffix.

Change-Id: I24233195f60dd352bf8e7ac32b0d95dcd3323156
2015-09-08 15:54:32 -04:00
Daniel Rosenberg
eb65ce0a24 resolved conflicts for merge of 7c4ed6af to stage-aosp-master
Change-Id: I52d0f66a6ad329daf19267be817c5a6d7118e7c4
2015-09-01 12:47:48 -07:00
Daniel Rosenberg
7c4ed6af79 Merge "fs_mgr: Add support for A/B partitions" 2015-09-01 19:24:09 +00:00
Daniel Rosenberg
8bb2f36abd fs_mgr: Add support for A/B partitions
Allow partitions to be marked as A/B partitions
using the slotselect flag in fstab. The partitions
can be identified by appending the correct suffix
to the block device listed in the fstab. The suffix
is provided by the bootloader through a command line
parameter or the device tree, and can be found in
ro.boot.slot_suffix or read from the boot_control HAL.

Change-Id: I6846d80e857f95bfb8f282f4ab81167394613bbe
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2015-08-31 15:18:05 -07:00
Yusuke Sato
2ef82cffad am d1b11a04: am e656be33: Merge "Add |opts| argument to android_fork_execvp_ext"
* commit 'd1b11a04903be74ba6a47307d8c3ef2731e3f4ab':
  Add |opts| argument to android_fork_execvp_ext
2015-08-19 22:31:08 +00:00
Yusuke Sato
d81c3c6c45 Add |opts| argument to android_fork_execvp_ext
to allow the caller to send data to the child's stdin.

Bug: 21725996
Change-Id: I818f5cf61045286c8d64a91b6d50f05740329be1
2015-08-19 11:00:37 -07:00
Daniel Rosenberg
88f82b6650 am 39087653: am 13d62278: Merge "Skip mounting /, just mark block device as ro if needed."
* commit '390876539ec12115268710762d86d8c4c5738c25':
  Skip mounting /, just mark block device as ro if needed.
2015-08-04 01:07:07 +00:00
Daniel Rosenberg
31a4fafc15 Skip mounting /, just mark block device as ro if needed.
Change-Id: I7fbb636d296abc1caab6c7bf88017684c9df7759
2015-08-04 00:47:04 +00:00
Yusuke Sato
7c842b57fe am ab64465d: am 0e3ce82b: Merge "Use fsck.f2fs -a instead of -f for faster boot"
* commit 'ab64465d1f16f414c0bde5e3c4707c32b8220bbc':
  Use fsck.f2fs -a instead of -f for faster boot
2015-07-21 18:25:57 +00:00
Yusuke Sato
0e3ce82b94 Merge "Use fsck.f2fs -a instead of -f for faster boot" 2015-07-21 16:06:40 +00:00
Sami Tolvanen
5f2b3b4be8 am 6c3b205c: am 759717ee: Merge "Update partition.*.verified even with ro.boot.veritymode set"
* commit '6c3b205c408f92101ddfa053cb134371e951a9a7':
  Update partition.*.verified even with ro.boot.veritymode set
2015-07-15 21:27:38 +00:00
Yusuke Sato
0df08271fb Use fsck.f2fs -a instead of -f for faster boot
and run fsck with -f on clean shutdown instead.

With -f, fsck.f2fs always performs a full scan of the /data
partition regardless of whether the partition is clean or not.
The full scan takes more than 2 seconds on volantis-userdebug
and delays the OS boot.

With -a, the command does almost nothing when the partition
is clean and finishes within 20-30ms on volantis-userdebug.
When the partition has an error or its check point has
CP_FSCK_FLAG (aka "need_fsck"), the command does exactly the
same full scan as -f to fix it.

Bug: 21853106
Change-Id: I126263caf34c0f5bb8f5e6794454d4e72526ce38
2015-07-15 10:13:51 -07:00
Sami Tolvanen
2f42554f18 Update partition.*.verified even with ro.boot.veritymode set
We need to have partition.*.verified properties even when bootloader
is managing dm-verity mode, because we may have failed to set up the
verified partition and need a property to indicate this.

This means we still need to run fs_mgr_update_verity_state and walk
through all the partitions to verify the device mapper status, just
without updating verity mode.

Bug: 22489805
Change-Id: Iaf28185adb8b80e5452447e54e1f4e4417a34168
2015-07-15 09:11:13 +00:00
Thierry Strudel
a0fbb90885 am 8703bea1: Merge "fs_config: replace getenv(\'OUT\') by new fs_config parameter" into mnc-dev
* commit '8703bea1807326fef9835bc474e7a7288c725925':
  fs_config: replace getenv('OUT') by new fs_config parameter
  fs_mgr: Use ro.boot.veritymode
2015-07-10 18:44:51 +00:00