-
Notifications
You must be signed in to change notification settings - Fork 434
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
objtool warnings in KernelCI report #945
Comments
Thanks for the report as usual! We briefly discussed it on a meeting on Wednesday. IBT/Retpoline/Rethunk require a few things to be in place:
In a patched
The resulting kernel boots in QEMU, but will need to be tested properly in real hardware. We will have to wait at least a couple months to get all the pieces in place, so I have submitted a PR to our KernelCI config to disable these: kernelci/kernelci-core#1580 |
Until we have the needed pieces in place in `rustc` and the kernel to support IBT/Retpoline/Rethunk; disable the relevant configs for the moment. This avoids the 2000+ warnings from `objtool` that we currently generate in the logs. Link: https://storage.kernelci.org/mainline/master/v6.1-11554-g785d21ba2f44/x86_64/x86_64_defconfig+rust/rustc-1.62/logs/build-warnings.log Link: Rust-for-Linux/linux#945 Signed-off-by: Miguel Ojeda <[email protected]>
Until we have the needed pieces in place in `rustc` and the kernel to support IBT/Retpoline/Rethunk; disable the relevant configs for the moment. This avoids the 2000+ warnings from `objtool` that we currently generate in the logs. Link: https://storage.kernelci.org/mainline/master/v6.1-11554-g785d21ba2f44/x86_64/x86_64_defconfig+rust/rustc-1.62/logs/build-warnings.log Link: Rust-for-Linux/linux#945 Signed-off-by: Miguel Ojeda <[email protected]>
For reference, a couple updates: |
The series https://lore.kernel.org/rust-for-linux/[email protected]/ should fix all of those warnings. |
Support `MITIGATION_RETPOLINE` by enabling the target features that Clang does. The existing target feature being enabled was a leftover from our old `rust` branch, and it is not enough: the target feature `retpoline-external-thunk` only implies `retpoline-indirect-calls`, but not `retpoline-indirect-branches` (see LLVM's `X86.td`), unlike Clang's flag of the same name `-mretpoline-external-thunk` which does imply both (see Clang's `lib/Driver/ToolChains/Arch/X86.cpp`). Without this, `objtool` would complain if enabled for Rust, e.g.: rust/core.o: warning: objtool: _R...escape_default+0x13: indirect jump found in RETPOLINE build In addition, change the comment to note that LLVM is the one disabling jump tables when retpoline is enabled, thus we do not need to use `-Zno-jump-tables` for Rust here -- see commit c58f2166ab39 ("Introduce the "retpoline" x86 mitigation technique ...") [1]: The goal is simple: avoid generating code which contains an indirect branch that could have its prediction poisoned by an attacker. In many cases, the compiler can simply use directed conditional branches and a small search tree. LLVM already has support for lowering switches in this way and the first step of this patch is to disable jump-table lowering of switches and introduce a pass to rewrite explicit indirectbr sequences into a switch over integers. As well as a live example at [2]. These should be eventually enabled via `-Ctarget-feature` when `rustc` starts recognizing them (or via a new dedicated flag) [3]. Cc: Daniel Borkmann <[email protected]> Link: llvm/llvm-project@c58f216 [1] Link: https://godbolt.org/z/G4YPr58qG [2] Link: rust-lang/rust#116852 [3] Reviewed-by: Gary Guo <[email protected]> Tested-by: Alice Ryhl <[email protected]> Tested-by: Benno Lossin <[email protected]> Link: Rust-for-Linux#945 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
The Rust compiler added support for `-Zfunction-return=thunk-extern` [1] in 1.76.0 [2], i.e. the equivalent of `-mfunction-return=thunk-extern`. Thus add support for `MITIGATION_RETHUNK`. Without this, `objtool` would warn if enabled for Rust and already warns under IBT builds, e.g.: samples/rust/rust_print.o: warning: objtool: _R...init+0xa5c: 'naked' return found in RETHUNK build Link: rust-lang/rust#116853 [1] Link: rust-lang/rust#116892 [2] Reviewed-by: Gary Guo <[email protected]> Tested-by: Alice Ryhl <[email protected]> Tested-by: Benno Lossin <[email protected]> Reviewed-by: Thomas Gleixner <[email protected]> Link: Rust-for-Linux#945 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
Support `MITIGATION_RETPOLINE` by enabling the target features that Clang does. The existing target feature being enabled was a leftover from our old `rust` branch, and it is not enough: the target feature `retpoline-external-thunk` only implies `retpoline-indirect-calls`, but not `retpoline-indirect-branches` (see LLVM's `X86.td`), unlike Clang's flag of the same name `-mretpoline-external-thunk` which does imply both (see Clang's `lib/Driver/ToolChains/Arch/X86.cpp`). Without this, `objtool` would complain if enabled for Rust, e.g.: rust/core.o: warning: objtool: _R...escape_default+0x13: indirect jump found in RETPOLINE build In addition, change the comment to note that LLVM is the one disabling jump tables when retpoline is enabled, thus we do not need to use `-Zno-jump-tables` for Rust here -- see commit c58f2166ab39 ("Introduce the "retpoline" x86 mitigation technique ...") [1]: The goal is simple: avoid generating code which contains an indirect branch that could have its prediction poisoned by an attacker. In many cases, the compiler can simply use directed conditional branches and a small search tree. LLVM already has support for lowering switches in this way and the first step of this patch is to disable jump-table lowering of switches and introduce a pass to rewrite explicit indirectbr sequences into a switch over integers. As well as a live example at [2]. These should be eventually enabled via `-Ctarget-feature` when `rustc` starts recognizing them (or via a new dedicated flag) [3]. Cc: Daniel Borkmann <[email protected]> Link: llvm/llvm-project@c58f216 [1] Link: https://godbolt.org/z/G4YPr58qG [2] Link: rust-lang/rust#116852 [3] Reviewed-by: Gary Guo <[email protected]> Tested-by: Alice Ryhl <[email protected]> Tested-by: Benno Lossin <[email protected]> Link: #945 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
The Rust compiler added support for `-Zfunction-return=thunk-extern` [1] in 1.76.0 [2], i.e. the equivalent of `-mfunction-return=thunk-extern`. Thus add support for `MITIGATION_RETHUNK`. Without this, `objtool` would warn if enabled for Rust and already warns under IBT builds, e.g.: samples/rust/rust_print.o: warning: objtool: _R...init+0xa5c: 'naked' return found in RETHUNK build Link: rust-lang/rust#116853 [1] Link: rust-lang/rust#116892 [2] Reviewed-by: Gary Guo <[email protected]> Tested-by: Alice Ryhl <[email protected]> Tested-by: Benno Lossin <[email protected]> Reviewed-by: Thomas Gleixner <[email protected]> Link: #945 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
Support `MITIGATION_RETPOLINE` by enabling the target features that Clang does. The existing target feature being enabled was a leftover from our old `rust` branch, and it is not enough: the target feature `retpoline-external-thunk` only implies `retpoline-indirect-calls`, but not `retpoline-indirect-branches` (see LLVM's `X86.td`), unlike Clang's flag of the same name `-mretpoline-external-thunk` which does imply both (see Clang's `lib/Driver/ToolChains/Arch/X86.cpp`). Without this, `objtool` would complain if enabled for Rust, e.g.: rust/core.o: warning: objtool: _R...escape_default+0x13: indirect jump found in RETPOLINE build In addition, change the comment to note that LLVM is the one disabling jump tables when retpoline is enabled, thus we do not need to use `-Zno-jump-tables` for Rust here -- see commit c58f2166ab39 ("Introduce the "retpoline" x86 mitigation technique ...") [1]: The goal is simple: avoid generating code which contains an indirect branch that could have its prediction poisoned by an attacker. In many cases, the compiler can simply use directed conditional branches and a small search tree. LLVM already has support for lowering switches in this way and the first step of this patch is to disable jump-table lowering of switches and introduce a pass to rewrite explicit indirectbr sequences into a switch over integers. As well as a live example at [2]. These should be eventually enabled via `-Ctarget-feature` when `rustc` starts recognizing them (or via a new dedicated flag) [3]. Cc: Daniel Borkmann <[email protected]> Link: llvm/llvm-project@c58f216 [1] Link: https://godbolt.org/z/G4YPr58qG [2] Link: rust-lang/rust#116852 [3] Reviewed-by: Gary Guo <[email protected]> Tested-by: Alice Ryhl <[email protected]> Tested-by: Benno Lossin <[email protected]> Link: #945 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
The Rust compiler added support for `-Zfunction-return=thunk-extern` [1] in 1.76.0 [2], i.e. the equivalent of `-mfunction-return=thunk-extern`. Thus add support for `MITIGATION_RETHUNK`. Without this, `objtool` would warn if enabled for Rust and already warns under IBT builds, e.g.: samples/rust/rust_print.o: warning: objtool: _R...init+0xa5c: 'naked' return found in RETHUNK build Link: rust-lang/rust#116853 [1] Link: rust-lang/rust#116892 [2] Reviewed-by: Gary Guo <[email protected]> Tested-by: Alice Ryhl <[email protected]> Tested-by: Benno Lossin <[email protected]> Reviewed-by: Thomas Gleixner <[email protected]> Link: #945 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
Applied to |
Support `MITIGATION_RETPOLINE` by enabling the target features that Clang does. The existing target feature being enabled was a leftover from our old `rust` branch, and it is not enough: the target feature `retpoline-external-thunk` only implies `retpoline-indirect-calls`, but not `retpoline-indirect-branches` (see LLVM's `X86.td`), unlike Clang's flag of the same name `-mretpoline-external-thunk` which does imply both (see Clang's `lib/Driver/ToolChains/Arch/X86.cpp`). Without this, `objtool` would complain if enabled for Rust, e.g.: rust/core.o: warning: objtool: _R...escape_default+0x13: indirect jump found in RETPOLINE build In addition, change the comment to note that LLVM is the one disabling jump tables when retpoline is enabled, thus we do not need to use `-Zno-jump-tables` for Rust here -- see commit c58f2166ab39 ("Introduce the "retpoline" x86 mitigation technique ...") [1]: The goal is simple: avoid generating code which contains an indirect branch that could have its prediction poisoned by an attacker. In many cases, the compiler can simply use directed conditional branches and a small search tree. LLVM already has support for lowering switches in this way and the first step of this patch is to disable jump-table lowering of switches and introduce a pass to rewrite explicit indirectbr sequences into a switch over integers. As well as a live example at [2]. These should be eventually enabled via `-Ctarget-feature` when `rustc` starts recognizing them (or via a new dedicated flag) [3]. Cc: Daniel Borkmann <[email protected]> Link: llvm/llvm-project@c58f216 [1] Link: https://godbolt.org/z/G4YPr58qG [2] Link: rust-lang/rust#116852 [3] Reviewed-by: Gary Guo <[email protected]> Tested-by: Alice Ryhl <[email protected]> Tested-by: Benno Lossin <[email protected]> Link: Rust-for-Linux#945 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
The Rust compiler added support for `-Zfunction-return=thunk-extern` [1] in 1.76.0 [2], i.e. the equivalent of `-mfunction-return=thunk-extern`. Thus add support for `MITIGATION_RETHUNK`. Without this, `objtool` would warn if enabled for Rust and already warns under IBT builds, e.g.: samples/rust/rust_print.o: warning: objtool: _R...init+0xa5c: 'naked' return found in RETHUNK build Link: rust-lang/rust#116853 [1] Link: rust-lang/rust#116892 [2] Reviewed-by: Gary Guo <[email protected]> Tested-by: Alice Ryhl <[email protected]> Tested-by: Benno Lossin <[email protected]> Reviewed-by: Thomas Gleixner <[email protected]> Link: Rust-for-Linux#945 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
Apologies if this has been reported already! KernelCI recently started testing with Rust and it seems that there are quite a few
objtool
warnings for Rust code: https://lore.kernel.org/llvm/[email protected]/The text was updated successfully, but these errors were encountered: