Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b3c395ef authored by David Hildenbrand's avatar David Hildenbrand Committed by Ingo Molnar
Browse files

mm/uaccess, mm/fault: Clarify that uaccess may only sleep if pagefaults are enabled



In general, non-atomic variants of user access functions must not sleep
if pagefaults are disabled.

Let's update all relevant comments in uaccess code. This also reflects
the might_sleep() checks in might_fault().

Reviewed-and-tested-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarDavid Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: David.Laight@ACULAB.COM
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: airlied@linux.ie
Cc: akpm@linux-foundation.org
Cc: benh@kernel.crashing.org
Cc: bigeasy@linutronix.de
Cc: borntraeger@de.ibm.com
Cc: daniel.vetter@intel.com
Cc: heiko.carstens@de.ibm.com
Cc: herbert@gondor.apana.org.au
Cc: hocko@suse.cz
Cc: hughd@google.com
Cc: mst@redhat.com
Cc: paulus@samba.org
Cc: ralf@linux-mips.org
Cc: schwidefsky@de.ibm.com
Cc: yang.shi@windriver.com
Link: http://lkml.kernel.org/r/1431359540-32227-4-git-send-email-dahi@linux.vnet.ibm.com


Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 9ec23531
Loading
Loading
Loading
Loading
+8 −4
Original line number Original line Diff line number Diff line
@@ -97,7 +97,8 @@ static inline __kernel_size_t __copy_from_user(void *to,
 * @x:   Value to copy to user space.
 * @x:   Value to copy to user space.
 * @ptr: Destination address, in user space.
 * @ptr: Destination address, in user space.
 *
 *
 * Context: User context only.  This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * This macro copies a single simple value from kernel space to user
 * This macro copies a single simple value from kernel space to user
 * space.  It supports simple types like char and int, but not larger
 * space.  It supports simple types like char and int, but not larger
@@ -116,7 +117,8 @@ static inline __kernel_size_t __copy_from_user(void *to,
 * @x:   Variable to store result.
 * @x:   Variable to store result.
 * @ptr: Source address, in user space.
 * @ptr: Source address, in user space.
 *
 *
 * Context: User context only.  This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * This macro copies a single simple variable from user space to kernel
 * This macro copies a single simple variable from user space to kernel
 * space.  It supports simple types like char and int, but not larger
 * space.  It supports simple types like char and int, but not larger
@@ -136,7 +138,8 @@ static inline __kernel_size_t __copy_from_user(void *to,
 * @x:   Value to copy to user space.
 * @x:   Value to copy to user space.
 * @ptr: Destination address, in user space.
 * @ptr: Destination address, in user space.
 *
 *
 * Context: User context only.  This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * This macro copies a single simple value from kernel space to user
 * This macro copies a single simple value from kernel space to user
 * space.  It supports simple types like char and int, but not larger
 * space.  It supports simple types like char and int, but not larger
@@ -158,7 +161,8 @@ static inline __kernel_size_t __copy_from_user(void *to,
 * @x:   Variable to store result.
 * @x:   Variable to store result.
 * @ptr: Source address, in user space.
 * @ptr: Source address, in user space.
 *
 *
 * Context: User context only.  This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * This macro copies a single simple variable from user space to kernel
 * This macro copies a single simple variable from user space to kernel
 * space.  It supports simple types like char and int, but not larger
 * space.  It supports simple types like char and int, but not larger
+2 −1
Original line number Original line Diff line number Diff line
@@ -36,7 +36,8 @@
 * @addr: User space pointer to start of block to check
 * @addr: User space pointer to start of block to check
 * @size: Size of block to check
 * @size: Size of block to check
 *
 *
 * Context: User context only.  This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * Checks if a pointer to a block of memory in user space is valid.
 * Checks if a pointer to a block of memory in user space is valid.
 *
 *
+20 −10
Original line number Original line Diff line number Diff line
@@ -91,7 +91,8 @@ static inline void set_fs(mm_segment_t s)
 * @addr: User space pointer to start of block to check
 * @addr: User space pointer to start of block to check
 * @size: Size of block to check
 * @size: Size of block to check
 *
 *
 * Context: User context only.  This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * Checks if a pointer to a block of memory in user space is valid.
 * Checks if a pointer to a block of memory in user space is valid.
 *
 *
@@ -155,7 +156,8 @@ extern int fixup_exception(struct pt_regs *regs);
 * @x:   Variable to store result.
 * @x:   Variable to store result.
 * @ptr: Source address, in user space.
 * @ptr: Source address, in user space.
 *
 *
 * Context: User context only.  This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * This macro copies a single simple variable from user space to kernel
 * This macro copies a single simple variable from user space to kernel
 * space.  It supports simple types like char and int, but not larger
 * space.  It supports simple types like char and int, but not larger
@@ -175,7 +177,8 @@ extern int fixup_exception(struct pt_regs *regs);
 * @x:   Value to copy to user space.
 * @x:   Value to copy to user space.
 * @ptr: Destination address, in user space.
 * @ptr: Destination address, in user space.
 *
 *
 * Context: User context only.  This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * This macro copies a single simple value from kernel space to user
 * This macro copies a single simple value from kernel space to user
 * space.  It supports simple types like char and int, but not larger
 * space.  It supports simple types like char and int, but not larger
@@ -194,7 +197,8 @@ extern int fixup_exception(struct pt_regs *regs);
 * @x:   Variable to store result.
 * @x:   Variable to store result.
 * @ptr: Source address, in user space.
 * @ptr: Source address, in user space.
 *
 *
 * Context: User context only.  This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * This macro copies a single simple variable from user space to kernel
 * This macro copies a single simple variable from user space to kernel
 * space.  It supports simple types like char and int, but not larger
 * space.  It supports simple types like char and int, but not larger
@@ -274,7 +278,8 @@ do { \
 * @x:   Value to copy to user space.
 * @x:   Value to copy to user space.
 * @ptr: Destination address, in user space.
 * @ptr: Destination address, in user space.
 *
 *
 * Context: User context only.  This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * This macro copies a single simple value from kernel space to user
 * This macro copies a single simple value from kernel space to user
 * space.  It supports simple types like char and int, but not larger
 * space.  It supports simple types like char and int, but not larger
@@ -568,7 +573,8 @@ unsigned long __generic_copy_from_user(void *, const void __user *, unsigned lon
 * @from: Source address, in kernel space.
 * @from: Source address, in kernel space.
 * @n:    Number of bytes to copy.
 * @n:    Number of bytes to copy.
 *
 *
 * Context: User context only.  This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * Copy data from kernel space to user space.  Caller must check
 * Copy data from kernel space to user space.  Caller must check
 * the specified block with access_ok() before calling this function.
 * the specified block with access_ok() before calling this function.
@@ -588,7 +594,8 @@ unsigned long __generic_copy_from_user(void *, const void __user *, unsigned lon
 * @from: Source address, in kernel space.
 * @from: Source address, in kernel space.
 * @n:    Number of bytes to copy.
 * @n:    Number of bytes to copy.
 *
 *
 * Context: User context only.  This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * Copy data from kernel space to user space.
 * Copy data from kernel space to user space.
 *
 *
@@ -606,7 +613,8 @@ unsigned long __generic_copy_from_user(void *, const void __user *, unsigned lon
 * @from: Source address, in user space.
 * @from: Source address, in user space.
 * @n:    Number of bytes to copy.
 * @n:    Number of bytes to copy.
 *
 *
 * Context: User context only.  This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * Copy data from user space to kernel space.  Caller must check
 * Copy data from user space to kernel space.  Caller must check
 * the specified block with access_ok() before calling this function.
 * the specified block with access_ok() before calling this function.
@@ -626,7 +634,8 @@ unsigned long __generic_copy_from_user(void *, const void __user *, unsigned lon
 * @from: Source address, in user space.
 * @from: Source address, in user space.
 * @n:    Number of bytes to copy.
 * @n:    Number of bytes to copy.
 *
 *
 * Context: User context only.  This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * Copy data from user space to kernel space.
 * Copy data from user space to kernel space.
 *
 *
@@ -677,7 +686,8 @@ unsigned long clear_user(void __user *mem, unsigned long len);
 * strlen_user: - Get the size of a string in user space.
 * strlen_user: - Get the size of a string in user space.
 * @str: The string to measure.
 * @str: The string to measure.
 *
 *
 * Context: User context only.  This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * Get the size of a NUL-terminated string in user space.
 * Get the size of a NUL-terminated string in user space.
 *
 *
+4 −2
Original line number Original line Diff line number Diff line
@@ -178,7 +178,8 @@ extern long __user_bad(void);
 * @x:   Variable to store result.
 * @x:   Variable to store result.
 * @ptr: Source address, in user space.
 * @ptr: Source address, in user space.
 *
 *
 * Context: User context only.  This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * This macro copies a single simple variable from user space to kernel
 * This macro copies a single simple variable from user space to kernel
 * space.  It supports simple types like char and int, but not larger
 * space.  It supports simple types like char and int, but not larger
@@ -290,7 +291,8 @@ extern long __user_bad(void);
 * @x:   Value to copy to user space.
 * @x:   Value to copy to user space.
 * @ptr: Destination address, in user space.
 * @ptr: Destination address, in user space.
 *
 *
 * Context: User context only.  This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * This macro copies a single simple value from kernel space to user
 * This macro copies a single simple value from kernel space to user
 * space.  It supports simple types like char and int, but not larger
 * space.  It supports simple types like char and int, but not larger
+30 −15
Original line number Original line Diff line number Diff line
@@ -103,7 +103,8 @@ extern u64 __ua_limit;
 * @addr: User space pointer to start of block to check
 * @addr: User space pointer to start of block to check
 * @size: Size of block to check
 * @size: Size of block to check
 *
 *
 * Context: User context only.	This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * Checks if a pointer to a block of memory in user space is valid.
 * Checks if a pointer to a block of memory in user space is valid.
 *
 *
@@ -138,7 +139,8 @@ extern u64 __ua_limit;
 * @x:	 Value to copy to user space.
 * @x:	 Value to copy to user space.
 * @ptr: Destination address, in user space.
 * @ptr: Destination address, in user space.
 *
 *
 * Context: User context only.	This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * This macro copies a single simple value from kernel space to user
 * This macro copies a single simple value from kernel space to user
 * space.  It supports simple types like char and int, but not larger
 * space.  It supports simple types like char and int, but not larger
@@ -157,7 +159,8 @@ extern u64 __ua_limit;
 * @x:	 Variable to store result.
 * @x:	 Variable to store result.
 * @ptr: Source address, in user space.
 * @ptr: Source address, in user space.
 *
 *
 * Context: User context only.	This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * This macro copies a single simple variable from user space to kernel
 * This macro copies a single simple variable from user space to kernel
 * space.  It supports simple types like char and int, but not larger
 * space.  It supports simple types like char and int, but not larger
@@ -177,7 +180,8 @@ extern u64 __ua_limit;
 * @x:	 Value to copy to user space.
 * @x:	 Value to copy to user space.
 * @ptr: Destination address, in user space.
 * @ptr: Destination address, in user space.
 *
 *
 * Context: User context only.	This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * This macro copies a single simple value from kernel space to user
 * This macro copies a single simple value from kernel space to user
 * space.  It supports simple types like char and int, but not larger
 * space.  It supports simple types like char and int, but not larger
@@ -199,7 +203,8 @@ extern u64 __ua_limit;
 * @x:	 Variable to store result.
 * @x:	 Variable to store result.
 * @ptr: Source address, in user space.
 * @ptr: Source address, in user space.
 *
 *
 * Context: User context only.	This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * This macro copies a single simple variable from user space to kernel
 * This macro copies a single simple variable from user space to kernel
 * space.  It supports simple types like char and int, but not larger
 * space.  It supports simple types like char and int, but not larger
@@ -498,7 +503,8 @@ extern void __put_user_unknown(void);
 * @x:	 Value to copy to user space.
 * @x:	 Value to copy to user space.
 * @ptr: Destination address, in user space.
 * @ptr: Destination address, in user space.
 *
 *
 * Context: User context only.	This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * This macro copies a single simple value from kernel space to user
 * This macro copies a single simple value from kernel space to user
 * space.  It supports simple types like char and int, but not larger
 * space.  It supports simple types like char and int, but not larger
@@ -517,7 +523,8 @@ extern void __put_user_unknown(void);
 * @x:	 Variable to store result.
 * @x:	 Variable to store result.
 * @ptr: Source address, in user space.
 * @ptr: Source address, in user space.
 *
 *
 * Context: User context only.	This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * This macro copies a single simple variable from user space to kernel
 * This macro copies a single simple variable from user space to kernel
 * space.  It supports simple types like char and int, but not larger
 * space.  It supports simple types like char and int, but not larger
@@ -537,7 +544,8 @@ extern void __put_user_unknown(void);
 * @x:	 Value to copy to user space.
 * @x:	 Value to copy to user space.
 * @ptr: Destination address, in user space.
 * @ptr: Destination address, in user space.
 *
 *
 * Context: User context only.	This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * This macro copies a single simple value from kernel space to user
 * This macro copies a single simple value from kernel space to user
 * space.  It supports simple types like char and int, but not larger
 * space.  It supports simple types like char and int, but not larger
@@ -559,7 +567,8 @@ extern void __put_user_unknown(void);
 * @x:	 Variable to store result.
 * @x:	 Variable to store result.
 * @ptr: Source address, in user space.
 * @ptr: Source address, in user space.
 *
 *
 * Context: User context only.	This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * This macro copies a single simple variable from user space to kernel
 * This macro copies a single simple variable from user space to kernel
 * space.  It supports simple types like char and int, but not larger
 * space.  It supports simple types like char and int, but not larger
@@ -815,7 +824,8 @@ extern size_t __copy_user(void *__to, const void *__from, size_t __n);
 * @from: Source address, in kernel space.
 * @from: Source address, in kernel space.
 * @n:	  Number of bytes to copy.
 * @n:	  Number of bytes to copy.
 *
 *
 * Context: User context only.	This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * Copy data from kernel space to user space.  Caller must check
 * Copy data from kernel space to user space.  Caller must check
 * the specified block with access_ok() before calling this function.
 * the specified block with access_ok() before calling this function.
@@ -888,7 +898,8 @@ extern size_t __copy_user_inatomic(void *__to, const void *__from, size_t __n);
 * @from: Source address, in kernel space.
 * @from: Source address, in kernel space.
 * @n:	  Number of bytes to copy.
 * @n:	  Number of bytes to copy.
 *
 *
 * Context: User context only.	This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * Copy data from kernel space to user space.
 * Copy data from kernel space to user space.
 *
 *
@@ -1075,7 +1086,8 @@ extern size_t __copy_in_user_eva(void *__to, const void *__from, size_t __n);
 * @from: Source address, in user space.
 * @from: Source address, in user space.
 * @n:	  Number of bytes to copy.
 * @n:	  Number of bytes to copy.
 *
 *
 * Context: User context only.	This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * Copy data from user space to kernel space.  Caller must check
 * Copy data from user space to kernel space.  Caller must check
 * the specified block with access_ok() before calling this function.
 * the specified block with access_ok() before calling this function.
@@ -1107,7 +1119,8 @@ extern size_t __copy_in_user_eva(void *__to, const void *__from, size_t __n);
 * @from: Source address, in user space.
 * @from: Source address, in user space.
 * @n:	  Number of bytes to copy.
 * @n:	  Number of bytes to copy.
 *
 *
 * Context: User context only.	This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * Copy data from user space to kernel space.
 * Copy data from user space to kernel space.
 *
 *
@@ -1329,7 +1342,8 @@ strncpy_from_user(char *__to, const char __user *__from, long __len)
 * strlen_user: - Get the size of a string in user space.
 * strlen_user: - Get the size of a string in user space.
 * @str: The string to measure.
 * @str: The string to measure.
 *
 *
 * Context: User context only.	This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * Get the size of a NUL-terminated string in user space.
 * Get the size of a NUL-terminated string in user space.
 *
 *
@@ -1398,7 +1412,8 @@ static inline long __strnlen_user(const char __user *s, long n)
 * strnlen_user: - Get the size of a string in user space.
 * strnlen_user: - Get the size of a string in user space.
 * @str: The string to measure.
 * @str: The string to measure.
 *
 *
 * Context: User context only.	This function may sleep.
 * Context: User context only. This function may sleep if pagefaults are
 *          enabled.
 *
 *
 * Get the size of a NUL-terminated string in user space.
 * Get the size of a NUL-terminated string in user space.
 *
 *
Loading