Example: bounds2a.c

up: index
prev: bounds2.c
next: bounds3.c

    #include <stdio.h>
    #include <stdint.h>
    #include "capprint.h"
    
    int main()
    {
        int x=42;
        int *p = &x;
        
        fprintf(stderr,"Original: %" PTR_FMT "\n", sptr((void*)p));
        intptr_t ip = (intptr_t)p;
        
        ip=ip+100;
        p = (int*)ip;
        fprintf(stderr,"OOB: %" PTR_FMT "\n", sptr((void*)p));
        
        ip=ip-100;
        p = (int*)ip;
        fprintf(stderr,"Recovered: %" PTR_FMT "\n", sptr((void*)p));
        
        fprintf(stderr,"Value: %d\n", *p);
    }

Experimental data (what does this mean?)

cerberus-cheri-no-pnvi
cerberus-cheri-revocation-no-pnvi
cerberus-cheri-cornucopia-no-pnvi
 Original: (@disabled, 0xffffe700 [rwRW,0xffffe700-0xffffe704])
OOB: (@disabled, 0xffffe764 [rwRW,0xffffe700-0xffffe704])
Recovered: (@disabled, 0xffffe700 [rwRW,0xffffe700-0xffffe704])
Value: 42
 
cerberus-cheri
cerberus-cheri-revocation
cerberus-cheri-cornucopia
 Original: (@83, 0xffffe700 [rwRW,0xffffe700-0xffffe704])
OOB: (@empty, 0xffffe764 [rwRW,0xffffe700-0xffffe704])
Recovered: (@83, 0xffffe700 [rwRW,0xffffe700-0xffffe704])
Value: 42
 
clang-riscv-O3-bounds-subobject-safe Original: 0x3fffdfff1c [rwRW,0x3fffdfff1c-0x3fffdfff20]
OOB: 0x3fffdfff80 [rwRW,0x3fffdfff1c-0x3fffdfff20]
Recovered: 0x3fffdfff1c [rwRW,0x3fffdfff1c-0x3fffdfff20]
Value: 42
 
clang-riscv-O3-bounds-conservative Original: 0x3fffdfff0c [rwRW,0x3fffdfff0c-0x3fffdfff10]
OOB: 0x3fffdfff70 [rwRW,0x3fffdfff0c-0x3fffdfff10]
Recovered: 0x3fffdfff0c [rwRW,0x3fffdfff0c-0x3fffdfff10]
Value: 42
 
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
 Original: 0x3fffdfff6c [rwRW,0x3fffdfff6c-0x3fffdfff70]
OOB: 0x3fffdfffd0 [rwRW,0x3fffdfff6c-0x3fffdfff70]
Recovered: 0x3fffdfff6c [rwRW,0x3fffdfff6c-0x3fffdfff70]
Value: 42
 
clang-morello-O3-bounds-subobject-safe Original: 0xfffffff7feec [rwRW,0xfffffff7feec-0xfffffff7fef0]
OOB: 0xfffffff7ff50 [rwRW,0xfffffff7feec-0xfffffff7fef0]
Recovered: 0xfffffff7feec [rwRW,0xfffffff7feec-0xfffffff7fef0]
Value: 42
 
clang-morello-O3-bounds-conservative Original: 0xfffffff7ff0c [rwRW,0xfffffff7ff0c-0xfffffff7ff10]
OOB: 0xfffffff7ff70 [rwRW,0xfffffff7ff0c-0xfffffff7ff10]
Recovered: 0xfffffff7ff0c [rwRW,0xfffffff7ff0c-0xfffffff7ff10]
Value: 42
 
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
 Original: 0xfffffff7ff5c [rwRW,0xfffffff7ff5c-0xfffffff7ff60]
OOB: 0xfffffff7ffc0 [rwRW,0xfffffff7ff5c-0xfffffff7ff60]
Recovered: 0xfffffff7ff5c [rwRW,0xfffffff7ff5c-0xfffffff7ff60]
Value: 42
 
gcc-morello-O3 Original: 0x7fffffdc [rwRW,0x7fffffdc-0x7fffffe0]
OOB: 0x80000040 [rwRW,0x7fffffdc-0x7fffffe0]
Recovered: 0x7fffffdc [rwRW,0x7fffffdc-0x7fffffe0]
Value: 42
 
gcc-morello-O0 Original: 0x7fffffbc [rwRW,0x7fffffbc-0x7fffffc0]
OOB: 0x80000020 [rwRW,0x7fffffbc-0x7fffffc0]
Recovered: 0x7fffffbc [rwRW,0x7fffffbc-0x7fffffc0]
Value: 42