Skip to content

Commit 99ea474

Browse files
committed
Check whether processes may run with MTE enabled
Add support for determining if processes can run with MTE enabled (`memory-tagging+` feature in `qSupported` packet).
1 parent 0f365cd commit 99ea474

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lldb/tools/debugserver/source/RNBRemote.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
#include <mach/mach_vm.h>
2323
#include <mach/task_info.h>
2424
#include <memory>
25+
#if __has_include(<os/security_config.h>) // macOS 26.1
26+
#include <os/security_config.h>
27+
#endif
2528
#include <pwd.h>
2629
#include <string>
2730
#include <sys/stat.h>
@@ -3477,6 +3480,18 @@ static bool GetProcessNameFrom_vAttach(const char *&p,
34773480
return return_val;
34783481
}
34793482

3483+
static bool supports_memory_tagging() {
3484+
const char *name = "hw.optional.arm.FEAT_MTE4";
3485+
uint32_t val;
3486+
size_t len = sizeof(val);
3487+
int ret = ::sysctlbyname(name, &val, &len, nullptr, 0);
3488+
if (ret != 0)
3489+
return false;
3490+
3491+
assert(len == sizeof(val));
3492+
return val;
3493+
}
3494+
34803495
rnb_err_t RNBRemote::HandlePacket_qSupported(const char *p) {
34813496
uint32_t max_packet_size = 128 * 1024; // 128 KiB is a reasonable max packet
34823497
// size--debugger can always use less
@@ -3507,6 +3522,9 @@ rnb_err_t RNBRemote::HandlePacket_qSupported(const char *p) {
35073522
reply << "SupportedWatchpointTypes=x86_64;";
35083523
#endif
35093524

3525+
if (supports_memory_tagging())
3526+
reply << "memory-tagging+;";
3527+
35103528
return SendPacket(reply.str().c_str());
35113529
}
35123530

0 commit comments

Comments
 (0)