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

CFI: Append debug location to CFI blocks #132702

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

1c3t3a
Copy link
Contributor

@1c3t3a 1c3t3a commented Nov 6, 2024

Currently we're not appending debug locations to the inserted CFI blocks. This shows up in #132615 and #100783. This change fixes that by passing down the debug location to the CFI type-test generation and appending it to the blocks.

@rustbot
Copy link
Collaborator

rustbot commented Nov 6, 2024

r? @BoxyUwU

rustbot has assigned @BoxyUwU.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 6, 2024
@rustbot
Copy link
Collaborator

rustbot commented Nov 6, 2024

Some changes occurred in tests/codegen/sanitizer

cc @rust-lang/project-exploit-mitigations, @rcvalle

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo, @GuillaumeGomez

@@ -222,7 +222,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
}
}

fn dbg_loc(&self, source_info: mir::SourceInfo) -> Option<Bx::DILocation> {
pub fn dbg_loc(&self, source_info: mir::SourceInfo) -> Option<Bx::DILocation> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing to point out: I need to turn a mir::SourceInfo into a Bx::DILocation and this was the only place I found that does that. I just marked the function public to also use it when generating the block (compiler/rustc_codegen_ssa/src/mir/block.rs), I hope that is fine.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My guess is this should be fine (cc @compiler-errors).

@1c3t3a
Copy link
Contributor Author

1c3t3a commented Nov 6, 2024

r? @rcvalle

@rustbot rustbot assigned rcvalle and unassigned BoxyUwU Nov 6, 2024
@rcvalle
Copy link
Member

rcvalle commented Nov 6, 2024

Thank you for your time and for working on this, @1c3t3a ! Much appreciated.

Alternatively, this could be implemented by passing back/returning the blocks created by CFI to rustc_codegen_ssa if any, but I'm OK with this implementation. I think invoke and call need some refactoring (and possibly being consolidated into one) anyway, and from past conversations with @bjorn3 seemed to agree, and might be interested in providing feedback here. Otherwise; LGTM (FYI @cuviper).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants