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

Inline assembly warning gets turned into error #73160

Closed
jethrogb opened this issue Jun 9, 2020 · 1 comment · Fixed by #73169
Closed

Inline assembly warning gets turned into error #73160

jethrogb opened this issue Jun 9, 2020 · 1 comment · Fixed by #73169
Labels
A-inline-assembly Area: inline asm!(..) C-bug Category: This is a bug. F-asm `#![feature(asm)]` (not `llvm_asm`) requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jethrogb
Copy link
Contributor

jethrogb commented Jun 9, 2020

Warnings generated by LLVM in inline assembly are reported by rustc as errors.

For example:

#![feature(asm, llvm_asm)]
fn main() {
    unsafe{
        asm!("call *(%rax)", options(att_syntax));
        llvm_asm!("call *(%rax)");
    }
}

Compile with today's nightly or newer: rustc +nightly --target x86_64-fortanix-unknown-sgx test.rs. You'll get these errors:

error: Instruction may be vulnerable to LVI and requires manual mitigation
 --> test.rs:4:15
  |
4 |         asm!("call *(%rax)", options(att_syntax));
  |               ^
  |
note: instantiated into assembly here
 --> <inline asm>:1:2
  |
1 |     call *(%rax)
  |     ^

error: See https://software.intel.com/security-software-guidance/insights/deep-dive-load-value-injection#specialinstructions for more information

error: Instruction may be vulnerable to LVI and requires manual mitigation
 --> test.rs:5:9
  |
5 |         llvm_asm!("call *(%rax)");
  |         ^
  |
note: instantiated into assembly here
 --> <inline asm>:1:2
  |
1 |     call *(%rax)
  |     ^

error: aborting due to 3 previous errors

However, when using clang, these are reported as warnings. For example:

asm("call *(%rax)");

Compile with a recent Clang nightly: clang-11 -mlvi-hardening -mllvm -x86-experimental-lvi-inline-asm-hardening -c test.c. You'll get this warning:

<inline asm>:1:1: warning: Instruction may be vulnerable to LVI and requires manual mitigation [-Winline-asm]
call *(%rax)
^
note: See https://software.intel.com/security-software-guidance/insights/deep-dive-load-value-injection#specialinstructions for more information
1 warning generated.

Note this issue has nothing to do with SGX/LVI, it's just a convenient way to trigger the assembler warnings.

@jethrogb jethrogb changed the title Inline assembly warning gets turned into error. Inline assembly warning gets turned into error Jun 9, 2020
@jethrogb
Copy link
Contributor Author

jethrogb commented Jun 9, 2020

cc @Amanieu

@jonas-schievink jonas-schievink added A-inline-assembly Area: inline asm!(..) C-bug Category: This is a bug. F-asm `#![feature(asm)]` (not `llvm_asm`) requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 9, 2020
@bors bors closed this as completed in b341115 Jun 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-inline-assembly Area: inline asm!(..) C-bug Category: This is a bug. F-asm `#![feature(asm)]` (not `llvm_asm`) requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants