|
Message-ID: <6106be97-2c82-75c0-ad88-2e49b17c68ee@darkkirb.de> Date: Sun, 27 Dec 2020 18:53:01 +0100 From: Charlotte Delenk <darkkirb@...kkirb.de> To: musl@...ts.openwall.com Subject: [PATCH] Add support for LLVM's Control Flow Integrity Hi, I have attempted to use musl HEAD together with clang's -fsanitize=cfi, but currently it requires the main function to take all 3 arguments and return an int. After this patch is applied, clang will no longer try to add CFI sanitization to the libc_start_main_stage2 function, allowing programs to get to main(). I have tested CFI sanitization for both regular indirect functions (qsort()) and thread creation and validly typed function pointers cause no runtime aborts with CFI enabled for the whole program. --- src/env/__libc_start_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/env/__libc_start_main.c b/src/env/__libc_start_main.c index 8fbe5262..af61fb7c 100644 --- a/src/env/__libc_start_main.c +++ b/src/env/__libc_start_main.c @@ -85,6 +85,9 @@ int __libc_start_main(int (*main)(int,char **,char **), int argc, char **argv) return stage2(main, argc, argv); } +#ifdef __clang__ +__attribute__((no_sanitize("cfi"))) +#endif static int libc_start_main_stage2(int (*main)(int,char **,char **), int argc, char **argv) { char **envp = argv+argc+1; -- 2.29.2
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.