Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 
0003 #include <linux/uaccess.h>
0004 #include <linux/kernel.h>
0005 
0006 #ifdef CONFIG_X86_64
0007 bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size)
0008 {
0009     unsigned long vaddr = (unsigned long)unsafe_src;
0010 
0011     /*
0012      * Range covering the highest possible canonical userspace address
0013      * as well as non-canonical address range. For the canonical range
0014      * we also need to include the userspace guard page.
0015      */
0016     return vaddr >= TASK_SIZE_MAX + PAGE_SIZE &&
0017            __is_canonical_address(vaddr, boot_cpu_data.x86_virt_bits);
0018 }
0019 #else
0020 bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size)
0021 {
0022     return (unsigned long)unsafe_src >= TASK_SIZE_MAX;
0023 }
0024 #endif