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

OSX CFI produces relocation issues #122848

Open
maurer opened this issue Mar 21, 2024 · 0 comments
Open

OSX CFI produces relocation issues #122848

maurer opened this issue Mar 21, 2024 · 0 comments
Labels
A-sanitizers Area: Sanitizers for correctness and code quality C-bug Category: This is a bug. O-macos Operating system: macOS PG-exploit-mitigations Project group: Exploit mitigations T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@maurer
Copy link
Contributor

maurer commented Mar 21, 2024

As seen when testing #122456

I tried this code:

pub fn main() {
  let f: &fn() = &((|| ()) as _);
  f();
} 

compiled with rustc --crate-type=bin -C prefer-dynamic=off -Clto -Zsanitizer=cfi -C target-feature=-crt-static -C codegen-units=1 -C opt-level=0 on OSX

I expected to see this happen: Builds successfully

Instead, this happened: Relocation issues:

command: RUSTC_ICE="0" "/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage2/bin/rustc" "/Users/runner/work/rust/rust/tests/ui/sanitizer/cfi-closure-fn-ptr-cast.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/Users/runner/.cargo" "--sysroot" "/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage2" "--target=x86_64-apple-darwin" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "-o" "/Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/ui/sanitizer/cfi-closure-fn-ptr-cast/a" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/native/rust-test-helpers" "-L" "/Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/ui/sanitizer/cfi-closure-fn-ptr-cast/auxiliary" "--crate-type=bin" "-Cprefer-dynamic=off" "-Clto" "-Zsanitizer=cfi" "-C" "target-feature=-crt-static" "-C" "codegen-units=1" "-C" "opt-level=0"
--- stderr -------------------------------
error: unsupported symbol modifier in branch relocation
   |
note: instantiated into assembly here
note: instantiated into assembly here
  --> <inline asm>:1:2
   |
LL |     jmp __ZN4core3ops8function6FnOnce9call_once17hbd679098001308bdE.cfi@plt

error: unsupported symbol modifier in branch relocation
   |
note: instantiated into assembly here
note: instantiated into assembly here
  --> <inline asm>:5:1
   |
LL | jmp __ZN23cfi_closure_fn_ptr_cast4main17hec6d7c750d93313aE.cfi@plt

error: aborting due to 2 previous errors
------------------------------------------

The patch being tested only adjusts labels, so this bug is about fixing actually producing CFI executables on OSX - all the previously existing tests were codegen only.

It is likely that a much smaller program (possibly anything with an indirect call? any function?) will trigger this issue without needing the FnPtrShim, but I don't personally have a mac to test with.

@maurer maurer added the C-bug Category: This is a bug. label Mar 21, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 21, 2024
@jieyouxu jieyouxu added PG-exploit-mitigations Project group: Exploit mitigations O-macos Operating system: macOS T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 21, 2024
@workingjubilee workingjubilee added A-sanitizers Area: Sanitizers for correctness and code quality and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sanitizers Area: Sanitizers for correctness and code quality C-bug Category: This is a bug. O-macos Operating system: macOS PG-exploit-mitigations Project group: Exploit mitigations T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants