Example: modptr2.c

up: index
prev: modptr1a.c
next: modptr2a.c

    #include <stdio.h>
    #include "capprint.h"
    
    int main(void)
    {
        int x;
        int *px = &x;
        fprintf(stderr,"Original %" PTR_FMT "\n", sptr((void*)px));
        unsigned char *p = (unsigned char*) &px;
        {
            fprintf(stderr,"[");
            for(size_t i=0;i<sizeof(void*);i++)
                fprintf(stderr,"%d;",(int)p[i]);
            fprintf(stderr,"]\n");
        }
        p[0] = 42;
        fprintf(stderr,"Modified %" PTR_FMT "\n", sptr((void*)px));
        {
            fprintf(stderr,"[");
            for(size_t i=0;i<sizeof(void*);i++)
                fprintf(stderr,"%d;",(int)p[i]);
            fprintf(stderr,"]\n");
        }
    }

Experimental data (what does this mean?)

cerberus-cheri-no-pnvi
cerberus-cheri-revocation-no-pnvi
cerberus-cheri-cornucopia-no-pnvi
 Original (@disabled, 0xffffe704 [rwRW,0xffffe704-0xffffe708])
[4;231;255;255;0;0;0;0;4;231;8;103;0;0;0;220;]
Modified (@disabled, 0xffffe72a [rwRW,0xffffe704-0xffffe708] (notag))
[42;231;255;255;0;0;0;0;4;231;8;103;0;0;0;220;]
 
cerberus-cheri
cerberus-cheri-revocation
cerberus-cheri-cornucopia
 Original (@87, 0xffffe704 [rwRW,0xffffe704-0xffffe708])
[4;231;255;255;0;0;0;0;4;231;8;103;0;0;0;220;]
Modified (@empty, 0xffffe72a [rwRW,0xffffe704-0xffffe708] (notag))
[42;231;255;255;0;0;0;0;4;231;8;103;0;0;0;220;]
 
clang-riscv-O3-bounds-subobject-safe Original 0x3fffdfff0c [rwRW,0x3fffdfff0c-0x3fffdfff10]
[12;255;223;255;63;0;0;0;8;191;197;7;0;0;125;209;]
Modified 0x3fffdfff2a [rwRW,0x3fffdfff0c-0x3fffdfff10] (invalid)
[42;255;223;255;63;0;0;0;8;191;197;7;0;0;125;209;]
 
clang-riscv-O3-bounds-conservative Original 0x3fffdfff2c [rwRW,0x3fffdfff2c-0x3fffdfff30]
[44;255;223;255;63;0;0;0;40;191;205;7;0;0;125;209;]
Modified 0x3fffdfff2a [rwRW,0x3fffdfff2c-0x3fffdfff30] (invalid)
[42;255;223;255;63;0;0;0;40;191;205;7;0;0;125;209;]
 
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 0x3fffdfff68 [rwRW,0x3fffdfff68-0x3fffdfff6c]
[104;255;223;255;63;0;0;0;108;191;218;7;0;0;125;209;]
Modified 0x3fffdfff2a [rwRW,0x3fffdfff68-0x3fffdfff6c] (invalid)
[42;255;223;255;63;0;0;0;108;191;218;7;0;0;125;209;]
 
clang-morello-O3-bounds-subobject-safe Original 0xfffffff7fedc [rwRW,0xfffffff7fedc-0xfffffff7fee0]
[220;254;247;255;255;255;0;0;220;254;224;126;0;64;93;220;]
Modified 0xfffffff7fe2a [rwRW,0xfffffff7fedc-0xfffffff7fee0] (invalid)
[42;254;247;255;255;255;0;0;220;254;224;126;0;64;93;220;]
 
clang-morello-O3-bounds-conservative Original 0xfffffff7ff1c [rwRW,0xfffffff7ff1c-0xfffffff7ff20]
[28;255;247;255;255;255;0;0;28;255;32;127;0;64;93;220;]
Modified 0xfffffff7ff2a [rwRW,0xfffffff7ff1c-0xfffffff7ff20] (invalid)
[42;255;247;255;255;255;0;0;28;255;32;127;0;64;93;220;]
 
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 0xfffffff7ff58 [rwRW,0xfffffff7ff58-0xfffffff7ff5c]
[88;255;247;255;255;255;0;0;88;255;92;127;0;64;93;220;]
Modified 0xfffffff7ff2a [rwRW,0xfffffff7ff58-0xfffffff7ff5c] (invalid)
[42;255;247;255;255;255;0;0;88;255;92;127;0;64;93;220;]
 
gcc-morello-O3 Original 0x7fffffcc [rwRW,0x7fffffcc-0x7fffffd0]
[204;255;255;127;0;0;0;0;204;255;208;127;0;192;255;223;]
Modified 0x7fffff2a [rwRW,0x7fffffcc-0x7fffffd0] (invalid)
[42;255;255;127;0;0;0;0;204;255;208;127;0;192;255;223;]
 
gcc-morello-O0 Original 0x7fffffbc [rwRW,0x7fffffbc-0x7fffffc0]
[188;255;255;127;0;0;0;0;188;255;192;127;0;192;255;223;]
Modified 0x7fffff2a [rwRW,0x7fffffbc-0x7fffffc0] (invalid)
[42;255;255;127;0;0;0;0;188;255;192;127;0;192;255;223;]