Skip to content

Commit 6250920

Browse files
committed
Tweaks including shifing from 'must' to 'will' in caller notes.
1 parent ba8656a commit 6250920

1 file changed

Lines changed: 17 additions & 23 deletions

File tree

src/allocators/caller-guarantees.md

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,24 @@
11
## Guarantees to the allocator consumer
22

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.
55
The rationales for most choices described in this section are explored in
66
greater detail in the section [Recommendation for allocator
77
implementations](allocator-recommendations.md).
88

99
### Allocating memory
1010

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:
1412

1513
* Is valid (i.e., with its tag bit set)
1614
* Is unsealed
1715
* Has bounds that permit access to the full requested memory range of the
1816
allocation
1917
* 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
2220
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
3122

3223
The allocator may:
3324

@@ -36,6 +27,7 @@ The allocator may:
3627
* Provide precise bounds, with the lower bound being the bottom address of
3728
the allocation, and the upper bound being one byte above the top address of
3829
the allocation
30+
* Provide imprecise bounds, inserting padding below or above the allocation
3931
* Pad and/or align allocation such that the returned address is equal to the
4032
lower bound.
4133

@@ -47,9 +39,9 @@ The caller must pass either a `NULL` pointer via a capability argument to
4739
* Is valid (i.e., with its tag bit set)
4840
* Is unsealed
4941
* 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()`
5143

52-
The allocator must not:
44+
In the presence of temporal safety support, the allocator will not:
5345

5446
* Reuse storage associated with the allocation until there are no outstanding
5547
valid capabilities that authorize access to the memory
@@ -62,14 +54,15 @@ The allocator may:
6254
of the allocation after it has been freed
6355
* Revoke capabilities to the storage immediately upon free
6456

65-
If utilizing revocation, the allocator must:
57+
If utilizing revocation, the allocator will:
6658

6759
* Ensure that any outstanding capabilities to the allocation become
68-
non-dereferenceable
60+
non-dereferenceable before the memory can be reallocated
6961

7062
On revocation, the allocator may:
7163

7264
* Clear the tag of revoked capabilities
65+
* Reduce the permissions on the revoked capabilities to deny further use
7366

7467
### Reallocating memory
7568

@@ -78,12 +71,13 @@ The caller must not:
7871
* Pass a capability to `realloc()` that violates any of the requirements for
7972
a call to `free()`.
8073

81-
The allocator must:
74+
The allocator will:
8275

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()`.
8579

86-
The allocator must not:
80+
The allocator will not:
8781

8882
* Return a new pointer from `realloc()` that has an identical address to the
8983
passed argument but differs in its bounds or other metadata.

0 commit comments

Comments
 (0)