From 4d0c5efac98903fac5be884cc28e15b6c0edd99d Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Mon, 8 Nov 2021 16:38:54 -0800 Subject: [PATCH] fs_mgr: remove crypt_footer argument from fs_mgr_do_format() FDE is no longer supported, so there's no longer any need to ever reserve a crypto footer. Bug: 191796797 Change-Id: I79121188b0bcb7b00c16fda03b68b20c40c1e240 --- fs_mgr/fs_mgr.cpp | 2 +- fs_mgr/fs_mgr_format.cpp | 21 +++++++-------------- fs_mgr/fs_mgr_roots.cpp | 2 +- fs_mgr/include/fs_mgr.h | 2 +- fs_mgr/libsnapshot/snapshot_fuzz_utils.cpp | 2 +- 5 files changed, 11 insertions(+), 18 deletions(-) diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp index 5350ee036..a320c0edb 100644 --- a/fs_mgr/fs_mgr.cpp +++ b/fs_mgr/fs_mgr.cpp @@ -1529,7 +1529,7 @@ MountAllResult fs_mgr_mount_all(Fstab* fstab, int mount_mode) { } } - if (fs_mgr_do_format(current_entry, false) == 0) { + if (fs_mgr_do_format(current_entry) == 0) { // Let's replay the mount actions. i = top_idx - 1; continue; diff --git a/fs_mgr/fs_mgr_format.cpp b/fs_mgr/fs_mgr_format.cpp index 301c90755..bb49873d0 100644 --- a/fs_mgr/fs_mgr_format.cpp +++ b/fs_mgr/fs_mgr_format.cpp @@ -34,7 +34,6 @@ #include #include "fs_mgr_priv.h" -#include "cryptfs.h" using android::base::unique_fd; @@ -58,7 +57,7 @@ static int get_dev_sz(const std::string& fs_blkdev, uint64_t* dev_sz) { } static int format_ext4(const std::string& fs_blkdev, const std::string& fs_mnt_point, - bool crypt_footer, bool needs_projid, bool needs_metadata_csum) { + bool needs_projid, bool needs_metadata_csum) { uint64_t dev_sz; int rc = 0; @@ -68,9 +67,6 @@ static int format_ext4(const std::string& fs_blkdev, const std::string& fs_mnt_p } /* Format the partition using the calculated length */ - if (crypt_footer) { - dev_sz -= CRYPT_FOOTER_OFFSET; - } std::string size_str = std::to_string(dev_sz / 4096); @@ -120,8 +116,8 @@ static int format_ext4(const std::string& fs_blkdev, const std::string& fs_mnt_p return rc; } -static int format_f2fs(const std::string& fs_blkdev, uint64_t dev_sz, bool crypt_footer, - bool needs_projid, bool needs_casefold, bool fs_compress) { +static int format_f2fs(const std::string& fs_blkdev, uint64_t dev_sz, bool needs_projid, + bool needs_casefold, bool fs_compress) { if (!dev_sz) { int rc = get_dev_sz(fs_blkdev, &dev_sz); if (rc) { @@ -130,9 +126,6 @@ static int format_f2fs(const std::string& fs_blkdev, uint64_t dev_sz, bool crypt } /* Format the partition using the calculated length */ - if (crypt_footer) { - dev_sz -= CRYPT_FOOTER_OFFSET; - } std::string size_str = std::to_string(dev_sz / 4096); @@ -159,7 +152,7 @@ static int format_f2fs(const std::string& fs_blkdev, uint64_t dev_sz, bool crypt return logwrap_fork_execvp(args.size(), args.data(), nullptr, false, LOG_KLOG, false, nullptr); } -int fs_mgr_do_format(const FstabEntry& entry, bool crypt_footer) { +int fs_mgr_do_format(const FstabEntry& entry) { LERROR << __FUNCTION__ << ": Format " << entry.blk_device << " as '" << entry.fs_type << "'"; bool needs_casefold = false; @@ -171,10 +164,10 @@ int fs_mgr_do_format(const FstabEntry& entry, bool crypt_footer) { } if (entry.fs_type == "f2fs") { - return format_f2fs(entry.blk_device, entry.length, crypt_footer, needs_projid, - needs_casefold, entry.fs_mgr_flags.fs_compress); + return format_f2fs(entry.blk_device, entry.length, needs_projid, needs_casefold, + entry.fs_mgr_flags.fs_compress); } else if (entry.fs_type == "ext4") { - return format_ext4(entry.blk_device, entry.mount_point, crypt_footer, needs_projid, + return format_ext4(entry.blk_device, entry.mount_point, needs_projid, entry.fs_mgr_flags.ext_meta_csum); } else { LERROR << "File system type '" << entry.fs_type << "' is not supported"; diff --git a/fs_mgr/fs_mgr_roots.cpp b/fs_mgr/fs_mgr_roots.cpp index 3e5619bcd..2ad8125e7 100644 --- a/fs_mgr/fs_mgr_roots.cpp +++ b/fs_mgr/fs_mgr_roots.cpp @@ -125,7 +125,7 @@ bool TryPathMount(FstabEntry* rec, const std::string& mount_pt) { int result = fs_mgr_do_mount_one(*rec, mount_point); if (result == -1 && rec->fs_mgr_flags.formattable) { PERROR << "Failed to mount " << mount_point << "; formatting"; - if (fs_mgr_do_format(*rec, false) != 0) { + if (fs_mgr_do_format(*rec) != 0) { PERROR << "Failed to format " << mount_point; return false; } diff --git a/fs_mgr/include/fs_mgr.h b/fs_mgr/include/fs_mgr.h index 21c998946..5ae4422bd 100644 --- a/fs_mgr/include/fs_mgr.h +++ b/fs_mgr/include/fs_mgr.h @@ -107,7 +107,7 @@ bool fs_mgr_update_logical_partition(android::fs_mgr::FstabEntry* entry); // device is in "check_at_most_once" mode. bool fs_mgr_verity_is_check_at_most_once(const android::fs_mgr::FstabEntry& entry); -int fs_mgr_do_format(const android::fs_mgr::FstabEntry& entry, bool reserve_footer); +int fs_mgr_do_format(const android::fs_mgr::FstabEntry& entry); #define FS_MGR_SETUP_VERITY_SKIPPED (-3) #define FS_MGR_SETUP_VERITY_DISABLED (-2) diff --git a/fs_mgr/libsnapshot/snapshot_fuzz_utils.cpp b/fs_mgr/libsnapshot/snapshot_fuzz_utils.cpp index acee2f4f7..54c6a0053 100644 --- a/fs_mgr/libsnapshot/snapshot_fuzz_utils.cpp +++ b/fs_mgr/libsnapshot/snapshot_fuzz_utils.cpp @@ -488,7 +488,7 @@ std::unique_ptr SnapshotFuzzEnv::CheckMountFormatData(const std::str .fs_type = "ext4", .mount_point = mount_point, }; - CHECK(0 == fs_mgr_do_format(entry, false /* crypt_footer */)); + CHECK(0 == fs_mgr_do_format(entry)); CHECK(0 == fs_mgr_do_mount_one(entry)); return std::make_unique(mount_point); }