usercopy.c 779 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * User address space access functions.
  3. *
  4. * For licencing details see kernel-base/COPYING
  5. */
  6. #include <linux/uaccess.h>
  7. #include <linux/export.h>
  8. /*
  9. * We rely on the nested NMI work to allow atomic faults from the NMI path; the
  10. * nested NMI paths are careful to preserve CR2.
  11. */
  12. unsigned long
  13. copy_from_user_nmi(void *to, const void __user *from, unsigned long n)
  14. {
  15. unsigned long ret;
  16. if (__range_not_ok(from, n, TASK_SIZE))
  17. return n;
  18. /*
  19. * Even though this function is typically called from NMI/IRQ context
  20. * disable pagefaults so that its behaviour is consistent even when
  21. * called form other contexts.
  22. */
  23. pagefault_disable();
  24. ret = __copy_from_user_inatomic(to, from, n);
  25. pagefault_enable();
  26. return ret;
  27. }
  28. EXPORT_SYMBOL_GPL(copy_from_user_nmi);