You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/allocators/caller-guarantees.md
+17-23Lines changed: 17 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,33 +1,24 @@
1
1
## Guarantees to the allocator consumer
2
2
3
-
This section describes properties that consumers of memory allocators may
4
-
rely on from all CHERI-enabled allocators.
3
+
This section describes properties that consumers of heap allocators may
4
+
rely on from CHERI-enabled allocators in the CHERI C/C++ programming environment.
5
5
The rationales for most choices described in this section are explored in
6
6
greater detail in the section [Recommendation for allocator
7
7
implementations](allocator-recommendations.md).
8
8
9
9
### Allocating memory
10
10
11
-
Calls to `malloc()`, `calloc()`, and `posix_memalign()` must either return a
12
-
capability holding a `NULL` pointer (on failure), or a capability holding a
13
-
non-`NULL` pointer (on success) that:
11
+
Calls to `malloc()`, `calloc()`, and `posix_memalign()` will return either a capability holding a `NULL` pointer (on failure) or a capability holding a non-`NULL` pointer (on success) that:
14
12
15
13
* Is valid (i.e., with its tag bit set)
16
14
* Is unsealed
17
15
* Has bounds that permit access to the full requested memory range of the
18
16
allocation
19
17
* Has bounds that do not permit access to any other current allocation, nor
20
-
to allocator metadata, implementing non-aliasing spatial safety
21
-
* Has permissions that allow data load, data store, capability load, and
18
+
to allocator metadata (implementing non-aliasing spatial safety)
19
+
* Has permissions that allow at least data load, data store, capability load, and
22
20
capability store
23
-
* Sufficiently aligned to allow capability loads and stores at relative
24
-
offset 0 from the returned pointer, if the allocation is at least the size
25
-
of a capability
26
-
27
-
The allocator must:
28
-
29
-
* Pad below and above allocations such that, when precise bounds are not
30
-
utilized, no other allocation is accessible within returned bounds.
21
+
* In the case of an allocation that is at least the size of a pointer, has an address that is sufficiently aligned to allow capability loads and stores at suitable relative alignment
31
22
32
23
The allocator may:
33
24
@@ -36,6 +27,7 @@ The allocator may:
36
27
* Provide precise bounds, with the lower bound being the bottom address of
37
28
the allocation, and the upper bound being one byte above the top address of
38
29
the allocation
30
+
* Provide imprecise bounds, inserting padding below or above the allocation
39
31
* Pad and/or align allocation such that the returned address is equal to the
40
32
lower bound.
41
33
@@ -47,9 +39,9 @@ The caller must pass either a `NULL` pointer via a capability argument to
47
39
* Is valid (i.e., with its tag bit set)
48
40
* Is unsealed
49
41
* Has address, bounds, and permissions identical to those on the original
50
-
capability returned by `malloc()`, `calloc()`, or `realloc()`
42
+
capability returned by `malloc()`, `calloc()`, `posix_memalign()`, or `realloc()`
51
43
52
-
The allocator must not:
44
+
In the presence of temporal safety support, the allocator will not:
53
45
54
46
* Reuse storage associated with the allocation until there are no outstanding
55
47
valid capabilities that authorize access to the memory
@@ -62,14 +54,15 @@ The allocator may:
62
54
of the allocation after it has been freed
63
55
* Revoke capabilities to the storage immediately upon free
64
56
65
-
If utilizing revocation, the allocator must:
57
+
If utilizing revocation, the allocator will:
66
58
67
59
* Ensure that any outstanding capabilities to the allocation become
68
-
non-dereferenceable
60
+
non-dereferenceable before the memory can be reallocated
69
61
70
62
On revocation, the allocator may:
71
63
72
64
* Clear the tag of revoked capabilities
65
+
* Reduce the permissions on the revoked capabilities to deny further use
73
66
74
67
### Reallocating memory
75
68
@@ -78,12 +71,13 @@ The caller must not:
78
71
* Pass a capability to `realloc()` that violates any of the requirements for
79
72
a call to `free()`.
80
73
81
-
The allocator must:
74
+
The allocator will:
82
75
83
-
* Conform to the guarantees associated with calls to `malloc()` and
84
-
`calloc()` when allocating memory in `realloc()`.
76
+
* Conform to the guarantees associated with calls to `malloc()`,
77
+
`calloc()`, and `posix_memalign(), when allocating memory in
78
+
`realloc()`.
85
79
86
-
The allocator must not:
80
+
The allocator will not:
87
81
88
82
* Return a new pointer from `realloc()` that has an identical address to the
89
83
passed argument but differs in its bounds or other metadata.
0 commit comments