Merge branch 'work.uaccess' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull uaccess unification updates from Al Viro: "This is the uaccess unification pile. It's _not_ the end of uaccess work, but the next batch of that will go into the next cycle. This one mostly takes copy_from_user() and friends out of arch/* and gets the zero-padding behaviour in sync for all architectures. Dealing with the nocache/writethrough mess is for the next cycle; fortunately, that's x86-only. Same for cleanups in iov_iter.c (I am sold on access_ok() in there, BTW; just not in this pile), same for reducing __copy_... callsites, strn*... stuff, etc. - there will be a pile about as large as this one in the next merge window. This one sat in -next for weeks. -3KLoC" * 'work.uaccess' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (96 commits) HAVE_ARCH_HARDENED_USERCOPY is unconditional now CONFIG_ARCH_HAS_RAW_COPY_USER is unconditional now m32r: switch to RAW_COPY_USER hexagon: switch to RAW_COPY_USER microblaze: switch to RAW_COPY_USER get rid of padding, switch to RAW_COPY_USER ia64: get rid of copy_in_user() ia64: sanitize __access_ok() ia64: get rid of 'segment' argument of __do_{get,put}_user() ia64: get rid of 'segment' argument of __{get,put}_user_check() ia64: add extable.h powerpc: get rid of zeroing, switch to RAW_COPY_USER esas2r: don't open-code memdup_user() alpha: fix stack smashing in old_adjtimex(2) don't open-code kernel_setsockopt() mips: switch to RAW_COPY_USER mips: get rid of tail-zeroing in primitives mips: make copy_from_user() zero tail explicitly mips: clean and reorder the forest of macros... mips: consolidate __invoke_... wrappers ...
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
#endif
|
||||
|
||||
#define user_addr_max() \
|
||||
(segment_eq(get_fs(), USER_DS) ? TASK_SIZE : ~0UL)
|
||||
(uaccess_kernel() ? ~0UL : TASK_SIZE)
|
||||
|
||||
long strncpy_from_user(char *dest, const char __user *src, long count);
|
||||
|
||||
|
@@ -7,14 +7,8 @@
|
||||
#ifndef _ASM_UACCESS_H
|
||||
#define _ASM_UACCESS_H
|
||||
|
||||
#ifdef __KERNEL__
|
||||
#include <linux/compiler.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/errno.h>
|
||||
#endif
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#include <asm/processor.h>
|
||||
|
||||
@@ -30,9 +24,6 @@
|
||||
#define KERNEL_DS ((mm_segment_t) { 0 })
|
||||
#define USER_DS ((mm_segment_t) { -1 })
|
||||
|
||||
#define VERIFY_READ 0
|
||||
#define VERIFY_WRITE 1
|
||||
|
||||
#define get_ds() (KERNEL_DS)
|
||||
#define get_fs() (current->thread.current_ds)
|
||||
#define set_fs(val) ((current->thread.current_ds) = (val))
|
||||
@@ -45,7 +36,7 @@
|
||||
* large size and address near to PAGE_OFFSET - a fault will break his intentions.
|
||||
*/
|
||||
#define __user_ok(addr, size) ({ (void)(size); (addr) < STACK_TOP; })
|
||||
#define __kernel_ok (segment_eq(get_fs(), KERNEL_DS))
|
||||
#define __kernel_ok (uaccess_kernel())
|
||||
#define __access_ok(addr, size) (__user_ok((addr) & get_fs().seg, (size)))
|
||||
#define access_ok(type, addr, size) \
|
||||
({ (void)(type); __access_ok((unsigned long)(addr), size); })
|
||||
@@ -80,8 +71,6 @@ struct exception_table_entry
|
||||
/* Returns 0 if exception not found and fixup otherwise. */
|
||||
unsigned long search_extables_range(unsigned long addr, unsigned long *g2);
|
||||
|
||||
void __ret_efault(void);
|
||||
|
||||
/* Uh, these should become the main single-value transfer routines..
|
||||
* They automatically use the right size if we just have the right
|
||||
* pointer type..
|
||||
@@ -246,39 +235,18 @@ int __get_user_bad(void);
|
||||
|
||||
unsigned long __copy_user(void __user *to, const void __user *from, unsigned long size);
|
||||
|
||||
static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
|
||||
static inline unsigned long raw_copy_to_user(void __user *to, const void *from, unsigned long n)
|
||||
{
|
||||
if (n && __access_ok((unsigned long) to, n)) {
|
||||
check_object_size(from, n, true);
|
||||
return __copy_user(to, (__force void __user *) from, n);
|
||||
} else
|
||||
return n;
|
||||
}
|
||||
|
||||
static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
|
||||
{
|
||||
check_object_size(from, n, true);
|
||||
return __copy_user(to, (__force void __user *) from, n);
|
||||
}
|
||||
|
||||
static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
|
||||
{
|
||||
if (n && __access_ok((unsigned long) from, n)) {
|
||||
check_object_size(to, n, false);
|
||||
return __copy_user((__force void __user *) to, from, n);
|
||||
} else {
|
||||
memset(to, 0, n);
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
|
||||
static inline unsigned long raw_copy_from_user(void *to, const void __user *from, unsigned long n)
|
||||
{
|
||||
return __copy_user((__force void __user *) to, from, n);
|
||||
}
|
||||
|
||||
#define __copy_to_user_inatomic __copy_to_user
|
||||
#define __copy_from_user_inatomic __copy_from_user
|
||||
#define INLINE_COPY_FROM_USER
|
||||
#define INLINE_COPY_TO_USER
|
||||
|
||||
static inline unsigned long __clear_user(void __user *addr, unsigned long size)
|
||||
{
|
||||
@@ -312,6 +280,4 @@ static inline unsigned long clear_user(void __user *addr, unsigned long n)
|
||||
__must_check long strlen_user(const char __user *str);
|
||||
__must_check long strnlen_user(const char __user *str, long n);
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
#endif /* _ASM_UACCESS_H */
|
||||
|
@@ -5,18 +5,12 @@
|
||||
* User space memory access functions
|
||||
*/
|
||||
|
||||
#ifdef __KERNEL__
|
||||
#include <linux/errno.h>
|
||||
#include <linux/compiler.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/thread_info.h>
|
||||
#include <asm/asi.h>
|
||||
#include <asm/spitfire.h>
|
||||
#include <asm-generic/uaccess-unaligned.h>
|
||||
#include <asm/extable_64.h>
|
||||
#endif
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#include <asm/processor.h>
|
||||
|
||||
@@ -36,9 +30,6 @@
|
||||
#define KERNEL_DS ((mm_segment_t) { ASI_P })
|
||||
#define USER_DS ((mm_segment_t) { ASI_AIUS }) /* har har har */
|
||||
|
||||
#define VERIFY_READ 0
|
||||
#define VERIFY_WRITE 1
|
||||
|
||||
#define get_fs() ((mm_segment_t){(current_thread_info()->current_ds)})
|
||||
#define get_ds() (KERNEL_DS)
|
||||
|
||||
@@ -185,39 +176,19 @@ __asm__ __volatile__( \
|
||||
|
||||
int __get_user_bad(void);
|
||||
|
||||
unsigned long __must_check ___copy_from_user(void *to,
|
||||
unsigned long __must_check raw_copy_from_user(void *to,
|
||||
const void __user *from,
|
||||
unsigned long size);
|
||||
static inline unsigned long __must_check
|
||||
copy_from_user(void *to, const void __user *from, unsigned long size)
|
||||
{
|
||||
check_object_size(to, size, false);
|
||||
|
||||
return ___copy_from_user(to, from, size);
|
||||
}
|
||||
#define __copy_from_user copy_from_user
|
||||
|
||||
unsigned long __must_check ___copy_to_user(void __user *to,
|
||||
unsigned long __must_check raw_copy_to_user(void __user *to,
|
||||
const void *from,
|
||||
unsigned long size);
|
||||
static inline unsigned long __must_check
|
||||
copy_to_user(void __user *to, const void *from, unsigned long size)
|
||||
{
|
||||
check_object_size(from, size, true);
|
||||
#define INLINE_COPY_FROM_USER
|
||||
#define INLINE_COPY_TO_USER
|
||||
|
||||
return ___copy_to_user(to, from, size);
|
||||
}
|
||||
#define __copy_to_user copy_to_user
|
||||
|
||||
unsigned long __must_check ___copy_in_user(void __user *to,
|
||||
unsigned long __must_check raw_copy_in_user(void __user *to,
|
||||
const void __user *from,
|
||||
unsigned long size);
|
||||
static inline unsigned long __must_check
|
||||
copy_in_user(void __user *to, void __user *from, unsigned long size)
|
||||
{
|
||||
return ___copy_in_user(to, from, size);
|
||||
}
|
||||
#define __copy_in_user copy_in_user
|
||||
|
||||
unsigned long __must_check __clear_user(void __user *, unsigned long);
|
||||
|
||||
@@ -226,14 +197,9 @@ unsigned long __must_check __clear_user(void __user *, unsigned long);
|
||||
__must_check long strlen_user(const char __user *str);
|
||||
__must_check long strnlen_user(const char __user *str, long n);
|
||||
|
||||
#define __copy_to_user_inatomic __copy_to_user
|
||||
#define __copy_from_user_inatomic __copy_from_user
|
||||
|
||||
struct pt_regs;
|
||||
unsigned long compute_effective_address(struct pt_regs *,
|
||||
unsigned int insn,
|
||||
unsigned int rd);
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
#endif /* _ASM_UACCESS_H */
|
||||
|
Reference in New Issue
Block a user