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
1599 1599
1600 src = *ppos;1600 src = *ppos;
1601 svpfn = src / PM_ENTRY_BYTES;1601 svpfn = src / PM_ENTRY_BYTES;
1602 start_vaddr = svpfn << PAGE_SHIFT;
1603 end_vaddr = mm->task_size;1602 end_vaddr = mm->task_size;
1604 1603
1605 /* watch out for wraparound */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 start_vaddr = end_vaddr;1611 start_vaddr = end_vaddr;
1608 1612
1609 /*1613 /*
include/linux/build_bug.h+5−0
@@ -77,4 +77,9 @@ · 76 unmodified lines
77#define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)77#define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
78#define __static_assert(expr, msg, ...) _Static_assert(expr, msg)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#endif /* _LINUX_BUILD_BUG_H */85#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
104#endif104#endif
105}105}
106 106
107#if defined(CONFIG_UM) || defined(CONFIG_IA64)
107/*108/*
108 * These functions parameterize elf_core_dump in fs/binfmt_elf.c to write out109 * These functions parameterize elf_core_dump in fs/binfmt_elf.c to write out
109 * extra segments containing the gate DSO contents. Dumping its110 * 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
118extern int119extern int
119elf_core_write_extra_data(struct coredump_params *cprm);120elf_core_write_extra_data(struct coredump_params *cprm);
120extern size_t elf_core_extra_data_size(void);121extern size_t elf_core_extra_data_size(void);
122#else
123static inline Elf_Half elf_core_extra_phdrs(void)
124{
125 return 0;
126}
127
128static inline int elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset)
129{
130 return 1;
131}
132
133static inline int elf_core_write_extra_data(struct coredump_params *cprm)
134{
135 return 1;
136}
137
138static inline size_t elf_core_extra_data_size(void)
139{
140 return 0;
141}
142#endif
121 143
122#endif /* _LINUX_ELFCORE_H */144#endif /* _LINUX_ELFCORE_H */
init/initramfs.c+1−1
@@ -535,7 +535,7 @@ extern unsigned long __initramfs_size; · 534 unmodified lines
535#include <linux/initrd.h>535#include <linux/initrd.h>
536#include <linux/kexec.h>536#include <linux/kexec.h>
537 537
538void __weak free_initrd_mem(unsigned long start, unsigned long end)538void __weak __init free_initrd_mem(unsigned long start, unsigned long end)
539{539{
540#ifdef CONFIG_ARCH_KEEP_MEMBLOCK540#ifdef CONFIG_ARCH_KEEP_MEMBLOCK
541 unsigned long aligned_start = ALIGN_DOWN(start, PAGE_SIZE);541 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
97obj-$(CONFIG_TASKSTATS) += taskstats.o tsacct.o97obj-$(CONFIG_TASKSTATS) += taskstats.o tsacct.o
98obj-$(CONFIG_TRACEPOINTS) += tracepoint.o98obj-$(CONFIG_TRACEPOINTS) += tracepoint.o
99obj-$(CONFIG_LATENCYTOP) += latencytop.o99obj-$(CONFIG_LATENCYTOP) += latencytop.o
100obj-$(CONFIG_ELFCORE) += elfcore.o
101obj-$(CONFIG_FUNCTION_TRACER) += trace/100obj-$(CONFIG_FUNCTION_TRACER) += trace/
102obj-$(CONFIG_TRACING) += trace/101obj-$(CONFIG_TRACING) += trace/
103obj-$(CONFIG_TRACE_CLOCK) += trace/102obj-$(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
8Elf_Half __weak elf_core_extra_phdrs(void)
9{
10 return 0;
11}
12
13int __weak elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset)
14{
15 return 1;
16}
17
18int __weak elf_core_write_extra_data(struct coredump_params *cprm)
19{
20 return 1;
21}
22
23size_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
107# off the generation of FPU/SSE* instructions for kernel proper but FPU_FLAGS107# off the generation of FPU/SSE* instructions for kernel proper but FPU_FLAGS
108# get appended last to CFLAGS and thus override those previous compiler options.108# get appended last to CFLAGS and thus override those previous compiler options.
109#109#
110FPU_CFLAGS := -mhard-float -msse -msse2110FPU_CFLAGS := -msse -msse2
111ifdef CONFIG_CC_IS_GCC111ifdef CONFIG_CC_IS_GCC
112# Stack alignment mismatch, proceed with caution.112# Stack alignment mismatch, proceed with caution.
113# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3113# 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# -mpreferred-stack-boundary=3 is not between 4 and 12120# -mpreferred-stack-boundary=3 is not between 4 and 12
121#121#
122# can be triggered. Otherwise gcc doesn't complain.122# can be triggered. Otherwise gcc doesn't complain.
123FPU_CFLAGS += -mhard-float
123FPU_CFLAGS += $(call cc-option,-msse -mpreferred-stack-boundary=3,-mpreferred-stack-boundary=4)124FPU_CFLAGS += $(call cc-option,-msse -mpreferred-stack-boundary=3,-mpreferred-stack-boundary=4)
124endif125endif
125 126
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
827}827}
828EXPORT_SYMBOL_GPL(replace_page_cache_page);828EXPORT_SYMBOL_GPL(replace_page_cache_page);
829 829
830static noinline int __add_to_page_cache_locked(struct page *page,830noinline int __add_to_page_cache_locked(struct page *page,
831 struct address_space *mapping,831 struct address_space *mapping,
832 pgoff_t offset, gfp_t gfp,832 pgoff_t offset, gfp_t gfp,
833 void **shadowp)833 void **shadowp)
mm/hugetlb.c+1−0
@@ -1216,6 +1216,7 @@ static void destroy_compound_gigantic_page(struct page *page, · 1215 unmodified lines
1216 }1216 }
1217 1217
1218 set_compound_order(page, 0);1218 set_compound_order(page, 0);
1219 page[1].compound_nr = 0;
1219 __ClearPageHead(page);1220 __ClearPageHead(page);
1220}1221}
1221 1222
mm/kasan/quarantine.c+39−0
@@ -29,6 +29,7 @@ · 28 unmodified lines
29#include <linux/srcu.h>29#include <linux/srcu.h>
30#include <linux/string.h>30#include <linux/string.h>
31#include <linux/types.h>31#include <linux/types.h>
32#include <linux/cpuhotplug.h>
32 33
33#include "../slab.h"34#include "../slab.h"
34#include "kasan.h"35#include "kasan.h"
@@ -43,6 +44,7 @@ struct qlist_head { · 8 unmodified lines
43 struct qlist_node *head;44 struct qlist_node *head;
44 struct qlist_node *tail;45 struct qlist_node *tail;
45 size_t bytes;46 size_t bytes;
47 bool offline;
46};48};
47 49
48#define QLIST_INIT { NULL, NULL, 0 }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 local_irq_save(flags);190 local_irq_save(flags);
189 191
190 q = this_cpu_ptr(&cpu_quarantine);192 q = this_cpu_ptr(&cpu_quarantine);
193 if (q->offline) {
194 local_irq_restore(flags);
195 return;
196 }
191 qlist_put(q, &info->quarantine_link, cache->size);197 qlist_put(q, &info->quarantine_link, cache->size);
192 if (unlikely(q->bytes > QUARANTINE_PERCPU_SIZE)) {198 if (unlikely(q->bytes > QUARANTINE_PERCPU_SIZE)) {
193 qlist_move_all(q, &temp);199 qlist_move_all(q, &temp);
@@ -328,3 +334,36 @@ void quarantine_remove_cache(struct kmem_cache *cache) · 134 unmodified lines
328 334
329 synchronize_srcu(&remove_cache_srcu);335 synchronize_srcu(&remove_cache_srcu);
330}336}
337
338static int kasan_cpu_online(unsigned int cpu)
339{
340 this_cpu_ptr(&cpu_quarantine)->offline = false;
341 return 0;
342}
343
344static 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
359static 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}
369late_initcall(kasan_cpu_quarantine_init);