forked from CHERIoT-Platform/cheriot-rtos
-
Notifications
You must be signed in to change notification settings - Fork 4
/
cheri.js
99 lines (85 loc) · 2.58 KB
/
cheri.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// FFI Imports
// Each function imported from the host environment needs to be assigned to a
// global like this and identified by a constant that the resolver in the C/C++
// code will understand.
// These constants are defined in the `Exports` enumeration.
/**
* Log function, writes all arguments to the UART.
*/
export const print = vmImport(1);
/*******************************************************************************
* CHERI functions give access to a virtual machine for writing exploits. This
* allows 8 virtual registers to be accessed as source and destination operands
* to any of the registers.
*
* The constants CSP, PCC, and CGP can also be used to access the values in
* these physical registers directly, but only as source operands.
******************************************************************************/
export const CSP = 8
export const CGP = 9
export const PCC = 10
/**
* register_move(destination, source)
*
* Move a value between two registers.
*/
export const register_move = vmImport(2);
/**
* load_capability(destination, source, offset)
*
* Loads a capability from the specified offset to the source capability
* register, into the destination register.
*/
export const load_capability = vmImport(3);
/**
* load_int(source, offset)
*
* Loads and returns an integer from memory, from the specified offset to the
* source register.
*/
export const load_int = vmImport(4);
/**
* store(source, destination, offset)
*
* Stores a capability from a source register to the specified offset relative
* to the destination register.
*/
export const store = vmImport(5);
/**
* get_address(source)
*
* Returns the address for the specified source register (capability).
*/
export const get_address = vmImport(6);
/**
* set_address(source, address)
*
* Sets the address for the specified register (capability).
*/
export const set_address = vmImport(7);
/**
* get_base(source)
*
* Returns the base address for the specified source register (capability).
*/
export const get_base = vmImport(8);
/**
* get_length(source)
*
* Returns the length for the specified source register (capability).
*/
export const get_length = vmImport(9);
/**
* get_permissions(source)
*
* Returns the permissions for the specified source register (capability).
*/
export const get_permissions = vmImport(10);
/**
* check_secret(guess)
*
* Resets the secret and prints the old value. Takes your guess as an argument
* and will report whether you guessed correctly. Use to see if you've managed
* to leak the value.
*/
export const check_secret = vmImport(11);