diff options
author | Luis Hector Chavez <lhchavez@google.com> | 2018-05-30 15:47:50 -0700 |
---|---|---|
committer | Luis Hector Chavez <lhchavez@google.com> | 2018-06-04 19:12:17 +0000 |
commit | bbb512d019008f6209d01f8de8d5d3b33b37f0ab (patch) | |
tree | 9c20befab86d738a2b69a3b3f8b588551c8b9a73 /cryptfs.cpp | |
parent | 6054bc3ded9f35d07a3b17a4f1849c85bec05c9b (diff) | |
download | vold-bbb512d019008f6209d01f8de8d5d3b33b37f0ab.tar.gz |
vold: Avoid SIGSEGVs when fstab lacks /data
This change adds null-checks for all the places where cryptfs tries to
access the /data entry in fstab, to avoid crashes.
Bug: 80493321
Test: No crashes in Android-in-Chrome OS (which lacks /data in fstab)
Change-Id: Id6cdfe01cdd336cebf8afb9bdd07135811115182
Merged-In: Id6cdfe01cdd336cebf8afb9bdd07135811115182
Diffstat (limited to 'cryptfs.cpp')
-rw-r--r-- | cryptfs.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/cryptfs.cpp b/cryptfs.cpp index e8bf3aaa..4e325e68 100644 --- a/cryptfs.cpp +++ b/cryptfs.cpp @@ -1451,7 +1451,9 @@ static int cryptfs_restart_internal(int restart_main) property_get("ro.crypto.readonly", ro_prop, ""); if (strlen(ro_prop) > 0 && atoi(ro_prop)) { struct fstab_rec* rec = fs_mgr_get_entry_for_mount_point(fstab, DATA_MNT_POINT); - rec->flags |= MS_RDONLY; + if (rec) { + rec->flags |= MS_RDONLY; + } } /* If that succeeded, then mount the decrypted filesystem */ @@ -2061,6 +2063,10 @@ static int cryptfs_enable_all_volumes(struct crypt_mnt_ftr *crypt_ftr, int how, if (how == CRYPTO_ENABLE_WIPE) { struct fstab_rec* rec = fs_mgr_get_entry_for_mount_point(fstab, DATA_MNT_POINT); + if (!rec) { + SLOGE("cryptfs_enable: missing %s entry in fstab\n", DATA_MNT_POINT); + return -1; + } int fs_type = get_fs_type(rec); if (fs_type < 0) { SLOGE("cryptfs_enable: unsupported fs type %s\n", rec->fs_type); @@ -2917,7 +2923,7 @@ void cryptfs_clear_password() int cryptfs_isConvertibleToFBE() { struct fstab_rec* rec = fs_mgr_get_entry_for_mount_point(fstab, DATA_MNT_POINT); - return fs_mgr_is_convertible_to_fbe(rec) ? 1 : 0; + return (rec && fs_mgr_is_convertible_to_fbe(rec)) ? 1 : 0; } int cryptfs_create_default_ftr(struct crypt_mnt_ftr* crypt_ftr, __attribute__((unused))int key_length) @@ -2990,5 +2996,10 @@ void cryptfs_get_file_encryption_modes(const char **contents_mode_ret, const char **filenames_mode_ret) { struct fstab_rec* rec = fs_mgr_get_entry_for_mount_point(fstab, DATA_MNT_POINT); + if (!rec) { + *contents_mode_ret = nullptr; + *filenames_mode_ret = nullptr; + return; + } fs_mgr_get_file_encryption_modes(rec, contents_mode_ret, filenames_mode_ret); } |