maccess.c 456 B

12345678910111213141516171819
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (C) 2013 Richard Weinberger <[email protected]>
  4. */
  5. #include <linux/uaccess.h>
  6. #include <linux/kernel.h>
  7. #include <os.h>
  8. bool copy_from_kernel_nofault_allowed(const void *src, size_t size)
  9. {
  10. void *psrc = (void *)rounddown((unsigned long)src, PAGE_SIZE);
  11. if ((unsigned long)src < PAGE_SIZE || size <= 0)
  12. return false;
  13. if (os_mincore(psrc, size + src - psrc) <= 0)
  14. return false;
  15. return true;
  16. }