Skip to content

Add Shadow Stack support for a simple app #505

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 9 commits into
base: staging
Choose a base branch
from

Conversation

mariasfiraiala
Copy link
Contributor

Prerequisite checklist

  • Read the contribution guidelines regarding submitting new changes to the project;
  • Tested your changes against relevant architectures and platforms;
  • Ran the checkpatch.pl on your commit series before opening this PR;
  • Updated relevant documentation.

Base target

  • Architecture(s): AArch64
  • Platform(s): KVM
  • Application(s): N/A

Additional configuration

You'll need to update the Makefile.uk of your app by adding this (let our app be helloworld for the sake of simplicity)

APPHELLOWORLD_CINCLUDES-y += -fsanitize=shadow-call-stack -ffixed-x18 -fno-exceptions
COMPFLAGS-y += -ffixed-x18 -fno-exceptions

Shadow Stack support comes with clang as a compiler, you'll have to build the app accordingly.

Build using

make CC=clang LD=~/toolchains/gcc-arm-11.2-2022.02-x86_64-aarch64-none-elf/bin/aarch64-none-elf-gcc OBJCOPY=~/toolchains/gcc-arm-11.2-2022.02-x86_64-aarch64-none-elf/bin/aarch64-none-elf-objcopy STRIP=~/toolchains/gcc-arm-11.2-2022.02-x86_64-aarch64-none-elf/bin/aarch64-none-elf-strip

You'll need the gcc cross-compiling toolchain installed. Get it from here.

Also, make sure to have erratum options disabled when using menuconfig (Architecture Selection -> Arm8 Compatible -> Workaround for [...] erratum).

What's more, you'll have to configure the Custom cross-compiler LLVM target too (Build Options -> Custom cross-compiler LLVM target); just write aarch64-none-elf and you should be good to go.

Description of changes

This PR aims to demonstrate how the Shadow Stack support will behave.

It brings minor changes in order to make possible the compilation with clang, as this security mechanism is supported by clang and gcc-12.

Further changes were made in boot.c in order to initialize the Shadow Stack.

Future changes will bring better performance by changing the memory allocator to a Unikraft based one and by integrating the constructor in the Unikraft constructor table.

For Proof of Concept and other information, refer this.

Signed-off-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Signed-off-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Signed-off-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
@razvand razvand requested review from razvand and vladandrew July 21, 2022 03:37
@razvand razvand added this to the v0.12.0 (Epimetheus) milestone Jul 21, 2022
@razvand razvand added lifecycle/active Indicates that an issue or PR is actively being worked on by a contributor. topic/build Topics to do with the build system lang/c Issues or PRs to do with C/C++ arch/arm64 topic/booting Topics pertaining to the boot process topic/mm Topics pertaining to memory management priority/low gsoc22 Google Summer of Code 2022 Project labels Jul 21, 2022
Signed-off-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Signed-off-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
…h clang (#6)

Signed-off-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Signed-off-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Signed-off-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Signed-off-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch/arm64 gsoc22 Google Summer of Code 2022 Project lang/c Issues or PRs to do with C/C++ lifecycle/active Indicates that an issue or PR is actively being worked on by a contributor. priority/low topic/booting Topics pertaining to the boot process topic/build Topics to do with the build system topic/mm Topics pertaining to memory management
Projects
Status: In Progress
Status: 🧊 Icebox
Development

Successfully merging this pull request may close these issues.

5 participants