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: Fix methods as function pointer cast #123071

Merged
merged 1 commit into from
Mar 29, 2024

Conversation

rcvalle
Copy link
Member

@rcvalle rcvalle commented Mar 26, 2024

Fix casting between methods and function pointers by assigning a secondary type id to methods with their concrete self so they can be used as function pointers.

This was split off from #116404.

cc @compiler-errors @workingjubilee

@rustbot
Copy link
Collaborator

rustbot commented Mar 26, 2024

r? @wesleywiser

rustbot has assigned @wesleywiser.
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. labels Mar 26, 2024
@rustbot
Copy link
Collaborator

rustbot commented Mar 26, 2024

Some changes occurred in tests/codegen/sanitizer

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

Some changes occurred in tests/ui/sanitizer

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

Some changes occurred in compiler/rustc_symbol_mangling/src/typeid

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

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 26, 2024
@rcvalle
Copy link
Member Author

rcvalle commented Mar 26, 2024

r? @compiler-errors

@rcvalle rcvalle force-pushed the rust-cfi-fix-method-fn-ptr-cast branch from 871deec to 4746c28 Compare March 26, 2024 02:29
@bors
Copy link
Contributor

bors commented Mar 26, 2024

☔ The latest upstream changes (presumably #123065) made this pull request unmergeable. Please resolve the merge conflicts.

@rcvalle rcvalle force-pushed the rust-cfi-fix-method-fn-ptr-cast branch from 4746c28 to 9449923 Compare March 26, 2024 05:40
@maurer
Copy link
Contributor

maurer commented Mar 27, 2024

Overall LGTM. I would like to reduce the alias set and avoid using dyn Drop which already has a meaning distinct from what we're using here (maybe dyn Destruct?), but that can be done in a future PR, doesn't need to be this one.

Copy link
Contributor

@maurer maurer left a comment

Choose a reason for hiding this comment

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

Overall LGTM

compiler/rustc_codegen_llvm/src/declare.rs Outdated Show resolved Hide resolved
compiler/rustc_codegen_llvm/src/declare.rs Outdated Show resolved Hide resolved
@rcvalle rcvalle force-pushed the rust-cfi-fix-method-fn-ptr-cast branch from 9449923 to 58d656b Compare March 27, 2024 06:29
compiler/rustc_codegen_llvm/src/declare.rs Outdated Show resolved Hide resolved
compiler/rustc_codegen_llvm/src/declare.rs Outdated Show resolved Hide resolved
compiler/rustc_codegen_llvm/src/declare.rs Outdated Show resolved Hide resolved
compiler/rustc_symbol_mangling/src/typeid.rs Outdated Show resolved Hide resolved
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 27, 2024
@rcvalle rcvalle force-pushed the rust-cfi-fix-method-fn-ptr-cast branch 3 times, most recently from 4f69501 to b737bd4 Compare March 27, 2024 22:21
Fix casting between methods and function pointers by assigning a
secondary type id to methods with their concrete self so they can be
used as function pointers.
@rcvalle rcvalle force-pushed the rust-cfi-fix-method-fn-ptr-cast branch from b737bd4 to 8e6b4e9 Compare March 27, 2024 23:19
@rcvalle
Copy link
Member Author

rcvalle commented Mar 28, 2024

@rustbot label -S-waiting-on-author +S-waiting-on-review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 28, 2024
@compiler-errors
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Mar 28, 2024

📌 Commit 8e6b4e9 has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 28, 2024
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Mar 28, 2024
@bors
Copy link
Contributor

bors commented Mar 28, 2024

⌛ Testing commit 8e6b4e9 with merge 30e054f...

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 28, 2024
…ast, r=compiler-errors

CFI: Fix methods as function pointer cast

Fix casting between methods and function pointers by assigning a secondary type id to methods with their concrete self so they can be used as function pointers.

This was split off from rust-lang#116404.

cc `@compiler-errors` `@workingjubilee`
@bors
Copy link
Contributor

bors commented Mar 28, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 28, 2024
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-msvc-ext failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
-- Configuring done (29.8s)
-- Generating done (2.6s)
-- Build files have been written to: C:/a/rust/rust/build/x86_64-pc-windows-msvc/llvm/build
running: "cmake" "--build" "." "--target" "install" "--config" "Release" "--" "-j" "8"
ninja: error: build.ninja:3780: multiple outputs aren't (yet?) supported by depslog; bring this up on the mailing list if it affects you
thread 'main' panicked at C:\Users\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\cmake-0.1.48\src\lib.rs:975:5:

command did not execute successfully, got: exit code: 1

@matthiaskrgr
Copy link
Member

@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 28, 2024
@bors
Copy link
Contributor

bors commented Mar 29, 2024

⌛ Testing commit 8e6b4e9 with merge 58dcd1f...

@bors
Copy link
Contributor

bors commented Mar 29, 2024

☀️ Test successful - checks-actions
Approved by: compiler-errors
Pushing 58dcd1f to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 29, 2024
@bors bors merged commit 58dcd1f into rust-lang:master Mar 29, 2024
12 checks passed
@rustbot rustbot added this to the 1.79.0 milestone Mar 29, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (58dcd1f): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.2% [-1.2%, -1.2%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 668.406s -> 668.769s (0.05%)
Artifact size: 315.93 MiB -> 315.81 MiB (-0.04%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

9 participants