@@ -33,16 +33,16 @@ pub trait Read {
33
33
/// A default instance of an AppSlice must return 0.
34
34
fn len ( & self ) -> usize ;
35
35
36
- /// Pointer to the userspace memory region.
36
+ /// Pointer to the first byte of the userspace memory region.
37
37
///
38
38
/// If the length of the initially shared memory region
39
39
/// (irrespective of the return value of [`len`](Read::len)) is 0,
40
- /// this function must return a pointer to address `0x0`. This is
41
- /// because processes allow buffers with length 0 to reclaim
42
- /// shared memory with the kernel and are allowed to specify _any_
43
- /// address, even if it is not contained within their address
44
- /// space. These _dummy addresses_ should not be leaked to outside
45
- /// code .
40
+ /// this function returns a pointer to address `0x0`. This is
41
+ /// because processes may allow buffers with length 0 to share no
42
+ /// no memory with the kernel. Because these buffers have zero
43
+ /// length, they may have any pointer value. However, these
44
+ /// _dummy addresses_ should not be leaked, so this method returns
45
+ /// 0 for zero-length slices .
46
46
///
47
47
/// # Default AppSlice
48
48
///
@@ -124,6 +124,13 @@ impl ReadWriteAppSlice {
124
124
Self :: new ( ptr, len, process_id)
125
125
}
126
126
127
+ /// Consumes the ReadWriteAppSlice, returning its constituent
128
+ /// pointer and size. This ensures that there cannot simultaneously
129
+ /// be both a `ReadWriteAppSlice` and a pointer to its internal data.
130
+ ///
131
+ /// `consume` can be used when the kernel needs to pass the underlying
132
+ /// values across the kernel-to-user boundary (e.g., in return values to
133
+ /// system calls).
127
134
pub ( crate ) fn consume ( self ) -> ( * mut u8 , usize ) {
128
135
( self . ptr , self . len )
129
136
}
@@ -234,6 +241,13 @@ impl ReadOnlyAppSlice {
234
241
Self :: new ( ptr, len, process_id)
235
242
}
236
243
244
+ /// Consumes the ReadOnlyAppSlice, returning its constituent
245
+ /// pointer and size. This ensures that there cannot simultaneously
246
+ /// be both a `ReadOnlyAppSlice` and a pointer to its internal data.
247
+ ///
248
+ /// `consume` can be used when the kernel needs to pass the underlying
249
+ /// values across the kernel-to-user boundary (e.g., in return values to
250
+ /// system calls).
237
251
pub ( crate ) fn consume ( self ) -> ( * const u8 , usize ) {
238
252
( self . ptr , self . len )
239
253
}
0 commit comments