Skip to content
This repository was archived by the owner on Mar 7, 2021. It is now read-only.

Commit bcde3a3

Browse files
authored
Merge pull request #153 from fishinabarrel/alex-patch-1
Document the way we use the Rust typesystem to prevent TOCTOU with userspace memory
1 parent 361409e commit bcde3a3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/user_ptr.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ extern "C" {
2424
/// after completing a read, and not expect that multiple reads of the
2525
/// same address will return the same value.
2626
///
27+
/// All APIs enforce the invariant that a given byte of memory from userspace
28+
/// may only be read once. By pretenting double-fetches we avoid TOCTOU
29+
/// vulnerabilities. This is accomplished by taking `self` by value to prevent
30+
/// obtaining multiple readers on a given UserSlicePtr, and the readers only
31+
/// permitting forward reads.
32+
///
2733
/// Constructing a `UserSlicePtr` only checks that the range is in valid
2834
/// userspace memory, and does not depend on the current process (and
2935
/// can safely be constructed inside a kernel thread with no current

0 commit comments

Comments
 (0)