summaryrefslogtreecommitdiff
path: root/fs_mgr/libdm/dm.cpp
diff options
context:
space:
mode:
authorDavid Anderson <dvander@google.com>2024-10-01 11:01:08 -0700
committeraoleary <seanm187@gmail.com>2025-02-21 09:45:46 +0000
commit4c3287d4a288449266341bf106a4d97dc1332ff6 (patch)
treea147a7c47bdf903fd3bdffb294983a1d12e6972e /fs_mgr/libdm/dm.cpp
parente6b44b2a91c37417cce0e81290ba9dee0b6fad93 (diff)
libdm: Redact keys from dm-crypt targets when calling GetTable.HEADt13.0
Ignore-AOSP-First: security fix Bug: 368069390 Test: libdm_test (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:034e2dd670e8bc81e35da74235c3d97f06556fa4) Merged-In: I40b9a0129e58b1a0f116ca29f0ee66f91a27a73d Change-Id: I40b9a0129e58b1a0f116ca29f0ee66f91a27a73d
Diffstat (limited to 'fs_mgr/libdm/dm.cpp')
-rw-r--r--fs_mgr/libdm/dm.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/fs_mgr/libdm/dm.cpp b/fs_mgr/libdm/dm.cpp
index 4034e30ab9..6da7b48b60 100644
--- a/fs_mgr/libdm/dm.cpp
+++ b/fs_mgr/libdm/dm.cpp
@@ -512,6 +512,17 @@ bool DeviceMapper::GetTableInfo(const std::string& name, std::vector<TargetInfo>
return GetTable(name, DM_STATUS_TABLE_FLAG, table);
}
+void RedactTableInfo(const struct dm_target_spec& spec, std::string* data) {
+ if (DeviceMapper::GetTargetType(spec) == "crypt") {
+ auto parts = android::base::Split(*data, " ");
+ if (parts.size() < 2) {
+ return;
+ }
+ parts[1] = "redacted";
+ *data = android::base::Join(parts, " ");
+ }
+}
+
// private methods of DeviceMapper
bool DeviceMapper::GetTable(const std::string& name, uint32_t flags,
std::vector<TargetInfo>* table) {
@@ -550,6 +561,9 @@ bool DeviceMapper::GetTable(const std::string& name, uint32_t flags,
// Note: we use c_str() to eliminate any extra trailing 0s.
data = std::string(&buffer[data_offset], next_cursor - data_offset).c_str();
}
+ if (flags & DM_STATUS_TABLE_FLAG) {
+ RedactTableInfo(*spec, &data);
+ }
table->emplace_back(*spec, data);
cursor = next_cursor;
}