[MTE] Reset MTE state for userdata wipe in fastbootd
Test: $ adb shell su root [...]/mtectrl memtag,memtag-kernel default
$ adb shell 'su root dd bs=1 skip=32832 if=/dev/block/bootdevice/by-name/misc count=15 | xxd'
00000000: 015a fefe 5a05 [...]
$ adb reboot fastboot
$ fastboot -w
$ fastboot reboot
$ adb shell 'su root dd bs=1 skip=32832 if=/dev/block/bootdevice/by-name/misc count=15 | xxd'
00000000: 0000 0000 0000 [...]
Bug: 245596152
Change-Id: I5e2d4584776ab1685bdf37124e32dcb827eaf05a
This commit is contained in:
parent
f2065c8890
commit
4c3c526e54
1 changed files with 15 additions and 0 deletions
|
|
@ -40,6 +40,8 @@
|
|||
#include <storage_literals/storage_literals.h>
|
||||
#include <uuid/uuid.h>
|
||||
|
||||
#include <bootloader_message/bootloader_message.h>
|
||||
|
||||
#include "BootControlClient.h"
|
||||
#include "constants.h"
|
||||
#include "fastboot_device.h"
|
||||
|
|
@ -154,6 +156,14 @@ static bool GetVarAll(FastbootDevice* device) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static void PostWipeData() {
|
||||
std::string err;
|
||||
// Reset mte state of device.
|
||||
if (!WriteMiscMemtagMessage({}, &err)) {
|
||||
LOG(ERROR) << "Failed to reset MTE state: " << err;
|
||||
}
|
||||
}
|
||||
|
||||
const std::unordered_map<std::string, std::function<bool(FastbootDevice*)>> kSpecialVars = {
|
||||
{"all", GetVarAll},
|
||||
{"dmesg", GetDmesg},
|
||||
|
|
@ -232,6 +242,7 @@ bool EraseHandler(FastbootDevice* device, const std::vector<std::string>& args)
|
|||
//Perform oem PostWipeData if Android userdata partition has been erased
|
||||
bool support_oem_postwipedata = false;
|
||||
if (partition_name == "userdata") {
|
||||
PostWipeData();
|
||||
support_oem_postwipedata = OemPostWipeData(device);
|
||||
}
|
||||
|
||||
|
|
@ -610,6 +621,10 @@ bool FlashHandler(FastbootDevice* device, const std::vector<std::string>& args)
|
|||
if (ret < 0) {
|
||||
return device->WriteStatus(FastbootResult::FAIL, strerror(-ret));
|
||||
}
|
||||
if (partition_name == "userdata") {
|
||||
PostWipeData();
|
||||
}
|
||||
|
||||
return device->WriteStatus(FastbootResult::OKAY, "Flashing succeeded");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue