Merge misc fixes from Andrew Morton: "8 patches. Subsystems affected by this patch series: proc, selftests, kbuild, and mm (pagecache, kasan, hugetlb)" * emailed patches from Andrew Morton <akpm@linux-foundation.org>: mm/hugetlb: clear compound_nr before freeing gigantic pages kasan: fix object remaining in offline per-cpu quarantine elfcore: fix building with clang initramfs: fix clang build failure kbuild: avoid static_assert for genksyms selftest/fpu: avoid clang warning proc: use untagged_addr() for pagemap_read addresses revert "mm/filemap: add static for function __add_to_page_cache_locked"
Unified · Split
| @@ -1599,11 +1599,15 @@ static ssize_t pagemap_read(struct file *file, char __user *buf, · 1598 unmodified lines | ||
| 1599 | 1599 | |
| 1600 | 1600 | src = *ppos; |
| 1601 | 1601 | svpfn = src / PM_ENTRY_BYTES; |
| 1602 | − start_vaddr = svpfn << PAGE_SHIFT; | |
| 1603 | 1602 | end_vaddr = mm->task_size; |
| 1604 | 1603 | |
| 1605 | 1604 | /* watch out for wraparound */ |
| 1606 | − if (svpfn > mm->task_size >> PAGE_SHIFT) | |
| 1605 | + start_vaddr = end_vaddr; | |
| 1606 | + if (svpfn <= (ULONG_MAX >> PAGE_SHIFT)) | |
| 1607 | + start_vaddr = untagged_addr(svpfn << PAGE_SHIFT); | |
| 1608 | + | |
| 1609 | + /* Ensure the address is inside the task */ | |
| 1610 | + if (start_vaddr > mm->task_size) | |
| 1607 | 1611 | start_vaddr = end_vaddr; |
| 1608 | 1612 | |
| 1609 | 1613 | /* |
| @@ -77,4 +77,9 @@ · 76 unmodified lines | ||
| 77 | 77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr) |
| 78 | 78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg) |
| 79 | 79 | |
| 80 | +#ifdef __GENKSYMS__ | |
| 81 | +/* genksyms gets confused by _Static_assert */ | |
| 82 | +#define _Static_assert(expr, ...) | |
| 83 | +#endif | |
| 84 | + | |
| 80 | 85 | #endif /* _LINUX_BUILD_BUG_H */ |
| @@ -104,6 +104,7 @@ static inline int elf_core_copy_task_fpregs(struct task_struct *t, struct pt_reg · 103 unmodified lines | ||
| 104 | 104 | #endif |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | +#if defined(CONFIG_UM) || defined(CONFIG_IA64) | |
| 107 | 108 | /* |
| 108 | 109 | * These functions parameterize elf_core_dump in fs/binfmt_elf.c to write out |
| 109 | 110 | * extra segments containing the gate DSO contents. Dumping its |
| @@ -118,5 +119,26 @@ elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset); · 8 unmodified lines | ||
| 118 | 119 | extern int |
| 119 | 120 | elf_core_write_extra_data(struct coredump_params *cprm); |
| 120 | 121 | extern size_t elf_core_extra_data_size(void); |
| 122 | +#else | |
| 123 | +static inline Elf_Half elf_core_extra_phdrs(void) | |
| 124 | +{ | |
| 125 | + return 0; | |
| 126 | +} | |
| 127 | + | |
| 128 | +static inline int elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset) | |
| 129 | +{ | |
| 130 | + return 1; | |
| 131 | +} | |
| 132 | + | |
| 133 | +static inline int elf_core_write_extra_data(struct coredump_params *cprm) | |
| 134 | +{ | |
| 135 | + return 1; | |
| 136 | +} | |
| 137 | + | |
| 138 | +static inline size_t elf_core_extra_data_size(void) | |
| 139 | +{ | |
| 140 | + return 0; | |
| 141 | +} | |
| 142 | +#endif | |
| 121 | 143 | |
| 122 | 144 | #endif /* _LINUX_ELFCORE_H */ |
| @@ -535,7 +535,7 @@ extern unsigned long __initramfs_size; · 534 unmodified lines | ||
| 535 | 535 | #include <linux/initrd.h> |
| 536 | 536 | #include <linux/kexec.h> |
| 537 | 537 | |
| 538 | −void __weak free_initrd_mem(unsigned long start, unsigned long end) | |
| 538 | +void __weak __init free_initrd_mem(unsigned long start, unsigned long end) | |
| 539 | 539 | { |
| 540 | 540 | #ifdef CONFIG_ARCH_KEEP_MEMBLOCK |
| 541 | 541 | unsigned long aligned_start = ALIGN_DOWN(start, PAGE_SIZE); |
| @@ -97,7 +97,6 @@ obj-$(CONFIG_TASK_DELAY_ACCT) += delayacct.o · 96 unmodified lines | ||
| 97 | 97 | obj-$(CONFIG_TASKSTATS) += taskstats.o tsacct.o |
| 98 | 98 | obj-$(CONFIG_TRACEPOINTS) += tracepoint.o |
| 99 | 99 | obj-$(CONFIG_LATENCYTOP) += latencytop.o |
| 100 | −obj-$(CONFIG_ELFCORE) += elfcore.o | |
| 101 | 100 | obj-$(CONFIG_FUNCTION_TRACER) += trace/ |
| 102 | 101 | obj-$(CONFIG_TRACING) += trace/ |
| 103 | 102 | obj-$(CONFIG_TRACE_CLOCK) += trace/ |
| @@ -1,26 +0,0 @@ | ||
| 1 | −// SPDX-License-Identifier: GPL-2.0 | |
| 2 | −#include <linux/elf.h> | |
| 3 | −#include <linux/fs.h> | |
| 4 | −#include <linux/mm.h> | |
| 5 | −#include <linux/binfmts.h> | |
| 6 | −#include <linux/elfcore.h> | |
| 7 | − | |
| 8 | −Elf_Half __weak elf_core_extra_phdrs(void) | |
| 9 | −{ | |
| 10 | − return 0; | |
| 11 | −} | |
| 12 | − | |
| 13 | −int __weak elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset) | |
| 14 | −{ | |
| 15 | − return 1; | |
| 16 | −} | |
| 17 | − | |
| 18 | −int __weak elf_core_write_extra_data(struct coredump_params *cprm) | |
| 19 | −{ | |
| 20 | − return 1; | |
| 21 | −} | |
| 22 | − | |
| 23 | −size_t __weak elf_core_extra_data_size(void) | |
| 24 | −{ | |
| 25 | − return 0; | |
| 26 | −} | |
| @@ -107,7 +107,7 @@ obj-$(CONFIG_TEST_FREE_PAGES) += test_free_pages.o · 106 unmodified lines | ||
| 107 | 107 | # off the generation of FPU/SSE* instructions for kernel proper but FPU_FLAGS |
| 108 | 108 | # get appended last to CFLAGS and thus override those previous compiler options. |
| 109 | 109 | # |
| 110 | −FPU_CFLAGS := -mhard-float -msse -msse2 | |
| 110 | +FPU_CFLAGS := -msse -msse2 | |
| 111 | 111 | ifdef CONFIG_CC_IS_GCC |
| 112 | 112 | # Stack alignment mismatch, proceed with caution. |
| 113 | 113 | # GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 |
| @@ -120,6 +120,7 @@ ifdef CONFIG_CC_IS_GCC · 6 unmodified lines | ||
| 120 | 120 | # -mpreferred-stack-boundary=3 is not between 4 and 12 |
| 121 | 121 | # |
| 122 | 122 | # can be triggered. Otherwise gcc doesn't complain. |
| 123 | +FPU_CFLAGS += -mhard-float | |
| 123 | 124 | FPU_CFLAGS += $(call cc-option,-msse -mpreferred-stack-boundary=3,-mpreferred-stack-boundary=4) |
| 124 | 125 | endif |
| 125 | 126 | |
| @@ -827,7 +827,7 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask) · 826 unmodified lines | ||
| 827 | 827 | } |
| 828 | 828 | EXPORT_SYMBOL_GPL(replace_page_cache_page); |
| 829 | 829 | |
| 830 | −static noinline int __add_to_page_cache_locked(struct page *page, | |
| 830 | +noinline int __add_to_page_cache_locked(struct page *page, | |
| 831 | 831 | struct address_space *mapping, |
| 832 | 832 | pgoff_t offset, gfp_t gfp, |
| 833 | 833 | void **shadowp) |
| @@ -1216,6 +1216,7 @@ static void destroy_compound_gigantic_page(struct page *page, · 1215 unmodified lines | ||
| 1216 | 1216 | } |
| 1217 | 1217 | |
| 1218 | 1218 | set_compound_order(page, 0); |
| 1219 | + page[1].compound_nr = 0; | |
| 1219 | 1220 | __ClearPageHead(page); |
| 1220 | 1221 | } |
| 1221 | 1222 | |
| @@ -29,6 +29,7 @@ · 28 unmodified lines | ||
| 29 | 29 | #include <linux/srcu.h> |
| 30 | 30 | #include <linux/string.h> |
| 31 | 31 | #include <linux/types.h> |
| 32 | +#include <linux/cpuhotplug.h> | |
| 32 | 33 | |
| 33 | 34 | #include "../slab.h" |
| 34 | 35 | #include "kasan.h" |
| @@ -43,6 +44,7 @@ struct qlist_head { · 8 unmodified lines | ||
| 43 | 44 | struct qlist_node *head; |
| 44 | 45 | struct qlist_node *tail; |
| 45 | 46 | size_t bytes; |
| 47 | + bool offline; | |
| 46 | 48 | }; |
| 47 | 49 | |
| 48 | 50 | #define QLIST_INIT { NULL, NULL, 0 } |
| @@ -188,6 +190,10 @@ void quarantine_put(struct kasan_free_meta *info, struct kmem_cache *cache) · 139 unmodified lines | ||
| 188 | 190 | local_irq_save(flags); |
| 189 | 191 | |
| 190 | 192 | q = this_cpu_ptr(&cpu_quarantine); |
| 193 | + if (q->offline) { | |
| 194 | + local_irq_restore(flags); | |
| 195 | + return; | |
| 196 | + } | |
| 191 | 197 | qlist_put(q, &info->quarantine_link, cache->size); |
| 192 | 198 | if (unlikely(q->bytes > QUARANTINE_PERCPU_SIZE)) { |
| 193 | 199 | qlist_move_all(q, &temp); |
| @@ -328,3 +334,36 @@ void quarantine_remove_cache(struct kmem_cache *cache) · 134 unmodified lines | ||
| 328 | 334 | |
| 329 | 335 | synchronize_srcu(&remove_cache_srcu); |
| 330 | 336 | } |
| 337 | + | |
| 338 | +static int kasan_cpu_online(unsigned int cpu) | |
| 339 | +{ | |
| 340 | + this_cpu_ptr(&cpu_quarantine)->offline = false; | |
| 341 | + return 0; | |
| 342 | +} | |
| 343 | + | |
| 344 | +static int kasan_cpu_offline(unsigned int cpu) | |
| 345 | +{ | |
| 346 | + struct qlist_head *q; | |
| 347 | + | |
| 348 | + q = this_cpu_ptr(&cpu_quarantine); | |
| 349 | + /* Ensure the ordering between the writing to q->offline and | |
| 350 | + * qlist_free_all. Otherwise, cpu_quarantine may be corrupted | |
| 351 | + * by interrupt. | |
| 352 | + */ | |
| 353 | + WRITE_ONCE(q->offline, true); | |
| 354 | + barrier(); | |
| 355 | + qlist_free_all(q, NULL); | |
| 356 | + return 0; | |
| 357 | +} | |
| 358 | + | |
| 359 | +static int __init kasan_cpu_quarantine_init(void) | |
| 360 | +{ | |
| 361 | + int ret = 0; | |
| 362 | + | |
| 363 | + ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "mm/kasan:online", | |
| 364 | + kasan_cpu_online, kasan_cpu_offline); | |
| 365 | + if (ret < 0) | |
| 366 | + pr_err("kasan cpu quarantine register failed [%d]\n", ret); | |
| 367 | + return ret; | |
| 368 | +} | |
| 369 | +late_initcall(kasan_cpu_quarantine_init); | |