intptr12.c
up: index
prev: intptr11a.c
next: modptr1.c
#include <stdio.h>
#include "capprint.h"
void real_f(int x)
{
fprintf(stderr,"real_f(%d)\n", x);
}
int main()
{
void (*f)(int) = &real_f;
fprintf(stderr,"Original: %" PTR_FMT "\n", sptr((void*)f));
unsigned long long a = (unsigned long long) f;
fprintf(stderr,"Int: %llx\n",a);
f = (void (*)(int))a;
fprintf(stderr,"Modified: %" PTR_FMT "\n", sptr((void*)f));
(*f)(42);
}
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: "UB_CERB003_invalid_function_pointer", loc: "<17:5--17:9>"}
Original: (@disabled, 0x100000386 [rxR,0x100000386-0x100000388] (sentry))
Int: 100000386
Modified: (@disabled, 0x100000386)
cerberus-cheri
cerberus-cheri-revocation
cerberus-cheri-cornucopia exit codes: compile 0 / execute 1
Undefined {ub: "UB_CERB003_invalid_function_pointer", loc: "<17:5--17:9>"}
Original: (@empty, 0x100000386 [rxR,0x100000386-0x100000388] (sentry))
Int: 100000386
Modified: (@empty, 0x100000386)
clang-riscv-O3-bounds-subobject-safe exit codes: compile 0 / execute 1
tests/cheri/intptr12.c:15:9: warning: cast from provenance-free integer type to pointer type will give pointer that can not be dereferenced [-Wcheri-capability-misuse]
f = (void (*)(int))a;
^
1 warning generated.
Program received signal SIGPROT, CHERI protection violation.
Capability tag fault caused by register cs2.
0x000000000010215a in main () at tests/cheri/intptr12.c:17
17 (*f)(42);
#0 0x000000000010215a in main () at tests/cheri/intptr12.c:17
f = 0x10202c <real_f>
a = <optimized out>
Original: 0x10202c [rxR,0x100000-0x104540] (sentry,capmode)
Int: 10202c
Modified: 0x10202c
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
tests/cheri/intptr12.c:15:9: warning: cast from provenance-free integer type to pointer type will give pointer that can not be dereferenced [-Wcheri-capability-misuse]
f = (void (*)(int))a;
^
1 warning generated.
Program received signal SIGPROT, CHERI protection violation.
Capability tag fault caused by register ca1.
0x0000000000102150 in main () at tests/cheri/intptr12.c:17
17 (*f)(42);
#0 0x0000000000102150 in main () at tests/cheri/intptr12.c:17
f = 0x102012 <real_f>
a = 1056786
Original: 0x102012 [rxR,0x100000-0x104520] (sentry,capmode)
Int: 102012
Modified: 0x102012
clang-riscv-O3-bounds-conservative exit codes: compile 0 / execute 1
tests/cheri/intptr12.c:15:9: warning: cast from provenance-free integer type to pointer type will give pointer that can not be dereferenced [-Wcheri-capability-misuse]
f = (void (*)(int))a;
^
1 warning generated.
Program received signal SIGPROT, CHERI protection violation.
Capability tag fault caused by register cs3.
0x0000000000102156 in main () at tests/cheri/intptr12.c:17
17 (*f)(42);
#0 0x0000000000102156 in main () at tests/cheri/intptr12.c:17
f = <optimized out>
a = <optimized out>
Original: 0x10204e [rxR,0x100000-0x104560] (sentry,capmode)
Int: 10204e
Modified: 0x10204e
clang-riscv-O0-bounds-conservative
clang-riscv-O0-bounds-references-only exit codes: compile 0 / execute 1
tests/cheri/intptr12.c:15:9: warning: cast from provenance-free integer type to pointer type will give pointer that can not be dereferenced [-Wcheri-capability-misuse]
f = (void (*)(int))a;
^
1 warning generated.
Program received signal SIGPROT, CHERI protection violation.
Capability tag fault caused by register ca1.
0x0000000000102110 in main () at tests/cheri/intptr12.c:17
17 (*f)(42);
#0 0x0000000000102110 in main () at tests/cheri/intptr12.c:17
f = 0x101ff2 <real_f>
a = 1056754
Original: 0x101ff2 [rxR,0x100000-0x1044e0] (sentry,capmode)
Int: 101ff2
Modified: 0x101ff2
clang-morello-O3-bounds-subobject-safe exit codes: compile 0 / execute 1
tests/cheri/intptr12.c:15:9: warning: cast from provenance-free integer type to pointer type will give pointer that can not be dereferenced [-Wcheri-capability-misuse]
f = (void (*)(int))a;
^
1 warning generated.
Program received signal SIGPROT, CHERI protection violation.
Capability tag fault.
real_f (x=42) at tests/cheri/intptr12.c:5
5 {
#0 real_f (x=42) at tests/cheri/intptr12.c:5
No locals.
#1 0x00000000001111ac in main () at tests/cheri/intptr12.c:17
f = 0x111041 <real_f>
a = 1118273
Original: 0x111041 [rxR,0x100000-0x131640] (sentry)
Int: 111041
Modified: 0x111041
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
tests/cheri/intptr12.c:15:9: warning: cast from provenance-free integer type to pointer type will give pointer that can not be dereferenced [-Wcheri-capability-misuse]
f = (void (*)(int))a;
^
1 warning generated.
Program received signal SIGPROT, CHERI protection violation.
Capability tag fault.
real_f (x=0) at tests/cheri/intptr12.c:5
5 {
#0 real_f (x=0) at tests/cheri/intptr12.c:5
No locals.
#1 0x0000000000110fcc in main () at tests/cheri/intptr12.c:17
f = 0x110e81 <real_f>
a = 1117825
Original: 0x110e81 [rxR,0x100000-0x131440] (sentry)
Int: 110e81
Modified: 0x110e81
clang-morello-O3-bounds-conservative exit codes: compile 0 / execute 1
tests/cheri/intptr12.c:15:9: warning: cast from provenance-free integer type to pointer type will give pointer that can not be dereferenced [-Wcheri-capability-misuse]
f = (void (*)(int))a;
^
1 warning generated.
Program received signal SIGPROT, CHERI protection violation.
Capability tag fault.
real_f (x=42) at tests/cheri/intptr12.c:5
5 {
#0 real_f (x=42) at tests/cheri/intptr12.c:5
No locals.
#1 0x00000000001111d0 in main () at tests/cheri/intptr12.c:17
f = 0x111091 <real_f>
a = <optimized out>
Original: 0x111091 [rxR,0x100000-0x131680] (sentry)
Int: 111091
Modified: 0x111091
clang-morello-O0-bounds-conservative
clang-morello-O0-bounds-references-only exit codes: compile 0 / execute 1
tests/cheri/intptr12.c:15:9: warning: cast from provenance-free integer type to pointer type will give pointer that can not be dereferenced [-Wcheri-capability-misuse]
f = (void (*)(int))a;
^
1 warning generated.
Program received signal SIGPROT, CHERI protection violation.
Capability tag fault.
real_f (x=0) at tests/cheri/intptr12.c:5
5 {
#0 real_f (x=0) at tests/cheri/intptr12.c:5
No locals.
#1 0x0000000000110f90 in main () at tests/cheri/intptr12.c:17
f = 0x110e61 <real_f>
a = 1117793
Original: 0x110e61 [rxR,0x100000-0x131400] (sentry)
Int: 110e61
Modified: 0x110e61
gcc-morello-O3 exit codes: compile 0 / execute 137
tests/cheri/intptr12.c: In function 'main':
tests/cheri/intptr12.c:12:53: warning: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic]
12 | fprintf(stderr,"Original: %" PTR_FMT "\n", sptr((void*)f));
| ^
tests/cheri/intptr12.c:15:9: warning: cast from provenance-free integer type to pointer type will give pointer that can not be dereferenced [-Wcheri-capability-misuse]
15 | f = (void (*)(int))a;
| ^
tests/cheri/intptr12.c:15:9: note: insert cast to intptr_t to silence this warning
tests/cheri/intptr12.c:16:53: warning: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic]
16 | fprintf(stderr,"Modified: %" PTR_FMT "\n", sptr((void*)f));
| ^
Original: 0x403011 [rxRE,0x400000-0x427280] (sentry)
Int: 403011
Modified: 0x403011
gcc-morello-O0 exit codes: compile 0 / execute 137
tests/cheri/intptr12.c: In function 'main':
tests/cheri/intptr12.c:12:53: warning: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic]
12 | fprintf(stderr,"Original: %" PTR_FMT "\n", sptr((void*)f));
| ^
tests/cheri/intptr12.c:15:9: warning: cast from provenance-free integer type to pointer type will give pointer that can not be dereferenced [-Wcheri-capability-misuse]
15 | f = (void (*)(int))a;
| ^
tests/cheri/intptr12.c:15:9: note: insert cast to intptr_t to silence this warning
tests/cheri/intptr12.c:16:53: warning: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic]
16 | fprintf(stderr,"Modified: %" PTR_FMT "\n", sptr((void*)f));
| ^
Original: 0x403845 [rxRE,0x400000-0x427740] (sentry)
Int: 403845
Modified: 0x403845