maccess.c 638 B

12345678910111213141516171819202122232425
  1. /*
  2. * Copyright (C) 2013 Richard Weinberger <richrd@nod.at>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #include <linux/uaccess.h>
  9. #include <linux/kernel.h>
  10. #include <os.h>
  11. long probe_kernel_read(void *dst, const void *src, size_t size)
  12. {
  13. void *psrc = (void *)rounddown((unsigned long)src, PAGE_SIZE);
  14. if ((unsigned long)src < PAGE_SIZE || size <= 0)
  15. return -EFAULT;
  16. if (os_mincore(psrc, size + src - psrc) <= 0)
  17. return -EFAULT;
  18. return __probe_kernel_read(dst, src, size);
  19. }