Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Copyright (C) 2013 Richard Weinberger <richrd@nod.at>
0004  */
0005 
0006 #include <linux/uaccess.h>
0007 #include <linux/kernel.h>
0008 #include <os.h>
0009 
0010 bool copy_from_kernel_nofault_allowed(const void *src, size_t size)
0011 {
0012     void *psrc = (void *)rounddown((unsigned long)src, PAGE_SIZE);
0013 
0014     if ((unsigned long)src < PAGE_SIZE || size <= 0)
0015         return false;
0016     if (os_mincore(psrc, size + src - psrc) <= 0)
0017         return false;
0018     return true;
0019 }