Skip to content
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

Use a per-task stack canary for stack protector #29

Open
18 of 33 tasks
kees opened this issue Dec 5, 2019 · 15 comments
Open
18 of 33 tasks

Use a per-task stack canary for stack protector #29

kees opened this issue Dec 5, 2019 · 15 comments
Labels
[ARCH] arm32 Needed on the 32-bit ARM architecture (ARCH=arm) [ARCH] mips Needed on the MIPS architecture (ARCH=mips) [ARCH] s390 Needed on the s390 architecture (ARCH=s390) [ARCH-done] arm64 Finished on the 64-bit ARM architecture (ARCH=arm64) [ARCH-done] powerpc32 Finished on the 32-bit POWER architecture [ARCH-done] powerpc64 Finished on the 64-bit POWER architecture [ARCH-done] riscv Finished on the RISC-V architecture (ARCH=riscv) [ARCH-done] x86_32 Finished on the 32-bit x86 architecture (ARCH=i386) [ARCH-done] x86_64 Finished on the 64-bit x86 architecture (ARCH=x86) compiler Needs compiler support

Comments

@kees
Copy link

kees commented Dec 5, 2019

Some architectures don't have compiler support for a per-task stack canary, so the canary value is the same across all kernel threads. This means a stack memory exposure of the canary value from one task can be used for attacks against all other kernel tasks, making such exposures much more severe. To avoid this, the stack canary must be different for each kernel thread, which requires compiler support as well as kernel support.

Recent implementations use the compiler arguments similar to the form -mstack-protector-guard=sysreg -mstack-protector-guard-reg=$REGISTER -mstack-protector-guard-offset=$OFFSET (see implementations below).

@kees kees added [ARCH-done] x86_64 Finished on the 64-bit x86 architecture (ARCH=x86) [ARCH-done] x86_32 Finished on the 32-bit x86 architecture (ARCH=i386) [ARCH-done] arm32 Finished on the 32-bit ARM architecture (ARCH=arm) [ARCH-done] arm64 Finished on the 64-bit ARM architecture (ARCH=arm64) [ARCH-done] powerpc64 Finished on the 64-bit POWER architecture [ARCH] riscv Needed on the RISC-V architecture (ARCH=riscv) [ARCH] mips Needed on the MIPS architecture (ARCH=mips) [ARCH] s390 Needed on the s390 architecture (ARCH=s390) labels Dec 5, 2019
@kees kees added the compiler Needs compiler support label Dec 5, 2019
@kees
Copy link
Author

kees commented Aug 28, 2020

Clang support needed:
https://bugs.llvm.org/show_bug.cgi?id=47341

@kees
Copy link
Author

kees commented Aug 28, 2020

GCC support for RISCV proposed:
https://marc.info/?l=gcc-patches&m=159462831728667&w=2

@kees kees added [ARCH] arm64 Needed on the 64-bit ARM architecture (ARCH=arm64) [ARCH] arm32 Needed on the 32-bit ARM architecture (ARCH=arm) and removed [ARCH-done] arm64 Finished on the 64-bit ARM architecture (ARCH=arm64) [ARCH-done] arm32 Finished on the 32-bit ARM architecture (ARCH=arm) labels Aug 28, 2020
@kees
Copy link
Author

kees commented Aug 28, 2020

(I'm removing the "fixed" labels for arm32 and arm64 since there isn't Clang support yet...)

@tsautereau-anssi
Copy link

(I'm removing the "fixed" labels for arm32 and arm64 since there isn't Clang support yet...)

PowerPC isn't supported either in Clang, is it?

By the way, RISC-V support for -mstack-protector-guard landed in GCC on July.

@kees
Copy link
Author

kees commented Nov 20, 2020

Hm, I may need to split up the per-arch issues and per-compiler issues into separate bugs. Or a task list, perhaps.

@kees kees removed the [ARCH-done] powerpc64 Finished on the 64-bit POWER architecture label Nov 20, 2020
@kees
Copy link
Author

kees commented Nov 20, 2020

Okay, I've tried to collect the matrix in the bug description.

@kees
Copy link
Author

kees commented Mar 4, 2021

https://git.kernel.org/linus/fea2fed201ee5647699018a56fbb6a5e8cc053a5 in v5.12 (riscv per-task canary support for gcc)

@kees
Copy link
Author

kees commented Mar 4, 2021

Also tracked at ClangBuiltLinux#289

@kees kees added [ARCH-done] arm64 Finished on the 64-bit ARM architecture (ARCH=arm64) and removed [ARCH] arm64 Needed on the 64-bit ARM architecture (ARCH=arm64) labels May 18, 2021
@kees
Copy link
Author

kees commented May 18, 2021

Implemented in Clang for arm64 now: llvm/llvm-project@0f41778

@tsautereau-anssi
Copy link

tsautereau-anssi commented May 27, 2021

Implemented in Clang for arm64 now: llvm/llvm-project@0f41778

I think there's a leak of the canary though: llvm/llvm-project#46338 (originally https://bugs.llvm.org/show_bug.cgi?id=50467)

@kees
Copy link
Author

kees commented May 27, 2021

Thanks for the heads-up!

@kees kees added the [ARCH] powerpc32 Needed on the 32-bit POWER architecture label Sep 16, 2021
@kees kees added the [ARCH] powerpc64 Needed on the 64-bit POWER architecture label Sep 16, 2021
@nickdesaulniers
Copy link
Member

I just accepted https://reviews.llvm.org/D129346 which should close out llvm/llvm-project#48553. Therefor, I have marked

x86_32: -mstack-protector-guard-reg=fs -mstack-protector-guard-symbol=__stack_chk_guard, or old %gs offset before v5.13
gcc: implemented
clang: implemented

@keith-packard
Copy link

llvm/llvm-project#46685 has been closed

@nathanchance
Copy link
Collaborator

clang support for PowerPC was merged in llvm/llvm-project@44b020a (20.0.0) and the kernel was updated to support clang’s implementation with my changes in the 6.13 pull request.

@kees kees added [ARCH-done] powerpc64 Finished on the 64-bit POWER architecture [ARCH-done] riscv Finished on the RISC-V architecture (ARCH=riscv) [ARCH-done] powerpc32 Finished on the 32-bit POWER architecture and removed [ARCH] powerpc64 Needed on the 64-bit POWER architecture [ARCH] riscv Needed on the RISC-V architecture (ARCH=riscv) [ARCH] powerpc32 Needed on the 32-bit POWER architecture labels Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[ARCH] arm32 Needed on the 32-bit ARM architecture (ARCH=arm) [ARCH] mips Needed on the MIPS architecture (ARCH=mips) [ARCH] s390 Needed on the s390 architecture (ARCH=s390) [ARCH-done] arm64 Finished on the 64-bit ARM architecture (ARCH=arm64) [ARCH-done] powerpc32 Finished on the 32-bit POWER architecture [ARCH-done] powerpc64 Finished on the 64-bit POWER architecture [ARCH-done] riscv Finished on the RISC-V architecture (ARCH=riscv) [ARCH-done] x86_32 Finished on the 32-bit x86 architecture (ARCH=i386) [ARCH-done] x86_64 Finished on the 64-bit x86 architecture (ARCH=x86) compiler Needs compiler support
Projects
None yet
Development

No branches or pull requests

5 participants