From: Charlotte Delenk <darkkirb@darkkirb.de>
To: musl@lists.openwall.com
Subject: [musl] [PATCH] Add support for LLVM's Control Flow Integrity
Date: Sun, 27 Dec 2020 18:53:01 +0100 [thread overview]
Message-ID: <6106be97-2c82-75c0-ad88-2e49b17c68ee@darkkirb.de> (raw)
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
next reply other threads:[~2020-12-27 17:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-27 17:53 Charlotte Delenk [this message]
2020-12-27 23:05 ` Fangrui Song
2020-12-28 0:56 ` Fangrui Song
2020-12-28 9:20 ` Charlotte Delenk
2020-12-28 13:17 ` [musl] [PATCH] Add support for LLVM's Control Flow Integrity (V2) Charlotte Delenk
2020-12-28 17:01 ` Shiz
2020-12-29 1:26 ` Rich Felker
2020-12-29 10:20 ` Charlotte Delenk
2020-12-29 11:56 ` [musl] [PATCH 1/2] Fix LTO shared library build on GCC and Clang Charlotte Delenk
2020-12-29 11:59 ` [musl] [PATCH 2/2] Add support for LLVM's Control Flow Integrity Charlotte Delenk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6106be97-2c82-75c0-ad88-2e49b17c68ee@darkkirb.de \
--to=darkkirb@darkkirb.de \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).