Skip to content

Commit bf68240

Browse files
committed
Wording changes to mention posix_memalign, NULL, prefer positive properties.
1 parent 352752b commit bf68240

2 files changed

Lines changed: 21 additions & 19 deletions

File tree

src/allocators/allocator-guarantees.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
In addition to implementing the conventational invariants ensuring the
66
mutually exclusive allocation of memory, CHERI-aware implementations of
7-
`malloc()` and `calloc()` must return a capability that has the following
8-
properties:
7+
`malloc()`, `calloc()`, and `posix_memalign()` must either return a capability
8+
holding a `NULL` pointer (on failure), or a capability holding a non-`NULL`
9+
poiner (on success) that is:
910

10-
* Is valid (i.e., with its tag bit set)
11-
* Is unsealed
11+
* Valid (i.e., with its tag bit set)
12+
* Unsealed
1213
* Has bounds that permit access to the full requested range of the allocation
1314
* Has bounds that do not permit access to any other current allocation, nor
1415
to allocator metadata, implementing non-aliasing spatial safety

src/allocators/caller-guarantees.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@ rely on from all CHERI-enabled allocators.
55

66
### Allocating memory
77

8-
Calls to `malloc()` and `calloc()` must return capabilities that:
8+
Calls to `malloc()`, `calloc()`, and `posix_memalign()` must either return a
9+
capability holding a `NULL` pointer (on failure), or a capability holding a
10+
non-`NULL` pointer (on success) that is:
911

10-
* Are valid (i.e., with its tag bit set)
11-
* Are unsealed
12-
* Have bounds that permit access to the full requested memory range of the
12+
* Valid (i.e., with its tag bit set)
13+
* Unsealed
14+
* Has bounds that permit access to the full requested memory range of the
1315
allocation
14-
* Have bounds that do not permit access to any other current allocation, nor
16+
* Has bounds that do not permit access to any other current allocation, nor
1517
to allocator metadata, implementing non-aliasing spatial safety
16-
* Have permissions that allow data load, data store, capability load, and
18+
* Has permissions that allow data load, data store, capability load, and
1719
capability store
18-
* Are sufficiently aligned to allow capability loads and stores at relative
20+
* Is sufficiently aligned to allow capability loads and stores at relative
1921
offset 0 from the returned pointer
2022

2123
The allocator may:
@@ -28,14 +30,13 @@ The allocator may:
2830

2931
### Freeing memory
3032

31-
The caller must not pass as an argument to `free()` a capability that:
33+
The caller must pass either a `NULL` pointer via a capability argument to
34+
`free()`, or a non-`NULL` capability that:
3235

33-
* Is invalid (i.e., without its tag bit set)
34-
* Is sealed
35-
* Has bounds other than those on the original capability returned by
36-
`malloc()`, `calloc()`, or `realloc()`
37-
* Has permissions that differ from those on the original capability returned
38-
by `malloc()`, `calloc()`, or `realloc()`
36+
* Is valid (i.e., with its tag bit set)
37+
* Is unsealed
38+
* Has address, bounds, and permissions identical to those on the original
39+
capability returned by `malloc()`, `calloc()`, or `realloc()`
3940

4041
The allocator must not:
4142

@@ -47,7 +48,7 @@ The allocator may:
4748
* Fill reachable memory within the bounds of the allocation with zeroes after
4849
it has been freed
4950
* On virtual-memory-enabled systems, unmap reachable memory within the bounds
50-
of the allocation after it has been freed.
51+
of the allocation after it has been freed
5152
* Revoke capabilities to the storage immediately upon free
5253

5354
If utilizing revocation, the allocator must:

0 commit comments

Comments
 (0)