bounds7.c
up: index
prev: bounds6.c
next: bounds8.c
#include <cheriintrin.h>
#include <stdio.h>
static char *encode(unsigned char password)
{
char *p = NULL;
return cheri_bounds_set(p, password);
}
static void decode(char *msg)
{
size_t password = cheri_length_get(msg);
fprintf(stderr,"Your password was %zu\n", password);
}
int main()
{
char *x = encode(42);
if(x==NULL)
decode(x);
}
Experimental data (what does this mean?)
clang-riscv-O3-bounds-conservative
clang-riscv-O3-bounds-subobject-safe exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability tag fault caused by register cnull.
main () at tests/cheri/bounds7.c:18
18 char *x = encode(42);
#0 main () at tests/cheri/bounds7.c:18
x = <optimized out>
clang-riscv-O0-bounds-conservative
clang-riscv-O0-bounds-references-only
clang-riscv-O0-bounds-subobject-safe
clang-riscv-O0-bounds-aggressive
clang-riscv-O0-bounds-very-aggressive
clang-riscv-O0-bounds-everywhere-unsafe exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability tag fault caused by register ca0.
0x000000000010189a in encode (password=42 '*') at tests/cheri/bounds7.c:7
7 return cheri_bounds_set(p, password);
#0 0x000000000010189a in encode (password=42 '*') at tests/cheri/bounds7.c:7
p = 0x0
#1 0x0000000000101838 in main () at tests/cheri/bounds7.c:18
x = 0x4011316a <rtld_nop_exit> [rxR,0x40103000-0x4012b300] (sentry,capmode) "\202\200]q\206\240\"\270&\260J\250N\240\027W\001"
clang-morello-O3-bounds-conservative
clang-morello-O3-bounds-subobject-safe Your password was 18446744073709551615
gcc-morello-O0
gcc-morello-O3
clang-morello-O0-bounds-conservative
clang-morello-O0-bounds-references-only
clang-morello-O0-bounds-subobject-safe
clang-morello-O0-bounds-aggressive
clang-morello-O0-bounds-very-aggressive
clang-morello-O0-bounds-everywhere-unsafe
cerberus-cheri
cerberus-cheri-no-pnvi
cerberus-cheri-revocation
cerberus-cheri-revocation-no-pnvi
cerberus-cheri-cornucopia
cerberus-cheri-cornucopia-no-pnvi Your password was 42