usercopy.c 845 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. #include <asm/tlbflush.h>
  9. /*
  10. * We rely on the nested NMI work to allow atomic faults from the NMI path; the
  11. * nested NMI paths are careful to preserve CR2.
  12. */
  13. unsigned long
  14. copy_from_user_nmi(void *to, const void __user *from, unsigned long n)
  15. {
  16. unsigned long ret;
  17. if (__range_not_ok(from, n, TASK_SIZE))
  18. return n;
  19. if (!nmi_uaccess_okay())
  20. return n;
  21. /*
  22. * Even though this function is typically called from NMI/IRQ context
  23. * disable pagefaults so that its behaviour is consistent even when
  24. * called form other contexts.
  25. */
  26. pagefault_disable();
  27. ret = __copy_from_user_inatomic(to, from, n);
  28. pagefault_enable();
  29. return ret;
  30. }
  31. EXPORT_SYMBOL_GPL(copy_from_user_nmi);