Skip to content

Add ARM MTE Support - May be broken#217

Merged
struct merged 12 commits intomasterfrom
mte_support
Dec 27, 2023
Merged

Add ARM MTE Support - May be broken#217
struct merged 12 commits intomasterfrom
mte_support

Conversation

@struct
Copy link
Copy Markdown
Owner

@struct struct commented Dec 20, 2023

This is the start of MTE support in IsoAlloc. Most of the code is adapted from Scudo (also released under an Apache v2 license with minor modifications). It is UNTESTED at the moment and should not be merged. If you have a Pixel 8 and want to do some testing of this PR please get in touch with me.

@struct struct mentioned this pull request Dec 20, 2023
@jvoisin
Copy link
Copy Markdown
Contributor

jvoisin commented Dec 20, 2023

cc @muhomorr @strcat

Comment thread src/iso_alloc.c
Comment thread include/iso_alloc_ds.h
int32_t big_zone_used_count;
uint16_t zones_used;
#if ARM_MTE
bool arm_mte_enabled;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should go in a read-only zone I think, otherwise, MTE is disableable by an attacker with an arbitrary write primitive.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A read-only section for settings like this is easy to implement but often requires dereferencing both _root and ro_config_page which can flush the cache and really hurt performance in any hot paths.

@struct struct changed the title DO NOT MERGE - Preliminary ARM MTE Support Add ARM MTE Support - May be broken Dec 27, 2023
@struct
Copy link
Copy Markdown
Owner Author

struct commented Dec 27, 2023

This PR looks OK to merge behind the ARM_MTE build define which is disabled by default. Its mostly complete and tested using qemu. However I have little faith in the qemu implementation as I ran into several bugs involving memset() of PROT_MTE pages that don't appear to happen with a simple while(){write()} loop. Once I get access to a real device with MTE support I will retest this functionality.

TLDR: YMMV, please let me know if you can test this on real hardware!

@struct struct merged commit 429fc73 into master Dec 27, 2023
@struct
Copy link
Copy Markdown
Owner Author

struct commented Dec 27, 2023

If you want to test in an Ubuntu Docker container on an M1/M2 based Macbook just enabled the ARM_MTE build defines in Makefile (make sure to set DISABLE_CANARY=1 as well).

apt-get install clang-12 make qemu qemu-system-arm qemu-user-static
make mte_test

The make command above will compile test programs and just runs the following command:

qemu-aarch64-static -cpu max build/tests

If you add -strace to the qemu command you should be able to see it killed with the proper signal and si_code for SEGV_MTESERR.

--- SIGSEGV {si_signo=SIGSEGV, si_code=9, si_addr=0x0e00005501a15400} ---
qemu: uncaught target signal 11 (Segmentation fault) - core dumped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants