Example: unrep1a.c

up: index
prev: unrep1.c
next: unrep2.c

    #include <stdint.h>
    #include <stdio.h>
    #include "capprint.h"
    
    int main()
    {
        int x=42;
        intptr_t ip = (intptr_t)&x;
        fprintf(stderr,"Before %" PTR_FMT "\n", sptr((void*)ip));
        intptr_t ip1 = ip + 100001; //may become non-representable
        fprintf(stderr,"Intermediate %" PTR_FMT "\n", sptr((void*)ip1));
        ip1 = ip1 - 100000;
        fprintf(stderr,"After %" PTR_FMT "\n", sptr((void*)ip1));
        fprintf(stderr,"Value=%d\n", *((int*)ip1));
    }

Experimental data (what does this mean?)

cerberus-cheri-no-pnvi
cerberus-cheri-revocation-no-pnvi
cerberus-cheri-cornucopia-no-pnvi
 exit codes: compile 0 / execute 1 Undefined {ub: "UB043_indirection_invalid_value", loc: "<14:36--14:48>"}
Before (@disabled, 0xffffe700 [rwRW,0xffffe700-0xffffe704])
Intermediate (@disabled, 0x100016da1 [?-?] (notag))
After (@disabled, 0xffffe701 [?-?] (notag))
 
cerberus-cheri
cerberus-cheri-revocation
cerberus-cheri-cornucopia
 exit codes: compile 0 / execute 1 Undefined {ub: "UB043_indirection_invalid_value", loc: "<14:36--14:48>"}
Before (@83, 0xffffe700 [rwRW,0xffffe700-0xffffe704])
Intermediate (@empty, 0x100016da1 [?-?] (notag))
After (@83, 0xffffe701 [?-?] (notag))
 
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 cs2.
0x0000000000102146 in main () at tests/cheri/unrep1a.c:14
14 fprintf(stderr,"Value=%d\n", *((int*)ip1));
#0 0x0000000000102146 in main () at tests/cheri/unrep1a.c:14
x = <optimized out>
ip = <optimized out>
ip1 = <optimized out>


Before 0x3fffdfff1c [rwRW,0x3fffdfff1c-0x3fffdfff20]
Intermediate 0x3fffe185bd [rwRW,0x3fffe17f1c-0x3fffe17f20] (invalid)
After 0x3fffdfff1d [rwRW,0x3fffdfff1c-0x3fffdfff20] (invalid)
 
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 ca2.
0x0000000000102126 in main () at tests/cheri/unrep1a.c:14
14 fprintf(stderr,"Value=%d\n", *((int*)ip1));
#0 0x0000000000102126 in main () at tests/cheri/unrep1a.c:14
x = 42
ip = -61824678692139721007568759220435157140
ip1 = -61824678692139721007568759220435157139


Before 0x3fffdfff6c [rwRW,0x3fffdfff6c-0x3fffdfff70]
Intermediate 0x3fffe1860d [rwRW,0x3fffe17f6c-0x3fffe17f70] (invalid)
After 0x3fffdfff6d [rwRW,0x3fffdfff6c-0x3fffdfff70] (invalid)
 
clang-riscv-O3-bounds-conservative exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability tag fault caused by register cfp.
0x0000000000102130 in main () at tests/cheri/unrep1a.c:14
14 fprintf(stderr,"Value=%d\n", *((int*)ip1));
#0 0x0000000000102130 in main () at tests/cheri/unrep1a.c:14
x = <optimized out>
ip1 = <optimized out>
ip = <optimized out>


Before 0x3fffdfff1c [rwRW,0x3fffdfff1c-0x3fffdfff20]
Intermediate 0x3fffe185bd [rwRW,0x3fffe17f1c-0x3fffe17f20] (invalid)
After 0x3fffdfff1d [rwRW,0x3fffdfff1c-0x3fffdfff20] (invalid)
 
clang-riscv-O0-bounds-conservative
clang-riscv-O0-bounds-references-only
 exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability tag fault caused by register ca1.
0x00000000001020d2 in main () at tests/cheri/unrep1a.c:14
14 fprintf(stderr,"Value=%d\n", *((int*)ip1));
#0 0x00000000001020d2 in main () at tests/cheri/unrep1a.c:14
x = 42
ip = -61824678692139721007568759220435157140
ip1 = -61824678692139721007568759220435157139


Before 0x3fffdfff6c [rwRW,0x3fffdfff6c-0x3fffdfff70]
Intermediate 0x3fffe1860d [rwRW,0x3fffe17f6c-0x3fffe17f70] (invalid)
After 0x3fffdfff6d [rwRW,0x3fffdfff6c-0x3fffdfff70] (invalid)
 
