History

Merge tag 'mm-hotfixes-stable-2023-03-24-17-09' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Pull misc fixes from Andrew Morton: "21 hotfixes, 8 of which are cc:stable. 11 are for MM, the remainder are for other subsystems" * tag 'mm-hotfixes-stable-2023-03-24-17-09' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (21 commits) mm: mmap: remove newline at the end of the trace mailmap: add entries for Richard Leitner kcsan: avoid passing -g for test kfence: avoid passing -g for test mm: kfence: fix using kfence_metadata without initialization in show_object() lib: dhry: fix unstable smp_processor_id(_) usage mailmap: add entry for Enric Balletbo i Serra mailmap: map Sai Prakash Ranjan's old address to his current one mailmap: map Rajendra Nayak's old address to his current one Revert "kasan: drop skip_kasan_poison variable in free_pages_prepare" mailmap: add entry for Tobias Klauser kasan, powerpc: don't rename memintrinsics if compiler adds prefixes mm/ksm: fix race with VMA iteration and mm_struct teardown kselftest: vm: fix unused variable warning mm: fix error handling for map_deny_write_exec mm: deduplicate error handling for map_deny_write_exec checksyscalls: ignore fstat to silence build warning on LoongArch nilfs2: fix kernel-infoleak in nilfs_ioctl_wrap_copy() test_maple_tree: add more testing for mas_empty_area() maple_tree: fix mas_skip_node() end slot detection ...

Linus Torvalds committed 3 years ago

Commit 65aca322 parents 90c8ce3 d0072ca19 files · +140 −53Browse files

Unified · Split

19 files
  1. .mailmap +11 −0
  2. arch/powerpc/include/asm/kasan.h +1 −1
  3. arch/powerpc/include/asm/string.h +11 −4
  4. arch/powerpc/kernel/prom_init_check.sh +7 −2
  5. fs/nilfs2/ioctl.c +1 −1
  6. include/trace/events/mmap.h +2 −2
  7. kernel/kcsan/Makefile +1 −1
  8. lib/dhry_run.c +4 −2
  9. lib/maple_tree.c +5 −19
  10. lib/test_maple_tree.c +48 −0
  11. mm/kfence/Makefile +1 −1
  12. mm/kfence/core.c +8 −2
  13. mm/ksm.c +9 −2
  14. mm/mmap.c +1 −6
  15. mm/mprotect.c +1 −1
  16. mm/page_alloc.c +2 −1
  17. mm/vmalloc.c +23 −5
  18. scripts/checksyscalls.sh +3 −1
  19. tools/testing/selftests/mm/mdwe_test.c +1 −2
