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

deny(unsafe_code) should prevent global_asm! usage. #103078

Closed
Lokathor opened this issue Oct 15, 2022 · 4 comments · Fixed by #121318
Closed

deny(unsafe_code) should prevent global_asm! usage. #103078

Lokathor opened this issue Oct 15, 2022 · 4 comments · Fixed by #121318
Labels
C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Lokathor
Copy link
Contributor

Lokathor commented Oct 15, 2022

Similar to how deny(unsafe_code) prevents #[no_mangle] from being used, it should also prevent global_asm! blocks from being allowed. If misused, they can do any number of strange and horrible thing simply by being within the crate.

@gimbling-away
Copy link
Contributor

@rustbot claim

@Rageking8
Copy link
Contributor

@rustbot label +C-bug +T-compiler

@rustbot rustbot added C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 16, 2022
@asquared31415
Copy link
Contributor

I suppose it's probably too late to actually make it require unsafe {}?

@Lokathor
Copy link
Contributor Author

that isn't even currently possible from a syntax perspective because unsafe blocks only work as expressions, you can't just put them around a top level item. It would take a whole RFC thing, even separately from global_asm already being stable.

@gimbling-away gimbling-away removed their assignment Nov 22, 2022
Noratrieb added a commit to Noratrieb/rust that referenced this issue Feb 20, 2024
…safe_code, r=Nilstrieb

Trigger `unsafe_code` lint on invocations of `global_asm`

`unsafe_code` already warns about things that don't involve the `unsafe` keyword, e.g. `#[no_mangle]`. This makes it warn on `core::arch::global_asm` too.

Fixes rust-lang#103078
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 20, 2024
Rollup merge of rust-lang#121318 - kadiwa4:no_assembly_in_supposedly_safe_code, r=Nilstrieb

Trigger `unsafe_code` lint on invocations of `global_asm`

`unsafe_code` already warns about things that don't involve the `unsafe` keyword, e.g. `#[no_mangle]`. This makes it warn on `core::arch::global_asm` too.

Fixes rust-lang#103078
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
5 participants