You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: text/0000-cmse-calling-conventions.md
+21-6Lines changed: 21 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -99,12 +99,12 @@ Currently both ABIs disallow the use of c-variadics. For `cmse-nonsecure-entry`,
99
99
- but accepts c-variadic nonsecure calls: https://godbolt.org/z/5rdK58ar4
100
100
101
101
For `cmse-nonsecure-call`, we may stabilize c-variadics at some point in the future.
102
-
### Warn on unions crossing the secure boundary
102
+
### Warn on partially uninitialized values crossing the secure boundary
103
103
104
-
Unions can contain uninitialized memory, and this uninitialized memory can contain stale secure information. Clang warns when union values cross the security boundary (see https://godbolt.org/z/vq9xnrnEs), and rust does the same.
104
+
Unions and types with padding or niches can contain uninitialized memory, and this uninitialized memory can contain stale secure information. Clang warns when union values cross the security boundary (see https://godbolt.org/z/vq9xnrnEs), and rust does the same.
105
105
106
106
```
107
-
warning: passing a union across the security boundary may leak information
107
+
warning: passing a (partially) uninitialized value across the secure boundary may leak information
= note: the bytes not used by the current variant may contain stale secure data
114
114
```
115
115
116
-
Like clang, the lint is emitted at the use site. That means that in the case where passing such a value is deliberate, each use site can be annotated with `#[allow(cmse_uninitialized_leak)]`.
116
+
Like clang, the lint is emitted at the use site. That means that in the case where passing such a value is deliberate, each use site can be annotated with `#[allow(cmse_uninitialized_leak)]`. In most cases this lint should be considered an error, and an alternative way of returning/passing the value should be found that does not run the risk of leaking secure information.
117
117
118
-
A `cmse-nonsecure-call` function call will emit a warning when any of its arguments is or contains a union, and a `cmse-nonsecure-entry` function warns at any (implicit) return when the return type is or contains a union.
118
+
The lint is implemented in https://github.com/rust-lang/rust/pull/147697, and checks whether transmuting a type `T` to `[u8; size_of::<T>]` is valid. The transmute is only valid when all bytes of `T` are guaranteed to be initialized.
119
119
120
-
There are other types that may contain uninitialized memory, for instance in padding bytes or in niches. Currently passing such types does not emit a warning because there is no straightforward way in the compiler to check whether a type may be (partially) uninitialized. We are of course free to extend this lint in the future when emitting the lint correctly in more cases becomes feasible.
//~^ WARN passing a (partially) uninitialized value across the security boundary may leak information
132
+
}
133
+
```
134
+
135
+
A `cmse-nonsecure-call` function call will emit a warning when any of its arguments has a partially uninitialized type, and a `cmse-nonsecure-entry` function warns at any (implicit) return when the return type may be partially uninitialized.
121
136
122
137
Ultimately guaranteeing the security properties of the system is up to the programmer, but warning on types with potentially uninitialized memory is a helpful signal that the compiler can provide.
0 commit comments