This repository was archived by the owner on Mar 7, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -44,13 +44,19 @@ impl UserSlicePtr {
44
44
/// the actual pages are mapped in the current process with
45
45
/// appropriate permissions. Those checks are handled in the read
46
46
/// and write methods.
47
- pub fn new ( ptr : * mut c_types:: c_void , length : usize ) -> error:: KernelResult < UserSlicePtr > {
47
+ ///
48
+ /// This is `unsafe` because if it is called within `set_fs(KERNEL_DS)` context then
49
+ /// `access_ok` will not do anything. As a result the only place you can safely use this is
50
+ /// with an `__user` pointer that was provided by the kernel.
51
+ pub ( crate ) unsafe fn new (
52
+ ptr : * mut c_types:: c_void ,
53
+ length : usize ,
54
+ ) -> error:: KernelResult < UserSlicePtr > {
48
55
// No current access_ok implementation actually distinguishes
49
56
// between VERIFY_READ and VERIFY_WRITE, so passing VERIFY_WRITE
50
57
// is fine in practice and fails safe if a future implementation
51
58
// bothers.
52
- if unsafe { access_ok_helper ( bindings:: VERIFY_WRITE , ptr, length as c_types:: c_ulong ) } == 0
53
- {
59
+ if access_ok_helper ( bindings:: VERIFY_WRITE , ptr, length as c_types:: c_ulong ) == 0 {
54
60
return Err ( error:: Error :: EFAULT ) ;
55
61
}
56
62
return Ok ( UserSlicePtr ( ptr, length) ) ;
You can’t perform that action at this time.
0 commit comments