Skip to content

Commit 3ef2ae6

Browse files
committed
Disable CFI for weakly linked syscalls
Currently, when enabling CFI via -Zsanitizer=cfi and executing e.g. std::sys::random::getrandom, we can observe a CFI violation. This is the case for all consumers of the std::sys::pal::weak::syscall macro, as it is defining weak functions which don't show up in LLVM IR metadata. CFI fails for all these functions. Similar to other such cases in #115199, this change stops emitting the CFI typecheck for consumers of the macro via the \#[no_sanitize(cfi)] attribute.
1 parent fd17dea commit 3ef2ae6

File tree

1 file changed

+3
-0
lines changed
  • library/std/src/sys/pal/unix

1 file changed

+3
-0
lines changed

library/std/src/sys/pal/unix/weak.rs

+3
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ unsafe fn fetch(name: &str) -> *mut libc::c_void {
144144
#[cfg(not(any(target_os = "linux", target_os = "android")))]
145145
pub(crate) macro syscall {
146146
(fn $name:ident($($arg_name:ident: $t:ty),*) -> $ret:ty) => (
147+
// FIXME: Rust currently omits weak function definitions
148+
// and its metadata from LLVM IR.
149+
#[no_sanitize(cfi)]
147150
unsafe fn $name($($arg_name: $t),*) -> $ret {
148151
weak! { fn $name($($t),*) -> $ret }
149152

0 commit comments

Comments
 (0)