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 {
4444 /// the actual pages are mapped in the current process with
4545 /// appropriate permissions. Those checks are handled in the read
4646 /// 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 > {
4855 // No current access_ok implementation actually distinguishes
4956 // between VERIFY_READ and VERIFY_WRITE, so passing VERIFY_WRITE
5057 // is fine in practice and fails safe if a future implementation
5158 // 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 {
5460 return Err ( error:: Error :: EFAULT ) ;
5561 }
5662 return Ok ( UserSlicePtr ( ptr, length) ) ;
You can’t perform that action at this time.
0 commit comments