clang-morello-O3-bounds-subobject-safe exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability tag fault.
0x000000000011117c in main () at tests/cheri/unrep1a.c:14
14 fprintf(stderr,"Value=%d\n", *((int*)ip1));
#0 0x000000000011117c in main () at tests/cheri/unrep1a.c:14
x = 42
ip = 0xfffffff7feec [rwRW,0xfffffff7feec-0xfffffff7fef0]
ip1 = 0xfffffff7feed [rwRW,0xfffffff7feec-0xfffffff7fef0] (invalid)


Before 0xfffffff7feec [rwRW,0xfffffff7feec-0xfffffff7fef0]
Intermediate 0xfffffff9858d [rwRW,0xfffffff8feec-0xfffffff8fef0] (invalid)
After 0xfffffff7feed [rwRW,0xfffffff7feec-0xfffffff7fef0] (invalid)
 
clang-morello-O0-bounds-subobject-safe
clang-morello-O0-bounds-aggressive
clang-morello-O0-bounds-very-aggressive
clang-morello-O0-bounds-everywhere-unsafe
 exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability tag fault.
0x0000000000110fa4 in main () at tests/cheri/unrep1a.c:14
14 fprintf(stderr,"Value=%d\n", *((int*)ip1));
#0 0x0000000000110fa4 in main () at tests/cheri/unrep1a.c:14
x = 42
ip = 0xfffffff7ff5c [rwRW,0xfffffff7ff5c-0xfffffff7ff60]
ip1 = 0xfffffff7ff5d [rwRW,0xfffffff7ff5c-0xfffffff7ff60] (invalid)


Before 0xfffffff7ff5c [rwRW,0xfffffff7ff5c-0xfffffff7ff60]
Intermediate 0xfffffff985fd [rwRW,0xfffffff8ff5c-0xfffffff8ff60] (invalid)
After 0xfffffff7ff5d [rwRW,0xfffffff7ff5c-0xfffffff7ff60] (invalid)
 
clang-morello-O3-bounds-conservative exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability tag fault.
main () at tests/cheri/unrep1a.c:14
14 fprintf(stderr,"Value=%d\n", *((int*)ip1));
#0 main () at tests/cheri/unrep1a.c:14
x = 42
ip = <optimized out>
ip1 = 0xfffffff7ff0d [rwRW,0xfffffff7ff0c-0xfffffff7ff10] (invalid)


Before 0xfffffff7ff0c [rwRW,0xfffffff7ff0c-0xfffffff7ff10]
Intermediate 0xfffffff985ad [rwRW,0xfffffff8ff0c-0xfffffff8ff10] (invalid)
After 0xfffffff7ff0d [rwRW,0xfffffff7ff0c-0xfffffff7ff10] (invalid)
 
clang-morello-O0-bounds-conservative
clang-morello-O0-bounds-references-only
 exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability tag fault.
0x0000000000110f50 in main () at tests/cheri/unrep1a.c:14
14 fprintf(stderr,"Value=%d\n", *((int*)ip1));
#0 0x0000000000110f50 in main () at tests/cheri/unrep1a.c:14
x = 42
ip = 0xfffffff7ff5c [rwRW,0xfffffff7ff5c-0xfffffff7ff60]
ip1 = 0xfffffff7ff5d [rwRW,0xfffffff7ff5c-0xfffffff7ff60] (invalid)


Before 0xfffffff7ff5c [rwRW,0xfffffff7ff5c-0xfffffff7ff60]
Intermediate 0xfffffff985fd [rwRW,0xfffffff8ff5c-0xfffffff8ff60] (invalid)
After 0xfffffff7ff5d [rwRW,0xfffffff7ff5c-0xfffffff7ff60] (invalid)
 
gcc-morello-O3 exit codes: compile 0 / execute 137 Before 0x7fffffdc [rwRW,0x7fffffdc-0x7fffffe0]
Intermediate 0x8001867d [rwRW,0x8000ffdc-0x8000ffe0] (invalid)
After 0x7fffffdd [rwRW,0x7fffffdc-0x7fffffe0]
 
gcc-morello-O0 exit codes: compile 0 / execute 137 Before 0x7fffffbc [rwRW,0x7fffffbc-0x7fffffc0]
Intermediate 0x8001865d [rwRW,0x8000ffbc-0x8000ffc0] (invalid)
After 0x7fffffbd [rwRW,0x7fffffbc-0x7fffffc0] (invalid)