Merge branch 'work.set_fs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull initial set_fs() removal from Al Viro:
"Christoph's set_fs base series + fixups"
* 'work.set_fs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
fs: Allow a NULL pos pointer to __kernel_read
fs: Allow a NULL pos pointer to __kernel_write
powerpc: remove address space overrides using set_fs()
powerpc: use non-set_fs based maccess routines
x86: remove address space overrides using set_fs()
x86: make TASK_SIZE_MAX usable from assembly code
x86: move PAGE_OFFSET, TASK_SIZE & friends to page_{32,64}_types.h
lkdtm: remove set_fs-based tests
test_bitmap: remove user bitmap tests
uaccess: add infrastructure for kernel builds with set_fs()
fs: don't allow splice read/write without explicit ops
fs: don't allow kernel reads and writes without iter ops
sysctl: Convert to iter interfaces
proc: add a read_iter method to proc proc_ops
proc: cleanup the compat vs no compat file ops
proc: remove a level of indentation in proc_get_inode
This commit is contained in:
@@ -8,62 +8,21 @@
|
||||
#include <asm/extable.h>
|
||||
#include <asm/kup.h>
|
||||
|
||||
/*
|
||||
* The fs value determines whether argument validity checking should be
|
||||
* performed or not. If get_fs() == USER_DS, checking is performed, with
|
||||
* get_fs() == KERNEL_DS, checking is bypassed.
|
||||
*
|
||||
* For historical reasons, these macros are grossly misnamed.
|
||||
*
|
||||
* The fs/ds values are now the highest legal address in the "segment".
|
||||
* This simplifies the checking in the routines below.
|
||||
*/
|
||||
|
||||
#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
|
||||
|
||||
#define KERNEL_DS MAKE_MM_SEG(~0UL)
|
||||
#ifdef __powerpc64__
|
||||
/* We use TASK_SIZE_USER64 as TASK_SIZE is not constant */
|
||||
#define USER_DS MAKE_MM_SEG(TASK_SIZE_USER64 - 1)
|
||||
#define TASK_SIZE_MAX TASK_SIZE_USER64
|
||||
#else
|
||||
#define USER_DS MAKE_MM_SEG(TASK_SIZE - 1)
|
||||
#define TASK_SIZE_MAX TASK_SIZE
|
||||
#endif
|
||||
|
||||
#define get_fs() (current->thread.addr_limit)
|
||||
|
||||
static inline void set_fs(mm_segment_t fs)
|
||||
static inline bool __access_ok(unsigned long addr, unsigned long size)
|
||||
{
|
||||
current->thread.addr_limit = fs;
|
||||
/* On user-mode return check addr_limit (fs) is correct */
|
||||
set_thread_flag(TIF_FSCHECK);
|
||||
return addr < TASK_SIZE_MAX && size <= TASK_SIZE_MAX - addr;
|
||||
}
|
||||
|
||||
#define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg)
|
||||
#define user_addr_max() (get_fs().seg)
|
||||
|
||||
#ifdef __powerpc64__
|
||||
/*
|
||||
* This check is sufficient because there is a large enough
|
||||
* gap between user addresses and the kernel addresses
|
||||
*/
|
||||
#define __access_ok(addr, size, segment) \
|
||||
(((addr) <= (segment).seg) && ((size) <= (segment).seg))
|
||||
|
||||
#else
|
||||
|
||||
static inline int __access_ok(unsigned long addr, unsigned long size,
|
||||
mm_segment_t seg)
|
||||
{
|
||||
if (addr > seg.seg)
|
||||
return 0;
|
||||
return (size == 0 || size - 1 <= seg.seg - addr);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define access_ok(addr, size) \
|
||||
(__chk_user_ptr(addr), \
|
||||
__access_ok((__force unsigned long)(addr), (size), get_fs()))
|
||||
__access_ok((unsigned long)(addr), (size)))
|
||||
|
||||
/*
|
||||
* These are the main single-value transfer routines. They automatically
|
||||
@@ -604,4 +563,20 @@ do { \
|
||||
__put_user_goto(*(u8*)(_src + _i), (u8 __user *)(_dst + _i), e);\
|
||||
} while (0)
|
||||
|
||||
#define HAVE_GET_KERNEL_NOFAULT
|
||||
|
||||
#define __get_kernel_nofault(dst, src, type, err_label) \
|
||||
do { \
|
||||
int __kr_err; \
|
||||
\
|
||||
__get_user_size_allowed(*((type *)(dst)), (__force type __user *)(src),\
|
||||
sizeof(type), __kr_err); \
|
||||
if (unlikely(__kr_err)) \
|
||||
goto err_label; \
|
||||
} while (0)
|
||||
|
||||
#define __put_kernel_nofault(dst, src, type, err_label) \
|
||||
__put_user_size_goto(*((type *)(src)), \
|
||||
(__force type __user *)(dst), sizeof(type), err_label)
|
||||
|
||||
#endif /* _ARCH_POWERPC_UACCESS_H */
|
||||
|
||||
Reference in New Issue
Block a user