prov2.c
up: index
prev: prov1.c
next: prov2a.c
#include <stdio.h>
#include <string.h>
#include "capprint.h"
int y=2, x=1;
int main()
{
int *p = &y + 1;
int *q = &x ;
fprintf(stderr,"Addresses: p=%" PTR_FMT " q=%" PTR_FMT "\n ", sptr((void*)p), sptr((void*)q));
if(memcmp(&p, &q, sizeof(p)) == 0) {
*p = 11; // does this have undefined behaviour ?
fprintf(stderr,"x=%d y=%d *p=%d *q=%d\n",x,y,*p,*q);
} else
fprintf(stderr,"memcpy(&p,&q) != 0\n");
if(p == q) {
*p = 11; // does this have undefined behaviour ?
fprintf(stderr,"x=%d y=%d *p=%d *q=%d\n",x,y,*p,*q);
} else
fprintf(stderr,"p != q\n");
}
Experimental data (what does this mean?)
cerberus-cheri-no-pnvi
cerberus-cheri-revocation-no-pnvi
cerberus-cheri-cornucopia-no-pnvi Addresses: p=(@disabled, 0xfffff240 [rwRW,0xfffff23c-0xfffff240]) q=(@disabled, 0xfffff238 [rwRW,0xfffff238-0xfffff23c])
memcpy(&p,&q) != 0
p != q
cerberus-cheri
cerberus-cheri-revocation
cerberus-cheri-cornucopia Addresses: p=(@18, 0xfffff240 [rwRW,0xfffff23c-0xfffff240]) q=(@19, 0xfffff238 [rwRW,0xfffff238-0xfffff23c])
memcpy(&p,&q) != 0
p != q
clang-riscv-O3-bounds-subobject-safe exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability bounds fault caused by register cs7.
main () at tests/cheri/prov2.c:19
19 *p = 11; // does this have undefined behaviour ?
#0 main () at tests/cheri/prov2.c:19
p = 0x104464 <x> [rwRW,0x104460-0x104464]
q = 0x104464 <x> [rwRW,0x104464-0x104468]
Addresses: p=0x104464 [rwRW,0x104460-0x104464] q=0x104464 [rwRW,0x104464-0x104468]
memcpy(&p,&q) != 0
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 bounds fault caused by register ca1.
0x00000000001021e8 in main () at tests/cheri/prov2.c:19
19 *p = 11; // does this have undefined behaviour ?
#0 0x00000000001021e8 in main () at tests/cheri/prov2.c:19
p = 0x104484 <x> [rwRW,0x104480-0x104484]
q = 0x104484 <x> [rwRW,0x104484-0x104488]
Addresses: p=0x104484 [rwRW,0x104480-0x104484] q=0x104484 [rwRW,0x104484-0x104488]
memcpy(&p,&q) != 0
clang-riscv-O3-bounds-conservative exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability bounds fault caused by register cs4.
main () at tests/cheri/prov2.c:19
19 *p = 11; // does this have undefined behaviour ?
#0 main () at tests/cheri/prov2.c:19
p = <optimized out>
q = <optimized out>
Addresses: p=0x104484 [rwRW,0x104480-0x104484] q=0x104484 [rwRW,0x104484-0x104488]
memcpy(&p,&q) != 0
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 bounds fault caused by register ca1.
0x00000000001021a0 in main () at tests/cheri/prov2.c:19
19 *p = 11; // does this have undefined behaviour ?
#0 0x00000000001021a0 in main () at tests/cheri/prov2.c:19
p = 0x104434 <x> [rwRW,0x104430-0x104434]
q = 0x104434 <x> [rwRW,0x104434-0x104438]
Addresses: p=0x104434 [rwRW,0x104430-0x104434] q=0x104434 [rwRW,0x104434-0x104438]
memcpy(&p,&q) != 0
clang-morello-O3-bounds-subobject-safe exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability bounds fault.
main () at tests/cheri/prov2.c:19
19 *p = 11; // does this have undefined behaviour ?
#0 main () at tests/cheri/prov2.c:19
q = 0x1315c4 <x> [rwRW,0x1315c4-0x1315c8]
p = 0x1315c4 <x> [rwRW,0x1315c0-0x1315c4]
Addresses: p=0x1315c4 [rwRW,0x1315c0-0x1315c4] q=0x1315c4 [rwRW,0x1315c4-0x1315c8]
memcpy(&p,&q) != 0
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 bounds fault.
0x0000000000111058 in main () at tests/cheri/prov2.c:19
19 *p = 11; // does this have undefined behaviour ?
#0 0x0000000000111058 in main () at tests/cheri/prov2.c:19
p = 0x131494 <x> [rwRW,0x131490-0x131494]
q = 0x131494 <x> [rwRW,0x131494-0x131498]
Addresses: p=0x131494 [rwRW,0x131490-0x131494] q=0x131494 [rwRW,0x131494-0x131498]
memcpy(&p,&q) != 0
clang-morello-O3-bounds-conservative exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability bounds fault.
main () at tests/cheri/prov2.c:19
19 *p = 11; // does this have undefined behaviour ?
#0 main () at tests/cheri/prov2.c:19
p = <optimized out>
q = <optimized out>
Addresses: p=0x131604 [rwRW,0x131600-0x131604] q=0x131604 [rwRW,0x131604-0x131608]
memcpy(&p,&q) != 0
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 bounds fault.
0x0000000000111014 in main () at tests/cheri/prov2.c:19
19 *p = 11; // does this have undefined behaviour ?
#0 0x0000000000111014 in main () at tests/cheri/prov2.c:19
p = 0x131444 <x> [rwRW,0x131440-0x131444]
q = 0x131444 <x> [rwRW,0x131444-0x131448]
Addresses: p=0x131444 [rwRW,0x131440-0x131444] q=0x131444 [rwRW,0x131444-0x131448]
memcpy(&p,&q) != 0
gcc-morello-O3 tests/cheri/prov2.c: In function 'main':
tests/cheri/prov2.c:13:9: warning: array subscript 1 is outside array bounds of 'int[1]' [-Warray-bounds]
13 | *p = 11; // does this have undefined behaviour ?
| ^~
tests/cheri/prov2.c:5:5: note: while referencing 'y'
5 | int y=2, x=1;
| ^
tests/cheri/prov2.c:19:9: warning: array subscript 1 is outside array bounds of 'int[1]' [-Warray-bounds]
19 | *p = 11; // does this have undefined behaviour ?
| ^~
tests/cheri/prov2.c:5:5: note: while referencing 'y'
5 | int y=2, x=1;
| ^
Addresses: p=0x4275d0 [rwRW,0x4275cc-0x4275d0] q=0x4275c8 [rwRW,0x4275c8-0x4275cc]
memcpy(&p,&q) != 0
p != q
gcc-morello-O0 exit codes: compile 0 / execute 137
Addresses: p=0x427bcc [rwRW,0x427bc8-0x427bcc] q=0x427bcc [rwRW,0x427bcc-0x427bd0]
memcpy(&p,&q) != 0