Skip to content

Commit b32aed0

Browse files
authored
Update 2025-01-09-capabilities-not-trust-third-party.markdown (#27)
improved formatting and corrected possessive apostrophe usage
1 parent c3e53fa commit b32aed0

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

_posts/2025-01-09-capabilities-not-trust-third-party.markdown

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,20 @@ int __cheri_compartment("MQTT") mqtt_publish(Timeout *t,
2424
```
2525
2626
and has the following comment about their scope:
27-
28-
_Both the topic and payload buffers must remain valid during the execution of this function._
29-
_If the caller frees them during the execution of this function, the publish may leak application data to the broker through the topic and payload._
27+
>```
28+
>Both the topic and payload buffers must remain valid during the execution of this function.
29+
>If the caller frees them during the execution of this function, the publish may leak application data to the broker through the topic and payload.
30+
>```
3031
3132
Ok, so it seems clear that I only need to make sure that they remain valid and unchanged until the call returns, but I was hitting a bug that seemed to suggest they might be being used outside of that by another thread in the network stack.
32-
_It turns out I was wrong about that BTW, but anyway I'm a suspicious kind of guy when it comes to trusting external modules._
33-
A quick look through the code quickly persuaded me that a) I'm not very good at reading other peoples code and b) it was probably not the issue but I still wanted to rule it out.
33+
> _It turns out I was wrong about that BTW, but anyway I'm a suspicious kind of guy when it comes to trusting external modules._
34+
35+
A quick look through the code quickly persuaded me that: a) I'm not very good at reading other people's code; and b) it was probably not the issue but I still wanted to rule it out.
3436
3537
Luckily by thinking of these in terms of capabilities rather than pointers I can directly implement my intent rather that trust what the library is telling me.
3638
Specifically I can derive new capabilities that are read only and can't be captured.
3739
So I can be guaranteed that at the end of the call nothing in the network stack can have modified the message or saved a reference to it.
38-
And for good measure I can also limit the bounds so that I don't have to trust that the MQTT code will only read within topicLength and payloadLength.
40+
And for good measure I can also limit the bounds so that I don't have to trust that the MQTT code will only read within `topicLength` and `payloadLength`.
3941
This is what the resulting code looks like in my demo:
4042
4143
```c++
@@ -87,5 +89,5 @@ Using the following would instead return an invalid capability if `statusLength`
8789

8890

8991
So by explicitly using the extra controls that CHERIoT provides we can eliminate any trust relationship between our code and some third party module and its compilation environment.
90-
The CHERI processor will guarantee that the MQTT library can only use the pointers we supply in the way we intend it to, even if the library is implemented to make use of compiler escape hatches such as "unsafe".
92+
The CHERI processor will guarantee that the MQTT library can only use the pointers we supply in the way we intend it to, even if the library is implemented to make use of compiler escape hatches such as "`unsafe`".
9193
And that's a significant step forwards in creating safe and reliable systems.

0 commit comments

Comments
 (0)