From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Wainer dos Santos Moschetta" <wainersm@redhat.com>,
"Thomas Huth" <thuth@redhat.com>,
"Beraldo Leal" <bleal@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Daniel P. Berrangé" <berrange@redhat.com>
Subject: [PATCH 1/2] meson: detect broken clang 17 with -fzero-call-used-regs
Date: Mon, 4 Mar 2024 14:44:55 +0000 [thread overview]
Message-ID: <20240304144456.3825935-2-berrange@redhat.com> (raw)
In-Reply-To: <20240304144456.3825935-1-berrange@redhat.com>
Clang 17 will segv if given -fzero-call-used-regs and optimization
is enabled. Since upstream hasn't triaged the bug, distros are
increasingly shipping with broken Clang.
https://github.com/llvm/llvm-project/issues/75168
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277474
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
meson.build | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/meson.build b/meson.build
index 0ef1654e86..762798f2ee 100644
--- a/meson.build
+++ b/meson.build
@@ -555,17 +555,24 @@ endif
# Check further flags that make QEMU more robust against malicious parties
hardening_flags = [
- # Zero out registers used during a function call
- # upon its return. This makes it harder to assemble
- # ROP gadgets into something usable
- '-fzero-call-used-regs=used-gpr',
-
# Initialize all stack variables to zero. This makes
# it harder to take advantage of uninitialized stack
# data to drive exploits
'-ftrivial-auto-var-init=zero',
]
+# Zero out registers used during a function call
+# upon its return. This makes it harder to assemble
+# ROP gadgets into something usable
+#
+# NB: CLang 17 is broken and SEGVs
+# https://github.com/llvm/llvm-project/issues/75168
+if cc.compiles('extern struct { void (*cb)(void); } s; void f(void) { s.cb(); }',
+ name: '-fzero-call-used-regs=used-gpr',
+ args: ['-O2', '-fzero-call-used-regs=used-gpr'])
+ hardening_flags += '-fzero-call-used-regs=used-gpr'
+endif
+
qemu_common_flags += cc.get_supported_arguments(hardening_flags)
add_global_arguments(qemu_common_flags, native: false, language: all_languages)
--
2.43.0
next prev parent reply other threads:[~2024-03-04 14:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-04 14:44 [PATCH 0/2] Fix CI build on Free BSD 13 Daniel P. Berrangé
2024-03-04 14:44 ` Daniel P. Berrangé [this message]
2024-03-04 14:48 ` [PATCH 1/2] meson: detect broken clang 17 with -fzero-call-used-regs Peter Maydell
2024-03-04 14:44 ` [PATCH 2/2] gitlab: update FreeBSD Cirrus CI image to 13.3 Daniel P. Berrangé
2024-03-04 14:49 ` Peter Maydell
2024-03-04 14:53 ` Daniel P. Berrangé
2024-03-04 17:05 ` [PATCH 0/2] Fix CI build on Free BSD 13 Richard Henderson
2024-03-04 21:16 ` Alex Bennée
2024-03-05 9:44 ` Peter Maydell
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=20240304144456.3825935-2-berrange@redhat.com \
--to=berrange@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=bleal@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
--cc=wainersm@redhat.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.