2 * User address space access functions.
4 * For licencing details see kernel-base/COPYING
7 #include <linux/highmem.h>
8 #include <linux/export.h>
10 #include <asm/word-at-a-time.h>
11 #include <linux/sched.h>
14 * We rely on the nested NMI work to allow atomic faults from the NMI path; the
15 * nested NMI paths are careful to preserve CR2.
18 copy_from_user_nmi(void *to
, const void __user
*from
, unsigned long n
)
22 if (__range_not_ok(from
, n
, TASK_SIZE
))
26 * Even though this function is typically called from NMI/IRQ context
27 * disable pagefaults so that its behaviour is consistent even when
28 * called form other contexts.
31 ret
= __copy_from_user_inatomic(to
, from
, n
);
36 EXPORT_SYMBOL_GPL(copy_from_user_nmi
);
39 * copy_to_user: - Copy a block of data into user space.
40 * @to: Destination address, in user space.
41 * @from: Source address, in kernel space.
42 * @n: Number of bytes to copy.
44 * Context: User context only. This function may sleep if pagefaults are
47 * Copy data from kernel space to user space.
49 * Returns number of bytes that could not be copied.
50 * On success, this will be zero.
52 unsigned long _copy_to_user(void __user
*to
, const void *from
, unsigned n
)
54 if (access_ok(VERIFY_WRITE
, to
, n
))
55 n
= __copy_to_user(to
, from
, n
);
58 EXPORT_SYMBOL(_copy_to_user
);
61 * copy_from_user: - Copy a block of data from user space.
62 * @to: Destination address, in kernel space.
63 * @from: Source address, in user space.
64 * @n: Number of bytes to copy.
66 * Context: User context only. This function may sleep if pagefaults are
69 * Copy data from user space to kernel space.
71 * Returns number of bytes that could not be copied.
72 * On success, this will be zero.
74 * If some data could not be copied, this function will pad the copied
75 * data to the requested size using zero bytes.
77 unsigned long _copy_from_user(void *to
, const void __user
*from
, unsigned n
)
79 if (access_ok(VERIFY_READ
, from
, n
))
80 n
= __copy_from_user(to
, from
, n
);
85 EXPORT_SYMBOL(_copy_from_user
);