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 encode_ty: unexpected Param(B/#1) #111697

Merged
merged 1 commit into from
May 21, 2023

Conversation

rcvalle
Copy link
Member

@rcvalle rcvalle commented May 17, 2023

Fixes #111510 and complements #106547 by adding support for encoding type parameters and also by transforming trait objects' traits into their identities before emitting type checks.

@rustbot
Copy link
Collaborator

rustbot commented May 17, 2023

r? @davidtwco

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added 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 May 17, 2023
@rcvalle
Copy link
Member Author

rcvalle commented May 17, 2023

r? @matthiaskrgr

@rustbot rustbot assigned matthiaskrgr and unassigned davidtwco May 17, 2023
@rcvalle rcvalle added the PG-exploit-mitigations Project group: Exploit mitigations label May 17, 2023
@rust-log-analyzer

This comment has been minimized.

Fixes rust-lang#111510 and complements rust-lang#106547 by adding support for encoding
type parameters and also by transforming trait objects' traits into
their identities before emitting type checks.
let mut s = String::from("u5param");
compress(dict, DictKey::Ty(ty, TyQ::None), &mut s);
typeid.push_str(&s);
}
Copy link
Member

Choose a reason for hiding this comment

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

Without -Zpolymorphize this shouldn't happen unless a monomorphization is missing I think.

Copy link
Member Author

Choose a reason for hiding this comment

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

The reason for this is when transforming the concrete self into a reference to a trait object before emitting type metadata identifiers for trait methods (in predefine_fn), the trait resolved from the method is the identity trait (i.e., early bound), and this is also necessary for trait objects with generic type parameters (see Trait3 in tests).

Unless there is a way to bind the traits at that time, we'll need to work with identity traits (i.e., early bound) and add support for encoding early bound types both when emitting type metadata identifiers for trait methods and when emitting type checks.

@rcvalle
Copy link
Member Author

rcvalle commented May 18, 2023

r? @bjorn3

@rustbot rustbot assigned bjorn3 and unassigned matthiaskrgr May 18, 2023
@bjorn3
Copy link
Member

bjorn3 commented May 19, 2023

I'm not entirely confident that the ty::Param encoding is correct, but I think it makes anything worse either.

@bors r+

@bors
Copy link
Contributor

bors commented May 19, 2023

📌 Commit f067935 has been approved by bjorn3

It is now in the queue for this repository.

@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 May 19, 2023
@bors
Copy link
Contributor

bors commented May 21, 2023

⌛ Testing commit f067935 with merge d77014a...

@bors
Copy link
Contributor

bors commented May 21, 2023

☀️ Test successful - checks-actions
Approved by: bjorn3
Pushing d77014a to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 21, 2023
@bors bors merged commit d77014a into rust-lang:master May 21, 2023
@rustbot rustbot added this to the 1.71.0 milestone May 21, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (d77014a): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

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

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not 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)
-3.5% [-3.6%, -3.3%] 2
All ❌✅ (primary) - - 0

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

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

Binary size

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

Bootstrap: 644.164s -> 644.012s (-0.02%)

@rcvalle rcvalle deleted the rust-cfi-fix-111510 branch April 22, 2024 23:06
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.

ICE: cfi: encode_ty: unexpected Param(B/#1)
8 participants