Pull x86 mm updates from Ingo Molnar: "The changes in here are: - text_poke() fixes and an extensive set of executability lockdowns, to (hopefully) eliminate the last residual circumstances under which we are using W|X mappings even temporarily on x86 kernels. This required a broad range of surgery in text patching facilities, module loading, trampoline handling and other bits. - tweak page fault messages to be more informative and more structured. - remove DISCONTIGMEM support on x86-32 and make SPARSEMEM the default. - reduce KASLR granularity on 5-level paging kernels from 512 GB to 1 GB. - misc other changes and updates" * 'x86-mm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (36 commits) x86/mm: Initialize PGD cache during mm initialization x86/alternatives: Add comment about module removal races x86/kprobes: Use vmalloc special flag x86/ftrace: Use vmalloc special flag bpf: Use vmalloc special flag modules: Use vmalloc special flag mm/vmalloc: Add flag for freeing of special permsissions mm/hibernation: Make hibernation handle unmapped pages x86/mm/cpa: Add set_direct_map_*() functions x86/alternatives: Remove the return value of text_poke_*() x86/jump-label: Remove support for custom text poker x86/modules: Avoid breaking W^X while loading modules x86/kprobes: Set instruction page as executable x86/ftrace: Set trampoline pages as executable x86/kgdb: Avoid redundant comparison of patched code x86/alternatives: Use temporary mm for text poking x86/alternatives: Initialize temporary mm for patching fork: Provide a function for copying init_mm uprobes: Initialize uprobes earlier x86/mm: Save debug registers when loading a temporary mm ...
Showing the changes to kernel/trace (1 of 40 files). Show all
Unified · Split
| @@ -14,6 +14,8 @@ · 13 unmodified lines | ||
| 14 | 14 | #include <linux/syscalls.h> |
| 15 | 15 | #include <linux/error-injection.h> |
| 16 | 16 | |
| 17 | +#include <asm/tlb.h> | |
| 18 | + | |
| 17 | 19 | #include "trace_probe.h" |
| 18 | 20 | #include "trace.h" |
| 19 | 21 | |
| @@ -163,6 +165,10 @@ BPF_CALL_3(bpf_probe_write_user, void *, unsafe_ptr, const void *, src, · 143 unmodified lines | ||
| 163 | 165 | * access_ok() should prevent writing to non-user memory, but in |
| 164 | 166 | * some situations (nommu, temporary switch, etc) access_ok() does |
| 165 | 167 | * not provide enough validation, hence the check on KERNEL_DS. |
| 168 | + * | |
| 169 | + * nmi_uaccess_okay() ensures the probe is not run in an interim | |
| 170 | + * state, when the task or mm are switched. This is specifically | |
| 171 | + * required to prevent the use of temporary mm. | |
| 166 | 172 | */ |
| 167 | 173 | |
| 168 | 174 | if (unlikely(in_interrupt() || |
| @@ -170,6 +176,8 @@ BPF_CALL_3(bpf_probe_write_user, void *, unsafe_ptr, const void *, src, · 1 unmodified line | ||
| 170 | 176 | return -EPERM; |
| 171 | 177 | if (unlikely(uaccess_kernel())) |
| 172 | 178 | return -EPERM; |
| 179 | + if (unlikely(!nmi_uaccess_okay())) | |
| 180 | + return -EPERM; | |
| 173 | 181 | if (!access_ok(unsafe_ptr, size)) |
| 174 | 182 | return -EPERM; |
| 175 | 183 | |