-
Notifications
You must be signed in to change notification settings - Fork 10
[CHERIoT] Add warning for common array offset patterns that generate out-of-bounds intermediate capabilities. #284
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
base: cheriot
Are you sure you want to change the base?
Conversation
…out-of-bounds intermediate capabilities. These aren't an issue on big CHERI where representable offsets usually extend well beyond bounds, but on CHERIoT our representation limits are quite tight, so this is a common source of bugs.
|
Added a warning for common variants of this in #284 |
|
I expect a lot of false positives from these, which is why I thought they’d make sense as static analysis things: there’s more dataflow and a bit of symbolic execution available to give a bit more precision there. |
FWIW, this warning doesn't trigger on the RTOS or the network-stack demos, but perhaps those are written in a CHERI-amenable style already? Is there something else that would be good to evaluate it on? I agree that a static analyzer check would be more powerful, but I think the value proposition is harder there. I expect fewer people to run |
|
Can you try https://github.com/pq-code-package/mlkem-c-embedded (mlkem and fips202 directories)? That codebase contains things that we know are broken, let's see if it finds the broken things without false positives. |
|
Do you have a build system for this? |
|
Only locally, but you can just point xmake at those files. |
|
|
randombytes.h: #pragma once
#include <stdint.h>
#include <stddef.h>
__BEGIN_DECLS
int randombytes(uint8_t *output, size_t n);
__END_DECLS |
|
Good new: no warnings are triggered on The original diagnosis of this code was wrong: the array in question has |
|
Yup, the original bug was due to |
|
Further diagnosis: The mlkem-c-embedded example actually is fine as written. Unfortunately, the compiler does the -4 before the |
These aren't an issue on big CHERI where representable offsets usually extend well beyond bounds, but on CHERIoT our representation limits are quite tight, so this is a common source of bugs.