.mailmap+11−0
@@ -133,6 +133,8 @@ Dmitry Safonov <0x7f454c46@gmail.com> <dsafonov@virtuozzo.com> · 132 unmodified lines
133Domen Puncer <domen@coderock.org>133Domen Puncer <domen@coderock.org>
134Douglas Gilbert <dougg@torque.net>134Douglas Gilbert <dougg@torque.net>
135Ed L. Cashin <ecashin@coraid.com>135Ed L. Cashin <ecashin@coraid.com>
136Enric Balletbo i Serra <eballetbo@kernel.org> <enric.balletbo@collabora.com>
137Enric Balletbo i Serra <eballetbo@kernel.org> <eballetbo@iseebcn.com>
136Erik Kaneda <erik.kaneda@intel.com> <erik.schmauss@intel.com>138Erik Kaneda <erik.kaneda@intel.com> <erik.schmauss@intel.com>
137Eugen Hristev <eugen.hristev@collabora.com> <eugen.hristev@microchip.com>139Eugen Hristev <eugen.hristev@collabora.com> <eugen.hristev@microchip.com>
138Evgeniy Polyakov <johnpol@2ka.mipt.ru>140Evgeniy Polyakov <johnpol@2ka.mipt.ru>
@@ -379,6 +381,7 @@ Quentin Monnet <quentin@isovalent.com> <quentin.monnet@netronome.com> · 240 unmodified lines
379Quentin Perret <qperret@qperret.net> <quentin.perret@arm.com>381Quentin Perret <qperret@qperret.net> <quentin.perret@arm.com>
380Rafael J. Wysocki <rjw@rjwysocki.net> <rjw@sisk.pl>382Rafael J. Wysocki <rjw@rjwysocki.net> <rjw@sisk.pl>
381Rajeev Nandan <quic_rajeevny@quicinc.com> <rajeevny@codeaurora.org>383Rajeev Nandan <quic_rajeevny@quicinc.com> <rajeevny@codeaurora.org>
384Rajendra Nayak <quic_rjendra@quicinc.com> <rnayak@codeaurora.org>
382Rajesh Shah <rajesh.shah@intel.com>385Rajesh Shah <rajesh.shah@intel.com>
383Ralf Baechle <ralf@linux-mips.org>386Ralf Baechle <ralf@linux-mips.org>
384Ralf Wildenhues <Ralf.Wildenhues@gmx.de>387Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
@@ -387,6 +390,9 @@ Rémi Denis-Courmont <rdenis@simphalempin.com> · 2 unmodified lines
387Ricardo Ribalda <ribalda@kernel.org> <ricardo@ribalda.com>390Ricardo Ribalda <ribalda@kernel.org> <ricardo@ribalda.com>
388Ricardo Ribalda <ribalda@kernel.org> Ricardo Ribalda Delgado <ribalda@kernel.org>391Ricardo Ribalda <ribalda@kernel.org> Ricardo Ribalda Delgado <ribalda@kernel.org>
389Ricardo Ribalda <ribalda@kernel.org> <ricardo.ribalda@gmail.com>392Ricardo Ribalda <ribalda@kernel.org> <ricardo.ribalda@gmail.com>
393Richard Leitner <richard.leitner@linux.dev> <dev@g0hl1n.net>
394Richard Leitner <richard.leitner@linux.dev> <me@g0hl1n.net>
395Richard Leitner <richard.leitner@linux.dev> <richard.leitner@skidata.com>
390Robert Foss <rfoss@kernel.org> <robert.foss@linaro.org>396Robert Foss <rfoss@kernel.org> <robert.foss@linaro.org>
391Roman Gushchin <roman.gushchin@linux.dev> <guro@fb.com>397Roman Gushchin <roman.gushchin@linux.dev> <guro@fb.com>
392Roman Gushchin <roman.gushchin@linux.dev> <guroan@gmail.com>398Roman Gushchin <roman.gushchin@linux.dev> <guroan@gmail.com>
@@ -397,6 +403,7 @@ Ross Zwisler <zwisler@kernel.org> <ross.zwisler@linux.intel.com> · 4 unmodified lines
397Rudolf Marek <R.Marek@sh.cvut.cz>403Rudolf Marek <R.Marek@sh.cvut.cz>
398Rui Saraiva <rmps@joel.ist.utl.pt>404Rui Saraiva <rmps@joel.ist.utl.pt>
399Sachin P Sant <ssant@in.ibm.com>405Sachin P Sant <ssant@in.ibm.com>
406Sai Prakash Ranjan <quic_saipraka@quicinc.com> <saiprakash.ranjan@codeaurora.org>
400Sakari Ailus <sakari.ailus@linux.intel.com> <sakari.ailus@iki.fi>407Sakari Ailus <sakari.ailus@linux.intel.com> <sakari.ailus@iki.fi>
401Sam Ravnborg <sam@mars.ravnborg.org>408Sam Ravnborg <sam@mars.ravnborg.org>
402Sankeerth Billakanti <quic_sbillaka@quicinc.com> <sbillaka@codeaurora.org>409Sankeerth Billakanti <quic_sbillaka@quicinc.com> <sbillaka@codeaurora.org>
@@ -437,6 +444,10 @@ Thomas Graf <tgraf@suug.ch> · 34 unmodified lines
437Thomas Körper <socketcan@esd.eu> <thomas.koerper@esd.eu>444Thomas Körper <socketcan@esd.eu> <thomas.koerper@esd.eu>
438Thomas Pedersen <twp@codeaurora.org>445Thomas Pedersen <twp@codeaurora.org>
439Tiezhu Yang <yangtiezhu@loongson.cn> <kernelpatch@126.com>446Tiezhu Yang <yangtiezhu@loongson.cn> <kernelpatch@126.com>
447Tobias Klauser <tklauser@distanz.ch> <tobias.klauser@gmail.com>
448Tobias Klauser <tklauser@distanz.ch> <klto@zhaw.ch>
449Tobias Klauser <tklauser@distanz.ch> <tklauser@nuerscht.ch>
450Tobias Klauser <tklauser@distanz.ch> <tklauser@xenon.tklauser.home>
440Todor Tomov <todor.too@gmail.com> <todor.tomov@linaro.org>451Todor Tomov <todor.too@gmail.com> <todor.tomov@linaro.org>
441Tony Luck <tony.luck@intel.com>452Tony Luck <tony.luck@intel.com>
442TripleX Chung <xxx.phy@gmail.com> <triplex@zh-kernel.org>453TripleX Chung <xxx.phy@gmail.com> <triplex@zh-kernel.org>
arch/powerpc/include/asm/kasan.h+1−1
@@ -2,7 +2,7 @@ · 1 unmodified line
2#ifndef __ASM_KASAN_H2#ifndef __ASM_KASAN_H
3#define __ASM_KASAN_H3#define __ASM_KASAN_H
4 4
5#ifdef CONFIG_KASAN5#if defined(CONFIG_KASAN) && !defined(CONFIG_CC_HAS_KASAN_MEMINTRINSIC_PREFIX)
6#define _GLOBAL_KASAN(fn) _GLOBAL(__##fn)6#define _GLOBAL_KASAN(fn) _GLOBAL(__##fn)
7#define _GLOBAL_TOC_KASAN(fn) _GLOBAL_TOC(__##fn)7#define _GLOBAL_TOC_KASAN(fn) _GLOBAL_TOC(__##fn)
8#define EXPORT_SYMBOL_KASAN(fn) EXPORT_SYMBOL(__##fn)8#define EXPORT_SYMBOL_KASAN(fn) EXPORT_SYMBOL(__##fn)
arch/powerpc/include/asm/string.h+11−4
@@ -30,11 +30,17 @@ extern int memcmp(const void *,const void *,__kernel_size_t); · 29 unmodified lines
30extern void * memchr(const void *,int,__kernel_size_t);30extern void * memchr(const void *,int,__kernel_size_t);
31void memcpy_flushcache(void *dest, const void *src, size_t size);31void memcpy_flushcache(void *dest, const void *src, size_t size);
32 32
33#ifdef CONFIG_KASAN
34/* __mem variants are used by KASAN to implement instrumented meminstrinsics. */
35#ifdef CONFIG_CC_HAS_KASAN_MEMINTRINSIC_PREFIX
36#define __memset memset
37#define __memcpy memcpy
38#define __memmove memmove
39#else /* CONFIG_CC_HAS_KASAN_MEMINTRINSIC_PREFIX */
33void *__memset(void *s, int c, __kernel_size_t count);40void *__memset(void *s, int c, __kernel_size_t count);
34void *__memcpy(void *to, const void *from, __kernel_size_t n);41void *__memcpy(void *to, const void *from, __kernel_size_t n);
35void *__memmove(void *to, const void *from, __kernel_size_t n);42void *__memmove(void *to, const void *from, __kernel_size_t n);
36 43#ifndef __SANITIZE_ADDRESS__
37#if defined(CONFIG_KASAN) && !defined(__SANITIZE_ADDRESS__)
38/*44/*
39 * For files that are not instrumented (e.g. mm/slub.c) we45 * For files that are not instrumented (e.g. mm/slub.c) we
40 * should use not instrumented version of mem* functions.46 * should use not instrumented version of mem* functions.
@@ -46,8 +52,9 @@ void *__memmove(void *to, const void *from, __kernel_size_t n); · 5 unmodified lines
46#ifndef __NO_FORTIFY52#ifndef __NO_FORTIFY
47#define __NO_FORTIFY /* FORTIFY_SOURCE uses __builtin_memcpy, etc. */53#define __NO_FORTIFY /* FORTIFY_SOURCE uses __builtin_memcpy, etc. */
48#endif54#endif
49 55#endif /* !__SANITIZE_ADDRESS__ */
50#endif56#endif /* CONFIG_CC_HAS_KASAN_MEMINTRINSIC_PREFIX */
57#endif /* CONFIG_KASAN */
51 58
52#ifdef CONFIG_PPC6459#ifdef CONFIG_PPC64
53#ifndef CONFIG_KASAN60#ifndef CONFIG_KASAN
arch/powerpc/kernel/prom_init_check.sh+7−2
@@ -13,8 +13,13 @@ · 12 unmodified lines
13# If you really need to reference something from prom_init.o add13# If you really need to reference something from prom_init.o add
14# it to the list below:14# it to the list below:
15 15
16grep "^CONFIG_KASAN=y$" ${KCONFIG_CONFIG} >/dev/null16has_renamed_memintrinsics()
17if [ $? -eq 0 ]17{
18 grep -q "^CONFIG_KASAN=y$" ${KCONFIG_CONFIG} && \
19 ! grep -q "^CONFIG_CC_HAS_KASAN_MEMINTRINSIC_PREFIX=y" ${KCONFIG_CONFIG}
20}
21
22if has_renamed_memintrinsics
18then23then
19 MEM_FUNCS="__memcpy __memset"24 MEM_FUNCS="__memcpy __memset"
20else25else
fs/nilfs2/ioctl.c+1−1
@@ -71,7 +71,7 @@ static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs, · 70 unmodified lines
71 if (argv->v_index > ~(__u64)0 - argv->v_nmembs)71 if (argv->v_index > ~(__u64)0 - argv->v_nmembs)
72 return -EINVAL;72 return -EINVAL;
73 73
74 buf = (void *)__get_free_pages(GFP_NOFS, 0);74 buf = (void *)get_zeroed_page(GFP_NOFS);
75 if (unlikely(!buf))75 if (unlikely(!buf))
76 return -ENOMEM;76 return -ENOMEM;
77 maxmembs = PAGE_SIZE / argv->v_size;77 maxmembs = PAGE_SIZE / argv->v_size;
include/trace/events/mmap.h+2−2
@@ -35,7 +35,7 @@ TRACE_EVENT(vm_unmapped_area, · 34 unmodified lines
35 __entry->align_offset = info->align_offset;35 __entry->align_offset = info->align_offset;
36 ),36 ),
37 37
38 TP_printk("addr=0x%lx err=%ld total_vm=0x%lx flags=0x%lx len=0x%lx lo=0x%lx hi=0x%lx mask=0x%lx ofs=0x%lx\n",38 TP_printk("addr=0x%lx err=%ld total_vm=0x%lx flags=0x%lx len=0x%lx lo=0x%lx hi=0x%lx mask=0x%lx ofs=0x%lx",
39 IS_ERR_VALUE(__entry->addr) ? 0 : __entry->addr,39 IS_ERR_VALUE(__entry->addr) ? 0 : __entry->addr,
40 IS_ERR_VALUE(__entry->addr) ? __entry->addr : 0,40 IS_ERR_VALUE(__entry->addr) ? __entry->addr : 0,
41 __entry->total_vm, __entry->flags, __entry->length,41 __entry->total_vm, __entry->flags, __entry->length,
@@ -110,7 +110,7 @@ TRACE_EVENT(exit_mmap, · 68 unmodified lines
110 __entry->mt = &mm->mm_mt;110 __entry->mt = &mm->mm_mt;
111 ),111 ),
112 112
113 TP_printk("mt_mod %p, DESTROY\n",113 TP_printk("mt_mod %p, DESTROY",
114 __entry->mt114 __entry->mt
115 )115 )
116);116);
kernel/kcsan/Makefile+1−1
@@ -16,6 +16,6 @@ obj-y := core.o debugfs.o report.o · 15 unmodified lines
16KCSAN_INSTRUMENT_BARRIERS_selftest.o := y16KCSAN_INSTRUMENT_BARRIERS_selftest.o := y
17obj-$(CONFIG_KCSAN_SELFTEST) += selftest.o17obj-$(CONFIG_KCSAN_SELFTEST) += selftest.o
18 18
19CFLAGS_kcsan_test.o := $(CFLAGS_KCSAN) -g -fno-omit-frame-pointer19CFLAGS_kcsan_test.o := $(CFLAGS_KCSAN) -fno-omit-frame-pointer
20CFLAGS_kcsan_test.o += $(DISABLE_STRUCTLEAK_PLUGIN)20CFLAGS_kcsan_test.o += $(DISABLE_STRUCTLEAK_PLUGIN)
21obj-$(CONFIG_KCSAN_KUNIT_TEST) += kcsan_test.o21obj-$(CONFIG_KCSAN_KUNIT_TEST) += kcsan_test.o
lib/dhry_run.c+4−2
@@ -31,6 +31,7 @@ MODULE_PARM_DESC(iterations, · 30 unmodified lines
31 31
32static void dhry_benchmark(void)32static void dhry_benchmark(void)
33{33{
34 unsigned int cpu = get_cpu();
34 int i, n;35 int i, n;
35 36
36 if (iterations > 0) {37 if (iterations > 0) {
@@ -45,9 +46,10 @@ static void dhry_benchmark(void) · 8 unmodified lines
45 }46 }
46 47
47report:48report:
49 put_cpu();
48 if (n >= 0)50 if (n >= 0)
49 pr_info("CPU%u: Dhrystones per Second: %d (%d DMIPS)\n",51 pr_info("CPU%u: Dhrystones per Second: %d (%d DMIPS)\n", cpu,
50 smp_processor_id(), n, n / DHRY_VAX);52 n, n / DHRY_VAX);
51 else if (n == -EAGAIN)53 else if (n == -EAGAIN)
52 pr_err("Please increase the number of iterations\n");54 pr_err("Please increase the number of iterations\n");
53 else55 else
lib/maple_tree.c+5−19
@@ -5099,35 +5099,21 @@ static inline bool mas_rewind_node(struct ma_state *mas) · 5098 unmodified lines
5099 */5099 */
5100static inline bool mas_skip_node(struct ma_state *mas)5100static inline bool mas_skip_node(struct ma_state *mas)
5101{5101{
5102 unsigned char slot, slot_count;5102 if (mas_is_err(mas))
5103 unsigned long *pivots;5103 return false;
5104 enum maple_type mt;
5105 5104
5106 mt = mte_node_type(mas->node);
5107 slot_count = mt_slots[mt] - 1;
5108 do {5105 do {
5109 if (mte_is_root(mas->node)) {5106 if (mte_is_root(mas->node)) {
5110 slot = mas->offset;5107 if (mas->offset >= mas_data_end(mas)) {
5111 if (slot > slot_count) {
5112 mas_set_err(mas, -EBUSY);5108 mas_set_err(mas, -EBUSY);
5113 return false;5109 return false;
5114 }5110 }
5115 } else {5111 } else {
5116 mas_ascend(mas);5112 mas_ascend(mas);
5117 slot = mas->offset;
5118 mt = mte_node_type(mas->node);
5119 slot_count = mt_slots[mt] - 1;
5120 }5113 }
5121 } while (slot > slot_count);5114 } while (mas->offset >= mas_data_end(mas));
5122
5123 mas->offset = ++slot;
5124 pivots = ma_pivots(mas_mn(mas), mt);
5125 if (slot > 0)
5126 mas->min = pivots[slot - 1] + 1;
5127
5128 if (slot <= slot_count)
5129 mas->max = pivots[slot];
5130 5115
5116 mas->offset++;
5131 return true;5117 return true;
5132}5118}
5133 5119
lib/test_maple_tree.c+48−0
@@ -2670,6 +2670,49 @@ static noinline void check_empty_area_window(struct maple_tree *mt) · 2669 unmodified lines
2670 rcu_read_unlock();2670 rcu_read_unlock();
2671}2671}
2672 2672
2673static noinline void check_empty_area_fill(struct maple_tree *mt)
2674{
2675 const unsigned long max = 0x25D78000;
2676 unsigned long size;
2677 int loop, shift;
2678 MA_STATE(mas, mt, 0, 0);
2679
2680 mt_set_non_kernel(99999);
2681 for (shift = 12; shift <= 16; shift++) {
2682 loop = 5000;
2683 size = 1 << shift;
2684 while (loop--) {
2685 mas_set(&mas, 0);
2686 mas_lock(&mas);
2687 MT_BUG_ON(mt, mas_empty_area(&mas, 0, max, size) != 0);
2688 MT_BUG_ON(mt, mas.last != mas.index + size - 1);
2689 mas_store_gfp(&mas, (void *)size, GFP_KERNEL);
2690 mas_unlock(&mas);
2691 mas_reset(&mas);
2692 }
2693 }
2694
2695 /* No space left. */
2696 size = 0x1000;
2697 rcu_read_lock();
2698 MT_BUG_ON(mt, mas_empty_area(&mas, 0, max, size) != -EBUSY);
2699 rcu_read_unlock();
2700
2701 /* Fill a depth 3 node to the maximum */
2702 for (unsigned long i = 629440511; i <= 629440800; i += 6)
2703 mtree_store_range(mt, i, i + 5, (void *)i, GFP_KERNEL);
2704 /* Make space in the second-last depth 4 node */
2705 mtree_erase(mt, 631668735);
2706 /* Make space in the last depth 4 node */
2707 mtree_erase(mt, 629506047);
2708 mas_reset(&mas);
2709 /* Search from just after the gap in the second-last depth 4 */
2710 rcu_read_lock();
2711 MT_BUG_ON(mt, mas_empty_area(&mas, 629506048, 690000000, 0x5000) != 0);
2712 rcu_read_unlock();
2713 mt_set_non_kernel(0);
2714}
2715
2673static DEFINE_MTREE(tree);2716static DEFINE_MTREE(tree);
2674static int maple_tree_seed(void)2717static int maple_tree_seed(void)
2675{2718{
@@ -2926,6 +2969,11 @@ static int maple_tree_seed(void) · 250 unmodified lines
2926 check_empty_area_window(&tree);2969 check_empty_area_window(&tree);
2927 mtree_destroy(&tree);2970 mtree_destroy(&tree);
2928 2971
2972 mt_init_flags(&tree, MT_FLAGS_ALLOC_RANGE);
2973 check_empty_area_fill(&tree);
2974 mtree_destroy(&tree);
2975
2976
2929#if defined(BENCH)2977#if defined(BENCH)
2930skip:2978skip:
2931#endif2979#endif
mm/kfence/Makefile+1−1
@@ -2,5 +2,5 @@ · 1 unmodified line
2 2
3obj-y := core.o report.o3obj-y := core.o report.o
4 4
5CFLAGS_kfence_test.o := -g -fno-omit-frame-pointer -fno-optimize-sibling-calls5CFLAGS_kfence_test.o := -fno-omit-frame-pointer -fno-optimize-sibling-calls
6obj-$(CONFIG_KFENCE_KUNIT_TEST) += kfence_test.o6obj-$(CONFIG_KFENCE_KUNIT_TEST) += kfence_test.o
mm/kfence/core.c+8−2
@@ -726,10 +726,14 @@ static const struct seq_operations objects_sops = { · 725 unmodified lines
726};726};
727DEFINE_SEQ_ATTRIBUTE(objects);727DEFINE_SEQ_ATTRIBUTE(objects);
728 728
729static int __init kfence_debugfs_init(void)729static int kfence_debugfs_init(void)
730{730{
731 struct dentry *kfence_dir = debugfs_create_dir("kfence", NULL);731 struct dentry *kfence_dir;
732 732
733 if (!READ_ONCE(kfence_enabled))
734 return 0;
735
736 kfence_dir = debugfs_create_dir("kfence", NULL);
733 debugfs_create_file("stats", 0444, kfence_dir, NULL, &stats_fops);737 debugfs_create_file("stats", 0444, kfence_dir, NULL, &stats_fops);
734 debugfs_create_file("objects", 0400, kfence_dir, NULL, &objects_fops);738 debugfs_create_file("objects", 0400, kfence_dir, NULL, &objects_fops);
735 return 0;739 return 0;
@@ -883,6 +887,8 @@ static int kfence_init_late(void) · 147 unmodified lines
883 }887 }
884 888
885 kfence_init_enable();889 kfence_init_enable();
890 kfence_debugfs_init();
891
886 return 0;892 return 0;
887}893}
888 894
mm/ksm.c+9−2
@@ -988,9 +988,15 @@ static int unmerge_and_remove_all_rmap_items(void) · 987 unmodified lines
988 988
989 mm = mm_slot->slot.mm;989 mm = mm_slot->slot.mm;
990 mmap_read_lock(mm);990 mmap_read_lock(mm);
991
992 /*
993 * Exit right away if mm is exiting to avoid lockdep issue in
994 * the maple tree
995 */
996 if (ksm_test_exit(mm))
997 goto mm_exiting;
998
991 for_each_vma(vmi, vma) {999 for_each_vma(vmi, vma) {
992 if (ksm_test_exit(mm))
993 break;
994 if (!(vma->vm_flags & VM_MERGEABLE) || !vma->anon_vma)1000 if (!(vma->vm_flags & VM_MERGEABLE) || !vma->anon_vma)
995 continue;1001 continue;
996 err = unmerge_ksm_pages(vma,1002 err = unmerge_ksm_pages(vma,
@@ -999,6 +1005,7 @@ static int unmerge_and_remove_all_rmap_items(void) · 2 unmodified lines
999 goto error;1005 goto error;
1000 }1006 }
1001 1007
1008mm_exiting:
1002 remove_trailing_rmap_items(&mm_slot->rmap_list);1009 remove_trailing_rmap_items(&mm_slot->rmap_list);
1003 mmap_read_unlock(mm);1010 mmap_read_unlock(mm);
1004 1011
mm/mmap.c+1−6
@@ -2621,12 +2621,7 @@ cannot_expand: · 2620 unmodified lines
2621 2621
2622 if (map_deny_write_exec(vma, vma->vm_flags)) {2622 if (map_deny_write_exec(vma, vma->vm_flags)) {
2623 error = -EACCES;2623 error = -EACCES;
2624 if (file)2624 goto close_and_free_vma;
2625 goto close_and_free_vma;
2626 else if (vma->vm_file)
2627 goto unmap_and_free_vma;
2628 else
2629 goto free_vma;
2630 }2625 }
2631 2626
2632 /* Allow architectures to sanity-check the vm_flags */2627 /* Allow architectures to sanity-check the vm_flags */
mm/mprotect.c+1−1
@@ -805,7 +805,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len, · 804 unmodified lines
805 805
806 if (map_deny_write_exec(vma, newflags)) {806 if (map_deny_write_exec(vma, newflags)) {
807 error = -EACCES;807 error = -EACCES;
808 goto out;808 break;
809 }809 }
810 810
811 /* Allow architectures to sanity-check the new flags */811 /* Allow architectures to sanity-check the new flags */
mm/page_alloc.c+2−1
@@ -1398,6 +1398,7 @@ static __always_inline bool free_pages_prepare(struct page *page, · 1397 unmodified lines
1398 unsigned int order, bool check_free, fpi_t fpi_flags)1398 unsigned int order, bool check_free, fpi_t fpi_flags)
1399{1399{
1400 int bad = 0;1400 int bad = 0;
1401 bool skip_kasan_poison = should_skip_kasan_poison(page, fpi_flags);
1401 bool init = want_init_on_free();1402 bool init = want_init_on_free();
1402 1403
1403 VM_BUG_ON_PAGE(PageTail(page), page);1404 VM_BUG_ON_PAGE(PageTail(page), page);
@@ -1470,7 +1471,7 @@ static __always_inline bool free_pages_prepare(struct page *page, · 66 unmodified lines
1470 * With hardware tag-based KASAN, memory tags must be set before the1471 * With hardware tag-based KASAN, memory tags must be set before the
1471 * page becomes unavailable via debug_pagealloc or arch_free_page.1472 * page becomes unavailable via debug_pagealloc or arch_free_page.
1472 */1473 */
1473 if (!should_skip_kasan_poison(page, fpi_flags)) {1474 if (!skip_kasan_poison) {
1474 kasan_poison_pages(page, order, init);1475 kasan_poison_pages(page, order, init);
1475 1476
1476 /* Memory is already initialized if KASAN did it internally. */1477 /* Memory is already initialized if KASAN did it internally. */
mm/vmalloc.c+23−5
@@ -2883,6 +2883,8 @@ vm_area_alloc_pages(gfp_t gfp, int nid, · 2882 unmodified lines
2883 unsigned int order, unsigned int nr_pages, struct page **pages)2883 unsigned int order, unsigned int nr_pages, struct page **pages)
2884{2884{
2885 unsigned int nr_allocated = 0;2885 unsigned int nr_allocated = 0;
2886 gfp_t alloc_gfp = gfp;
2887 bool nofail = false;
2886 struct page *page;2888 struct page *page;
2887 int i;2889 int i;
2888 2890
@@ -2893,6 +2895,7 @@ vm_area_alloc_pages(gfp_t gfp, int nid, · 4 unmodified lines
2893 * more permissive.2895 * more permissive.
2894 */2896 */
2895 if (!order) {2897 if (!order) {
2898 /* bulk allocator doesn't support nofail req. officially */
2896 gfp_t bulk_gfp = gfp & ~__GFP_NOFAIL;2899 gfp_t bulk_gfp = gfp & ~__GFP_NOFAIL;
2897 2900
2898 while (nr_allocated < nr_pages) {2901 while (nr_allocated < nr_pages) {
@@ -2931,20 +2934,35 @@ vm_area_alloc_pages(gfp_t gfp, int nid, · 32 unmodified lines
2931 if (nr != nr_pages_request)2934 if (nr != nr_pages_request)
2932 break;2935 break;
2933 }2936 }
2937 } else if (gfp & __GFP_NOFAIL) {
2938 /*
2939 * Higher order nofail allocations are really expensive and
2940 * potentially dangerous (pre-mature OOM, disruptive reclaim
2941 * and compaction etc.
2942 */
2943 alloc_gfp &= ~__GFP_NOFAIL;
2944 nofail = true;
2934 }2945 }
2935 2946
2936 /* High-order pages or fallback path if "bulk" fails. */2947 /* High-order pages or fallback path if "bulk" fails. */
2937
2938 while (nr_allocated < nr_pages) {2948 while (nr_allocated < nr_pages) {
2939 if (fatal_signal_pending(current))2949 if (fatal_signal_pending(current))
2940 break;2950 break;
2941 2951
2942 if (nid == NUMA_NO_NODE)2952 if (nid == NUMA_NO_NODE)
2943 page = alloc_pages(gfp, order);2953 page = alloc_pages(alloc_gfp, order);
2944 else2954 else
2945 page = alloc_pages_node(nid, gfp, order);2955 page = alloc_pages_node(nid, alloc_gfp, order);
2946 if (unlikely(!page))2956 if (unlikely(!page)) {
2947 break;2957 if (!nofail)
2958 break;
2959
2960 /* fall back to the zero order allocations */
2961 alloc_gfp |= __GFP_NOFAIL;
2962 order = 0;
2963 continue;
2964 }
2965
2948 /*2966 /*
2949 * Higher order allocations must be able to be treated as2967 * Higher order allocations must be able to be treated as
2950 * indepdenent small pages by callers (as they can with2968 * indepdenent small pages by callers (as they can with
scripts/checksyscalls.sh+3−1
@@ -114,7 +114,6 @@ cat << EOF · 113 unmodified lines
114#define __IGNORE_truncate114#define __IGNORE_truncate
115#define __IGNORE_stat115#define __IGNORE_stat
116#define __IGNORE_lstat116#define __IGNORE_lstat
117#define __IGNORE_fstat
118#define __IGNORE_fcntl117#define __IGNORE_fcntl
119#define __IGNORE_fadvise64118#define __IGNORE_fadvise64
120#define __IGNORE_newfstatat119#define __IGNORE_newfstatat
@@ -255,6 +254,9 @@ cat << EOF · 134 unmodified lines
255/* 64-bit ports never needed these, and new 32-bit ports can use statx */254/* 64-bit ports never needed these, and new 32-bit ports can use statx */
256#define __IGNORE_fstat64255#define __IGNORE_fstat64
257#define __IGNORE_fstatat64256#define __IGNORE_fstatat64
257
258/* Newer ports are not required to provide fstat in favor of statx */
259#define __IGNORE_fstat
258EOF260EOF
259}261}
260 262
tools/testing/selftests/mm/mdwe_test.c+1−2
@@ -163,9 +163,8 @@ TEST_F(mdwe, mprotect_WRITE_EXEC) · 162 unmodified lines
163 163
164TEST_F(mdwe, mmap_FIXED)164TEST_F(mdwe, mmap_FIXED)
165{165{
166 void *p, *p2;166 void *p;
167 167
168 p2 = mmap(NULL, self->size, PROT_READ | PROT_EXEC, self->flags, 0, 0);
169 self->p = mmap(NULL, self->size, PROT_READ, self->flags, 0, 0);168 self->p = mmap(NULL, self->size, PROT_READ, self->flags, 0, 0);
170 ASSERT_NE(self->p, MAP_FAILED);169 ASSERT_NE(self->p, MAP_FAILED);
171 170