-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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: Repair vtables without altering types #122573
Commits on Mar 14, 2024
-
This query computes the trait object, complete with associated type projections for its supertraits, from a trait ref. This is intended for use by CFI shimming.
Configuration menu - View commit details
-
Copy full SHA for 7578cc5 - Browse repository at this point
Copy the full SHA 7578cc5View commit details -
Refactor visiting instance_def
In preparation to add recursive instance_defs, move this logic to its own convenience method.
Configuration menu - View commit details
-
Copy full SHA for f50baef - Browse repository at this point
Copy the full SHA f50baefView commit details -
Factored out to minimize the amount of noise in the main CfiShim defining patch.
Configuration menu - View commit details
-
Copy full SHA for 0b49e3c - Browse repository at this point
Copy the full SHA 0b49e3cView commit details
Commits on Mar 15, 2024
-
CFI: Use Instance at callsites
We already use `Instance` at declaration sites when available to glean additional information about possible abstractions of the type in use. This does the same when possible at callsites as well. The primary purpose of this change is to allow CFI to alter how it generates type information for indirect calls through `Virtual` instances.
Configuration menu - View commit details
-
Copy full SHA for 8aaa391 - Browse repository at this point
Copy the full SHA 8aaa391View commit details -
Indirect calls through vtables (trait objects or drop_in_place) expect to have an alias set based on `dyn Trait` at the call-site. The actual implementations have aslias sets based on `MyImplType`. These shims create a separate `InstanceDef`, allowing a different type to be assigned. These function for both CFI and KCFI, as they have a single principal type.
Configuration menu - View commit details
-
Copy full SHA for c9ff274 - Browse repository at this point
Copy the full SHA c9ff274View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7fd0f60 - Browse repository at this point
Copy the full SHA 7fd0f60View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1d81d8e - Browse repository at this point
Copy the full SHA 1d81d8eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 6538cdb - Browse repository at this point
Copy the full SHA 6538cdbView commit details -
CFI: Skip non-passed arguments
Rust will occasionally rely on fn((), X) -> Y being compatible with fn(X) -> Y, since () is a non-passed argument. Relax CFI by choosing not to encode non-passed arguments.
Configuration menu - View commit details
-
Copy full SHA for 614f30c - Browse repository at this point
Copy the full SHA 614f30cView commit details -
CFI: Support self_cell-like recursion
Current `transform_ty` attempts to avoid cycles when normalizing `#[repr(transparent)]` types to their interior, but runs afoul of this pattern used in `self_cell`: ``` struct X<T> { x: u8, p: PhantomData<T>, } #[repr(transparent)] struct Y(X<Y>); ``` When attempting to normalize Y, it will still cycle indefinitely. By using a types-visited list, this will instead get expanded exactly one layer deep to X<Y>, and then stop, not attempting to normalize `Y` any further.
Configuration menu - View commit details
-
Copy full SHA for 54cf2dc - Browse repository at this point
Copy the full SHA 54cf2dcView commit details -
CFI: Generate super vtables explicitly
CFI shimming means they're not gauranteed to be pre-generated. Traditionally, the base vtable has all the elements of the supertrait vtable, and so visiting the base vtable implies you don't need to visit the supertrait vtable. However, with CFI the base vtable entries will have invocation type `dyn Child`, and the parent vtable will have invocation type `dyn Parent`, so they aren't actually the same instance, and both must be visited.
Configuration menu - View commit details
-
Copy full SHA for c74b018 - Browse repository at this point
Copy the full SHA c74b018View commit details -
CFI: Strip auto traits off Self for virtual calls
Additional trait bounds beyond the principal trait and its implications are not possible in the vtable. This means that if a receiver is `&dyn Foo + Send`, the function will only be expecting `&dyn Foo`. This strips those auto traits off before CFI encoding.
Configuration menu - View commit details
-
Copy full SHA for 54b15b0 - Browse repository at this point
Copy the full SHA 54b15b0View commit details -
CFI: Handle dyn with no principal
In user-facing Rust, `dyn` always has at least one predicate following it. Unfortunately, because we filter out marker traits and `dyn Sync` is, for example, legal, this results in us having `dyn` types with no predicates on occasion. This patch handles cases where there are no predicates in a `dyn` type.
Configuration menu - View commit details
-
Copy full SHA for a93f25b - Browse repository at this point
Copy the full SHA a93f25bView commit details