usercopy.c 837 B

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