History

Merge branch 'akpm' (patches from Andrew)

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"

Linus Torvalds committed 5 years ago

Commit a06caa42 parents 94801e5 ba9c12010 files · +77 −32Browse files

Unified · Split

10 files
  1. fs/proc/task_mmu.c +6 −2
  2. include/linux/build_bug.h +5 −0
  3. include/linux/elfcore.h +22 −0
  4. init/initramfs.c +1 −1
  5. kernel/Makefile +0 −1
  6. kernel/elfcore.c +0 −26
  7. lib/Makefile +2 −1
  8. mm/filemap.c +1 −1
  9. mm/hugetlb.c +1 −0
  10. mm/kasan/quarantine.c +39 −0
fs/proc/task_mmu.c+6−2
@@ -1599,11 +1599,15 @@ static ssize_t pagemap_read(struct file *file, char __user *buf, · 1598 unmodified lines
15991599
16001600 src = *ppos;
16011601 svpfn = src / PM_ENTRY_BYTES;
1602− start_vaddr = svpfn << PAGE_SHIFT;
16031602 end_vaddr = mm->task_size;
16041603
16051604 /* 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)
16071611 start_vaddr = end_vaddr;
16081612
16091613 /*
include/linux/build_bug.h+5−0
@@ -77,4 +77,9 @@ · 76 unmodified lines
7777 #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
7878 #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
7979
80+#ifdef __GENKSYMS__
81+/* genksyms gets confused by _Static_assert */
82+#define _Static_assert(expr, ...)
83+#endif
84+
8085 #endif /* _LINUX_BUILD_BUG_H */
include/linux/elfcore.h+22−0
@@ -104,6 +104,7 @@ static inline int elf_core_copy_task_fpregs(struct task_struct *t, struct pt_reg · 103 unmodified lines
104104 #endif
105105 }
106106
107+#if defined(CONFIG_UM) || defined(CONFIG_IA64)
107108 /*
108109 * These functions parameterize elf_core_dump in fs/binfmt_elf.c to write out
109110 * 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
118119 extern int
119120 elf_core_write_extra_data(struct coredump_params *cprm);
120121 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
121143
122144 #endif /* _LINUX_ELFCORE_H */
init/initramfs.c+1−1
@@ -535,7 +535,7 @@ extern unsigned long __initramfs_size; · 534 unmodified lines
535535 #include <linux/initrd.h>
536536 #include <linux/kexec.h>
537537
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)
539539 {
540540 #ifdef CONFIG_ARCH_KEEP_MEMBLOCK
541541 unsigned long aligned_start = ALIGN_DOWN(start, PAGE_SIZE);
kernel/Makefile+0−1
@@ -97,7 +97,6 @@ obj-$(CONFIG_TASK_DELAY_ACCT) += delayacct.o · 96 unmodified lines
9797 obj-$(CONFIG_TASKSTATS) += taskstats.o tsacct.o
9898 obj-$(CONFIG_TRACEPOINTS) += tracepoint.o
9999 obj-$(CONFIG_LATENCYTOP) += latencytop.o
100−obj-$(CONFIG_ELFCORE) += elfcore.o
101100 obj-$(CONFIG_FUNCTION_TRACER) += trace/
102101 obj-$(CONFIG_TRACING) += trace/
103102 obj-$(CONFIG_TRACE_CLOCK) += trace/
kernel/elfcore.c+0−26
@@ -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−}
lib/Makefile+2−1
@@ -107,7 +107,7 @@ obj-$(CONFIG_TEST_FREE_PAGES) += test_free_pages.o · 106 unmodified lines
107107 # off the generation of FPU/SSE* instructions for kernel proper but FPU_FLAGS
108108 # get appended last to CFLAGS and thus override those previous compiler options.
109109 #
110−FPU_CFLAGS := -mhard-float -msse -msse2
110+FPU_CFLAGS := -msse -msse2
111111 ifdef CONFIG_CC_IS_GCC
112112 # Stack alignment mismatch, proceed with caution.
113113 # 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
120120 # -mpreferred-stack-boundary=3 is not between 4 and 12
121121 #
122122 # can be triggered. Otherwise gcc doesn't complain.
123+FPU_CFLAGS += -mhard-float
123124 FPU_CFLAGS += $(call cc-option,-msse -mpreferred-stack-boundary=3,-mpreferred-stack-boundary=4)
124125 endif
125126
mm/filemap.c+1−1
@@ -827,7 +827,7 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask) · 826 unmodified lines
827827 }
828828 EXPORT_SYMBOL_GPL(replace_page_cache_page);
829829
830−static noinline int __add_to_page_cache_locked(struct page *page,
830+noinline int __add_to_page_cache_locked(struct page *page,
831831 struct address_space *mapping,
832832 pgoff_t offset, gfp_t gfp,
833833 void **shadowp)
mm/hugetlb.c+1−0
@@ -1216,6 +1216,7 @@ static void destroy_compound_gigantic_page(struct page *page, · 1215 unmodified lines
12161216 }
12171217
12181218 set_compound_order(page, 0);
1219+ page[1].compound_nr = 0;
12191220 __ClearPageHead(page);
12201221 }
12211222
mm/kasan/quarantine.c+39−0
@@ -29,6 +29,7 @@ · 28 unmodified lines
2929 #include <linux/srcu.h>
3030 #include <linux/string.h>
3131 #include <linux/types.h>
32+#include <linux/cpuhotplug.h>
3233
3334 #include "../slab.h"
3435 #include "kasan.h"
@@ -43,6 +44,7 @@ struct qlist_head { · 8 unmodified lines
4344 struct qlist_node *head;
4445 struct qlist_node *tail;
4546 size_t bytes;
47+ bool offline;
4648 };
4749
4850 #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
188190 local_irq_save(flags);
189191
190192 q = this_cpu_ptr(&cpu_quarantine);
193+ if (q->offline) {
194+ local_irq_restore(flags);
195+ return;
196+ }
191197 qlist_put(q, &info->quarantine_link, cache->size);
192198 if (unlikely(q->bytes > QUARANTINE_PERCPU_SIZE)) {
193199 qlist_move_all(q, &temp);
@@ -328,3 +334,36 @@ void quarantine_remove_cache(struct kmem_cache *cache) · 134 unmodified lines
328334
329335 synchronize_srcu(&remove_cache_srcu);
330336 }
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);