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

The check_abi function in typeck is not called for ABIs in trait declarations or type aliases #86232

Open
nagisa opened this issue Jun 11, 2021 · 0 comments
Labels
A-ABI Area: Concerning the application binary interface (ABI) C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nagisa
Copy link
Member

nagisa commented Jun 11, 2021

Consider the following code:

trait T {
    extern "amdgpu-kernel" fn mu();
}

type TAU = extern "amdgpu-kernel" fn();

The check_abi function…

pub(super) fn check_abi(tcx: TyCtxt<'_>, span: Span, abi: Abi) {
if !tcx.sess.target.is_abi_supported(abi) {
struct_span_err!(
tcx.sess,
span,
E0570,
"The ABI `{}` is not supported for the current target",
abi
)
.emit()
}
// This ABI is only allowed on function pointers
if abi == Abi::CCmseNonSecureCall {
struct_span_err!(
tcx.sess,
span,
E0781,
"the `\"C-cmse-nonsecure-call\"` ABI is only allowed on function pointers."
)
.emit()
}
}

… is not called for the following two ABI lines, meaning that the checks present therein do not activate, potentially allowing circumvention of the checks this function implements. In particular one thing that is allowed is taking the TAU function pointer as an argument and calling it on architectures where this ABI is unsupported.

This becomes especially relevant after #86231 lands.

@nagisa nagisa added the C-bug Category: This is a bug. label Nov 21, 2021
@ChrisDenton ChrisDenton added the needs-triage-legacy Old issue that were never triaged. Remove this label once the issue has been sufficiently triaged. label Jul 16, 2023
@fmease fmease added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-ABI Area: Concerning the application binary interface (ABI) and removed needs-triage-legacy Old issue that were never triaged. Remove this label once the issue has been sufficiently triaged. labels Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ABI Area: Concerning the application binary interface (ABI) C-bug Category: This is a bug. 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

3 participants