diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-06-28 16:55:08 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-06-28 16:55:08 -0400 |
| commit | 21dc2e6c6d552702736ad3603fe9b074654d3932 (patch) | |
| tree | 90f3ef090166756324097493ef05417217791684 /arch/um/include/asm | |
| parent | b779157dd3db6199b50e7ad64678a1ceedbeebcf (diff) | |
| parent | da028d5e5463dabb6ede2f5e3f6cced1283988cc (diff) | |
Merge branch 'for-linus-4.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml
Pull UML updates from Richard Weinberger:
- remove hppfs ("HonePot ProcFS")
- initial support for musl libc
- uaccess cleanup
- random cleanups and bug fixes all over the place
* 'for-linus-4.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml: (21 commits)
um: Don't pollute kernel namespace with uapi
um: Include sys/types.h for makedev(), major(), minor()
um: Do not use stdin and stdout identifiers for struct members
um: Do not use __ptr_t type for stack_t's .ss pointer
um: Fix mconsole dependency
um: Handle tracehook_report_syscall_entry() result
um: Remove copy&paste code from init.h
um: Stop abusing __KERNEL__
um: Catch unprotected user memory access
um: Fix warning in setup_signal_stack_si()
um: Rework uaccess code
um: Add uaccess.h to ldt.c
um: Add uaccess.h to syscalls_64.c
um: Add asm/elf.h to vma.c
um: Cleanup mem_32/64.c headers
um: Remove hppfs
um: Move syscall() declaration into os.h
um: kernel: ksyms: Export symbol syscall() for fixing modpost issue
um/os-Linux: Use char[] for syscall_stub declarations
um: Use char[] for linker script address declarations
...
Diffstat (limited to 'arch/um/include/asm')
| -rw-r--r-- | arch/um/include/asm/Kbuild | 1 | ||||
| -rw-r--r-- | arch/um/include/asm/ptrace-generic.h | 3 | ||||
| -rw-r--r-- | arch/um/include/asm/sections.h | 9 | ||||
| -rw-r--r-- | arch/um/include/asm/thread_info.h | 2 | ||||
| -rw-r--r-- | arch/um/include/asm/uaccess.h | 176 |
5 files changed, 36 insertions, 155 deletions
diff --git a/arch/um/include/asm/Kbuild b/arch/um/include/asm/Kbuild index b7df3ae9be51..3d63ff6f583f 100644 --- a/arch/um/include/asm/Kbuild +++ b/arch/um/include/asm/Kbuild | |||
| @@ -21,7 +21,6 @@ generic-y += param.h | |||
| 21 | generic-y += pci.h | 21 | generic-y += pci.h |
| 22 | generic-y += percpu.h | 22 | generic-y += percpu.h |
| 23 | generic-y += preempt.h | 23 | generic-y += preempt.h |
| 24 | generic-y += sections.h | ||
| 25 | generic-y += switch_to.h | 24 | generic-y += switch_to.h |
| 26 | generic-y += topology.h | 25 | generic-y += topology.h |
| 27 | generic-y += trace_clock.h | 26 | generic-y += trace_clock.h |
diff --git a/arch/um/include/asm/ptrace-generic.h b/arch/um/include/asm/ptrace-generic.h index cb9b3c47ca8e..2966adbbdf6c 100644 --- a/arch/um/include/asm/ptrace-generic.h +++ b/arch/um/include/asm/ptrace-generic.h | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | 8 | ||
| 9 | #ifndef __ASSEMBLY__ | 9 | #ifndef __ASSEMBLY__ |
| 10 | 10 | ||
| 11 | #include <asm/ptrace-abi.h> | ||
| 12 | #include <sysdep/ptrace.h> | 11 | #include <sysdep/ptrace.h> |
| 13 | 12 | ||
| 14 | struct pt_regs { | 13 | struct pt_regs { |
| @@ -37,7 +36,7 @@ extern int putreg(struct task_struct *child, int regno, unsigned long value); | |||
| 37 | 36 | ||
| 38 | extern int arch_copy_tls(struct task_struct *new); | 37 | extern int arch_copy_tls(struct task_struct *new); |
| 39 | extern void clear_flushed_tls(struct task_struct *task); | 38 | extern void clear_flushed_tls(struct task_struct *task); |
| 40 | extern void syscall_trace_enter(struct pt_regs *regs); | 39 | extern int syscall_trace_enter(struct pt_regs *regs); |
| 41 | extern void syscall_trace_leave(struct pt_regs *regs); | 40 | extern void syscall_trace_leave(struct pt_regs *regs); |
| 42 | 41 | ||
| 43 | #endif | 42 | #endif |
diff --git a/arch/um/include/asm/sections.h b/arch/um/include/asm/sections.h new file mode 100644 index 000000000000..cafcf684d947 --- /dev/null +++ b/arch/um/include/asm/sections.h | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | #ifndef __UM_SECTIONS_H | ||
| 2 | #define __UM_SECTIONS_H | ||
| 3 | |||
| 4 | #include <asm-generic/sections.h> | ||
| 5 | |||
| 6 | extern char __binary_start[]; | ||
| 7 | extern char __syscall_stub_start[], __syscall_stub_end[]; | ||
| 8 | |||
| 9 | #endif | ||
diff --git a/arch/um/include/asm/thread_info.h b/arch/um/include/asm/thread_info.h index b30c85b141d9..53968aaf76f9 100644 --- a/arch/um/include/asm/thread_info.h +++ b/arch/um/include/asm/thread_info.h | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | #include <asm/types.h> | 11 | #include <asm/types.h> |
| 12 | #include <asm/page.h> | 12 | #include <asm/page.h> |
| 13 | #include <asm/uaccess.h> | 13 | #include <asm/segment.h> |
| 14 | 14 | ||
| 15 | struct thread_info { | 15 | struct thread_info { |
| 16 | struct task_struct *task; /* main task structure */ | 16 | struct task_struct *task; /* main task structure */ |
diff --git a/arch/um/include/asm/uaccess.h b/arch/um/include/asm/uaccess.h index 3f22fbf7ca1d..3705620ca298 100644 --- a/arch/um/include/asm/uaccess.h +++ b/arch/um/include/asm/uaccess.h | |||
| @@ -1,178 +1,52 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | 2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) |
| 3 | * Copyright (C) 2015 Richard Weinberger (richard@nod.at) | ||
| 3 | * Licensed under the GPL | 4 | * Licensed under the GPL |
| 4 | */ | 5 | */ |
| 5 | 6 | ||
| 6 | #ifndef __UM_UACCESS_H | 7 | #ifndef __UM_UACCESS_H |
| 7 | #define __UM_UACCESS_H | 8 | #define __UM_UACCESS_H |
| 8 | 9 | ||
| 9 | /* thread_info has a mm_segment_t in it, so put the definition up here */ | 10 | #include <asm/thread_info.h> |
| 10 | typedef struct { | ||
| 11 | unsigned long seg; | ||
| 12 | } mm_segment_t; | ||
| 13 | |||
| 14 | #include <linux/thread_info.h> | ||
| 15 | #include <linux/errno.h> | ||
| 16 | #include <asm/processor.h> | ||
| 17 | #include <asm/elf.h> | 11 | #include <asm/elf.h> |
| 18 | 12 | ||
| 19 | #define VERIFY_READ 0 | ||
| 20 | #define VERIFY_WRITE 1 | ||
| 21 | |||
| 22 | /* | ||
| 23 | * The fs value determines whether argument validity checking should be | ||
| 24 | * performed or not. If get_fs() == USER_DS, checking is performed, with | ||
| 25 | * get_fs() == KERNEL_DS, checking is bypassed. | ||
| 26 | * | ||
| 27 | * For historical reasons, these macros are grossly misnamed. | ||
| 28 | */ | ||
| 29 | |||
| 30 | #define MAKE_MM_SEG(s) ((mm_segment_t) { (s) }) | ||
| 31 | |||
| 32 | #define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFF) | ||
| 33 | #define USER_DS MAKE_MM_SEG(TASK_SIZE) | ||
| 34 | |||
| 35 | #define get_ds() (KERNEL_DS) | ||
| 36 | #define get_fs() (current_thread_info()->addr_limit) | ||
| 37 | #define set_fs(x) (current_thread_info()->addr_limit = (x)) | ||
| 38 | |||
| 39 | #define segment_eq(a, b) ((a).seg == (b).seg) | ||
| 40 | |||
| 41 | #define __under_task_size(addr, size) \ | 13 | #define __under_task_size(addr, size) \ |
| 42 | (((unsigned long) (addr) < TASK_SIZE) && \ | 14 | (((unsigned long) (addr) < TASK_SIZE) && \ |
| 43 | (((unsigned long) (addr) + (size)) < TASK_SIZE)) | 15 | (((unsigned long) (addr) + (size)) < TASK_SIZE)) |
| 44 | 16 | ||
| 45 | #define __access_ok_vsyscall(type, addr, size) \ | 17 | #define __access_ok_vsyscall(addr, size) \ |
| 46 | ((type == VERIFY_READ) && \ | 18 | (((unsigned long) (addr) >= FIXADDR_USER_START) && \ |
| 47 | ((unsigned long) (addr) >= FIXADDR_USER_START) && \ | ||
| 48 | ((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \ | 19 | ((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \ |
| 49 | ((unsigned long) (addr) + (size) >= (unsigned long)(addr))) | 20 | ((unsigned long) (addr) + (size) >= (unsigned long)(addr))) |
| 50 | 21 | ||
| 51 | #define __addr_range_nowrap(addr, size) \ | 22 | #define __addr_range_nowrap(addr, size) \ |
| 52 | ((unsigned long) (addr) <= ((unsigned long) (addr) + (size))) | 23 | ((unsigned long) (addr) <= ((unsigned long) (addr) + (size))) |
| 53 | 24 | ||
| 54 | #define access_ok(type, addr, size) \ | 25 | extern long __copy_from_user(void *to, const void __user *from, unsigned long n); |
| 55 | (__addr_range_nowrap(addr, size) && \ | 26 | extern long __copy_to_user(void __user *to, const void *from, unsigned long n); |
| 56 | (__under_task_size(addr, size) || \ | 27 | extern long __strncpy_from_user(char *dst, const char __user *src, long count); |
| 57 | __access_ok_vsyscall(type, addr, size) || \ | 28 | extern long __strnlen_user(const void __user *str, long len); |
| 58 | segment_eq(get_fs(), KERNEL_DS))) | 29 | extern unsigned long __clear_user(void __user *mem, unsigned long len); |
| 59 | 30 | static inline int __access_ok(unsigned long addr, unsigned long size); | |
| 60 | extern int copy_from_user(void *to, const void __user *from, int n); | 31 | |
| 61 | extern int copy_to_user(void __user *to, const void *from, int n); | 32 | /* Teach asm-generic/uaccess.h that we have C functions for these. */ |
| 62 | 33 | #define __access_ok __access_ok | |
| 63 | /* | 34 | #define __clear_user __clear_user |
| 64 | * strncpy_from_user: - Copy a NUL terminated string from userspace. | 35 | #define __copy_to_user __copy_to_user |
| 65 | * @dst: Destination address, in kernel space. This buffer must be at | 36 | #define __copy_from_user __copy_from_user |
| 66 | * least @count bytes long. | 37 | #define __strnlen_user __strnlen_user |
| 67 | * @src: Source address, in user space. | 38 | #define __strncpy_from_user __strncpy_from_user |
| 68 | * @count: Maximum number of bytes to copy, including the trailing NUL. | ||
| 69 | * | ||
| 70 | * Copies a NUL-terminated string from userspace to kernel space. | ||
| 71 | * | ||
| 72 | * On success, returns the length of the string (not including the trailing | ||
| 73 | * NUL). | ||
| 74 | * | ||
| 75 | * If access to userspace fails, returns -EFAULT (some data may have been | ||
| 76 | * copied). | ||
| 77 | * | ||
| 78 | * If @count is smaller than the length of the string, copies @count bytes | ||
| 79 | * and returns @count. | ||
| 80 | */ | ||
| 81 | |||
| 82 | extern int strncpy_from_user(char *dst, const char __user *src, int count); | ||
| 83 | |||
| 84 | /* | ||
| 85 | * __clear_user: - Zero a block of memory in user space, with less checking. | ||
| 86 | * @to: Destination address, in user space. | ||
| 87 | * @n: Number of bytes to zero. | ||
| 88 | * | ||
| 89 | * Zero a block of memory in user space. Caller must check | ||
| 90 | * the specified block with access_ok() before calling this function. | ||
| 91 | * | ||
| 92 | * Returns number of bytes that could not be cleared. | ||
| 93 | * On success, this will be zero. | ||
| 94 | */ | ||
| 95 | extern int __clear_user(void __user *mem, int len); | ||
| 96 | |||
| 97 | /* | ||
| 98 | * clear_user: - Zero a block of memory in user space. | ||
| 99 | * @to: Destination address, in user space. | ||
| 100 | * @n: Number of bytes to zero. | ||
| 101 | * | ||
| 102 | * Zero a block of memory in user space. | ||
| 103 | * | ||
| 104 | * Returns number of bytes that could not be cleared. | ||
| 105 | * On success, this will be zero. | ||
| 106 | */ | ||
| 107 | extern int clear_user(void __user *mem, int len); | ||
| 108 | |||
| 109 | /* | ||
| 110 | * strlen_user: - Get the size of a string in user space. | ||
| 111 | * @str: The string to measure. | ||
| 112 | * @n: The maximum valid length | ||
| 113 | * | ||
| 114 | * Get the size of a NUL-terminated string in user space. | ||
| 115 | * | ||
| 116 | * Returns the size of the string INCLUDING the terminating NUL. | ||
| 117 | * On exception, returns 0. | ||
| 118 | * If the string is too long, returns a value greater than @n. | ||
| 119 | */ | ||
| 120 | extern int strnlen_user(const void __user *str, int len); | ||
| 121 | |||
| 122 | #define __copy_from_user(to, from, n) copy_from_user(to, from, n) | ||
| 123 | |||
| 124 | #define __copy_to_user(to, from, n) copy_to_user(to, from, n) | ||
| 125 | |||
| 126 | #define __copy_to_user_inatomic __copy_to_user | 39 | #define __copy_to_user_inatomic __copy_to_user |
| 127 | #define __copy_from_user_inatomic __copy_from_user | 40 | #define __copy_from_user_inatomic __copy_from_user |
| 128 | 41 | ||
| 129 | #define __get_user(x, ptr) \ | 42 | #include <asm-generic/uaccess.h> |
| 130 | ({ \ | ||
| 131 | const __typeof__(*(ptr)) __user *__private_ptr = (ptr); \ | ||
| 132 | __typeof__(x) __private_val; \ | ||
| 133 | int __private_ret = -EFAULT; \ | ||
| 134 | (x) = (__typeof__(*(__private_ptr)))0; \ | ||
| 135 | if (__copy_from_user((__force void *)&__private_val, (__private_ptr),\ | ||
| 136 | sizeof(*(__private_ptr))) == 0) { \ | ||
| 137 | (x) = (__typeof__(*(__private_ptr))) __private_val; \ | ||
| 138 | __private_ret = 0; \ | ||
| 139 | } \ | ||
| 140 | __private_ret; \ | ||
| 141 | }) | ||
| 142 | |||
| 143 | #define get_user(x, ptr) \ | ||
| 144 | ({ \ | ||
| 145 | const __typeof__((*(ptr))) __user *private_ptr = (ptr); \ | ||
| 146 | (access_ok(VERIFY_READ, private_ptr, sizeof(*private_ptr)) ? \ | ||
| 147 | __get_user(x, private_ptr) : ((x) = (__typeof__(*ptr))0, -EFAULT)); \ | ||
| 148 | }) | ||
| 149 | |||
| 150 | #define __put_user(x, ptr) \ | ||
| 151 | ({ \ | ||
| 152 | __typeof__(*(ptr)) __user *__private_ptr = ptr; \ | ||
| 153 | __typeof__(*(__private_ptr)) __private_val; \ | ||
| 154 | int __private_ret = -EFAULT; \ | ||
| 155 | __private_val = (__typeof__(*(__private_ptr))) (x); \ | ||
| 156 | if (__copy_to_user((__private_ptr), &__private_val, \ | ||
| 157 | sizeof(*(__private_ptr))) == 0) { \ | ||
| 158 | __private_ret = 0; \ | ||
| 159 | } \ | ||
| 160 | __private_ret; \ | ||
| 161 | }) | ||
| 162 | |||
| 163 | #define put_user(x, ptr) \ | ||
| 164 | ({ \ | ||
| 165 | __typeof__(*(ptr)) __user *private_ptr = (ptr); \ | ||
| 166 | (access_ok(VERIFY_WRITE, private_ptr, sizeof(*private_ptr)) ? \ | ||
| 167 | __put_user(x, private_ptr) : -EFAULT); \ | ||
| 168 | }) | ||
| 169 | |||
| 170 | #define strlen_user(str) strnlen_user(str, ~0U >> 1) | ||
| 171 | 43 | ||
| 172 | struct exception_table_entry | 44 | static inline int __access_ok(unsigned long addr, unsigned long size) |
| 173 | { | 45 | { |
| 174 | unsigned long insn; | 46 | return __addr_range_nowrap(addr, size) && |
| 175 | unsigned long fixup; | 47 | (__under_task_size(addr, size) || |
| 176 | }; | 48 | __access_ok_vsyscall(addr, size) || |
| 49 | segment_eq(get_fs(), KERNEL_DS)); | ||
| 50 | } | ||
| 177 | 51 | ||
| 178 | #endif | 52 | #endif |
