Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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
...

+140 -53
+11
.mailmap
··· 133 133 Domen Puncer <domen@coderock.org> 134 134 Douglas Gilbert <dougg@torque.net> 135 135 Ed L. Cashin <ecashin@coraid.com> 136 + Enric Balletbo i Serra <eballetbo@kernel.org> <enric.balletbo@collabora.com> 137 + Enric Balletbo i Serra <eballetbo@kernel.org> <eballetbo@iseebcn.com> 136 138 Erik Kaneda <erik.kaneda@intel.com> <erik.schmauss@intel.com> 137 139 Eugen Hristev <eugen.hristev@collabora.com> <eugen.hristev@microchip.com> 138 140 Evgeniy Polyakov <johnpol@2ka.mipt.ru> ··· 381 379 Quentin Perret <qperret@qperret.net> <quentin.perret@arm.com> 382 380 Rafael J. Wysocki <rjw@rjwysocki.net> <rjw@sisk.pl> 383 381 Rajeev Nandan <quic_rajeevny@quicinc.com> <rajeevny@codeaurora.org> 382 + Rajendra Nayak <quic_rjendra@quicinc.com> <rnayak@codeaurora.org> 384 383 Rajesh Shah <rajesh.shah@intel.com> 385 384 Ralf Baechle <ralf@linux-mips.org> 386 385 Ralf Wildenhues <Ralf.Wildenhues@gmx.de> ··· 390 387 Ricardo Ribalda <ribalda@kernel.org> <ricardo@ribalda.com> 391 388 Ricardo Ribalda <ribalda@kernel.org> Ricardo Ribalda Delgado <ribalda@kernel.org> 392 389 Ricardo Ribalda <ribalda@kernel.org> <ricardo.ribalda@gmail.com> 390 + Richard Leitner <richard.leitner@linux.dev> <dev@g0hl1n.net> 391 + Richard Leitner <richard.leitner@linux.dev> <me@g0hl1n.net> 392 + Richard Leitner <richard.leitner@linux.dev> <richard.leitner@skidata.com> 393 393 Robert Foss <rfoss@kernel.org> <robert.foss@linaro.org> 394 394 Roman Gushchin <roman.gushchin@linux.dev> <guro@fb.com> 395 395 Roman Gushchin <roman.gushchin@linux.dev> <guroan@gmail.com> ··· 403 397 Rudolf Marek <R.Marek@sh.cvut.cz> 404 398 Rui Saraiva <rmps@joel.ist.utl.pt> 405 399 Sachin P Sant <ssant@in.ibm.com> 400 + Sai Prakash Ranjan <quic_saipraka@quicinc.com> <saiprakash.ranjan@codeaurora.org> 406 401 Sakari Ailus <sakari.ailus@linux.intel.com> <sakari.ailus@iki.fi> 407 402 Sam Ravnborg <sam@mars.ravnborg.org> 408 403 Sankeerth Billakanti <quic_sbillaka@quicinc.com> <sbillaka@codeaurora.org> ··· 444 437 Thomas Körper <socketcan@esd.eu> <thomas.koerper@esd.eu> 445 438 Thomas Pedersen <twp@codeaurora.org> 446 439 Tiezhu Yang <yangtiezhu@loongson.cn> <kernelpatch@126.com> 440 + Tobias Klauser <tklauser@distanz.ch> <tobias.klauser@gmail.com> 441 + Tobias Klauser <tklauser@distanz.ch> <klto@zhaw.ch> 442 + Tobias Klauser <tklauser@distanz.ch> <tklauser@nuerscht.ch> 443 + Tobias Klauser <tklauser@distanz.ch> <tklauser@xenon.tklauser.home> 447 444 Todor Tomov <todor.too@gmail.com> <todor.tomov@linaro.org> 448 445 Tony Luck <tony.luck@intel.com> 449 446 TripleX Chung <xxx.phy@gmail.com> <triplex@zh-kernel.org>
+1 -1
arch/powerpc/include/asm/kasan.h
··· 2 2 #ifndef __ASM_KASAN_H 3 3 #define __ASM_KASAN_H 4 4 5 - #ifdef CONFIG_KASAN 5 + #if defined(CONFIG_KASAN) && !defined(CONFIG_CC_HAS_KASAN_MEMINTRINSIC_PREFIX) 6 6 #define _GLOBAL_KASAN(fn) _GLOBAL(__##fn) 7 7 #define _GLOBAL_TOC_KASAN(fn) _GLOBAL_TOC(__##fn) 8 8 #define EXPORT_SYMBOL_KASAN(fn) EXPORT_SYMBOL(__##fn)
+11 -4
arch/powerpc/include/asm/string.h
··· 30 30 extern void * memchr(const void *,int,__kernel_size_t); 31 31 void 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 */ 33 40 void *__memset(void *s, int c, __kernel_size_t count); 34 41 void *__memcpy(void *to, const void *from, __kernel_size_t n); 35 42 void *__memmove(void *to, const void *from, __kernel_size_t n); 36 - 37 - #if defined(CONFIG_KASAN) && !defined(__SANITIZE_ADDRESS__) 43 + #ifndef __SANITIZE_ADDRESS__ 38 44 /* 39 45 * For files that are not instrumented (e.g. mm/slub.c) we 40 46 * should use not instrumented version of mem* functions. ··· 52 46 #ifndef __NO_FORTIFY 53 47 #define __NO_FORTIFY /* FORTIFY_SOURCE uses __builtin_memcpy, etc. */ 54 48 #endif 55 - 56 - #endif 49 + #endif /* !__SANITIZE_ADDRESS__ */ 50 + #endif /* CONFIG_CC_HAS_KASAN_MEMINTRINSIC_PREFIX */ 51 + #endif /* CONFIG_KASAN */ 57 52 58 53 #ifdef CONFIG_PPC64 59 54 #ifndef CONFIG_KASAN
+7 -2
arch/powerpc/kernel/prom_init_check.sh
··· 13 13 # If you really need to reference something from prom_init.o add 14 14 # it to the list below: 15 15 16 - grep "^CONFIG_KASAN=y$" ${KCONFIG_CONFIG} >/dev/null 17 - if [ $? -eq 0 ] 16 + has_renamed_memintrinsics() 17 + { 18 + grep -q "^CONFIG_KASAN=y$" ${KCONFIG_CONFIG} && \ 19 + ! grep -q "^CONFIG_CC_HAS_KASAN_MEMINTRINSIC_PREFIX=y" ${KCONFIG_CONFIG} 20 + } 21 + 22 + if has_renamed_memintrinsics 18 23 then 19 24 MEM_FUNCS="__memcpy __memset" 20 25 else
+1 -1
fs/nilfs2/ioctl.c
··· 71 71 if (argv->v_index > ~(__u64)0 - argv->v_nmembs) 72 72 return -EINVAL; 73 73 74 - buf = (void *)__get_free_pages(GFP_NOFS, 0); 74 + buf = (void *)get_zeroed_page(GFP_NOFS); 75 75 if (unlikely(!buf)) 76 76 return -ENOMEM; 77 77 maxmembs = PAGE_SIZE / argv->v_size;
+2 -2
include/trace/events/mmap.h
··· 35 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 39 IS_ERR_VALUE(__entry->addr) ? 0 : __entry->addr, 40 40 IS_ERR_VALUE(__entry->addr) ? __entry->addr : 0, 41 41 __entry->total_vm, __entry->flags, __entry->length, ··· 110 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 114 __entry->mt 115 115 ) 116 116 );
+1 -1
kernel/kcsan/Makefile
··· 16 16 KCSAN_INSTRUMENT_BARRIERS_selftest.o := y 17 17 obj-$(CONFIG_KCSAN_SELFTEST) += selftest.o 18 18 19 - CFLAGS_kcsan_test.o := $(CFLAGS_KCSAN) -g -fno-omit-frame-pointer 19 + CFLAGS_kcsan_test.o := $(CFLAGS_KCSAN) -fno-omit-frame-pointer 20 20 CFLAGS_kcsan_test.o += $(DISABLE_STRUCTLEAK_PLUGIN) 21 21 obj-$(CONFIG_KCSAN_KUNIT_TEST) += kcsan_test.o
+4 -2
lib/dhry_run.c
··· 31 31 32 32 static void dhry_benchmark(void) 33 33 { 34 + unsigned int cpu = get_cpu(); 34 35 int i, n; 35 36 36 37 if (iterations > 0) { ··· 46 45 } 47 46 48 47 report: 48 + put_cpu(); 49 49 if (n >= 0) 50 - pr_info("CPU%u: Dhrystones per Second: %d (%d DMIPS)\n", 51 - smp_processor_id(), n, n / DHRY_VAX); 50 + pr_info("CPU%u: Dhrystones per Second: %d (%d DMIPS)\n", cpu, 51 + n, n / DHRY_VAX); 52 52 else if (n == -EAGAIN) 53 53 pr_err("Please increase the number of iterations\n"); 54 54 else
+5 -19
lib/maple_tree.c
··· 5099 5099 */ 5100 5100 static inline bool mas_skip_node(struct ma_state *mas) 5101 5101 { 5102 - unsigned char slot, slot_count; 5103 - unsigned long *pivots; 5104 - enum maple_type mt; 5102 + if (mas_is_err(mas)) 5103 + return false; 5105 5104 5106 - mt = mte_node_type(mas->node); 5107 - slot_count = mt_slots[mt] - 1; 5108 5105 do { 5109 5106 if (mte_is_root(mas->node)) { 5110 - slot = mas->offset; 5111 - if (slot > slot_count) { 5107 + if (mas->offset >= mas_data_end(mas)) { 5112 5108 mas_set_err(mas, -EBUSY); 5113 5109 return false; 5114 5110 } 5115 5111 } else { 5116 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 5115 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 - 5116 + mas->offset++; 5131 5117 return true; 5132 5118 } 5133 5119
+48
lib/test_maple_tree.c
··· 2670 2670 rcu_read_unlock(); 2671 2671 } 2672 2672 2673 + static 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 + 2673 2716 static DEFINE_MTREE(tree); 2674 2717 static int maple_tree_seed(void) 2675 2718 { ··· 2968 2925 mt_init_flags(&tree, MT_FLAGS_ALLOC_RANGE); 2969 2926 check_empty_area_window(&tree); 2970 2927 mtree_destroy(&tree); 2928 + 2929 + mt_init_flags(&tree, MT_FLAGS_ALLOC_RANGE); 2930 + check_empty_area_fill(&tree); 2931 + mtree_destroy(&tree); 2932 + 2971 2933 2972 2934 #if defined(BENCH) 2973 2935 skip:
+1 -1
mm/kfence/Makefile
··· 2 2 3 3 obj-y := core.o report.o 4 4 5 - CFLAGS_kfence_test.o := -g -fno-omit-frame-pointer -fno-optimize-sibling-calls 5 + CFLAGS_kfence_test.o := -fno-omit-frame-pointer -fno-optimize-sibling-calls 6 6 obj-$(CONFIG_KFENCE_KUNIT_TEST) += kfence_test.o
+8 -2
mm/kfence/core.c
··· 726 726 }; 727 727 DEFINE_SEQ_ATTRIBUTE(objects); 728 728 729 - static int __init kfence_debugfs_init(void) 729 + static 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 737 debugfs_create_file("stats", 0444, kfence_dir, NULL, &stats_fops); 734 738 debugfs_create_file("objects", 0400, kfence_dir, NULL, &objects_fops); 735 739 return 0; ··· 887 883 } 888 884 889 885 kfence_init_enable(); 886 + kfence_debugfs_init(); 887 + 890 888 return 0; 891 889 } 892 890
+9 -2
mm/ksm.c
··· 988 988 989 989 mm = mm_slot->slot.mm; 990 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 999 for_each_vma(vmi, vma) { 992 - if (ksm_test_exit(mm)) 993 - break; 994 1000 if (!(vma->vm_flags & VM_MERGEABLE) || !vma->anon_vma) 995 1001 continue; 996 1002 err = unmerge_ksm_pages(vma, ··· 1005 999 goto error; 1006 1000 } 1007 1001 1002 + mm_exiting: 1008 1003 remove_trailing_rmap_items(&mm_slot->rmap_list); 1009 1004 mmap_read_unlock(mm); 1010 1005
+1 -6
mm/mmap.c
··· 2621 2621 2622 2622 if (map_deny_write_exec(vma, vma->vm_flags)) { 2623 2623 error = -EACCES; 2624 - if (file) 2625 - goto close_and_free_vma; 2626 - else if (vma->vm_file) 2627 - goto unmap_and_free_vma; 2628 - else 2629 - goto free_vma; 2624 + goto close_and_free_vma; 2630 2625 } 2631 2626 2632 2627 /* Allow architectures to sanity-check the vm_flags */
+1 -1
mm/mprotect.c
··· 805 805 806 806 if (map_deny_write_exec(vma, newflags)) { 807 807 error = -EACCES; 808 - goto out; 808 + break; 809 809 } 810 810 811 811 /* Allow architectures to sanity-check the new flags */
+2 -1
mm/page_alloc.c
··· 1398 1398 unsigned int order, bool check_free, fpi_t fpi_flags) 1399 1399 { 1400 1400 int bad = 0; 1401 + bool skip_kasan_poison = should_skip_kasan_poison(page, fpi_flags); 1401 1402 bool init = want_init_on_free(); 1402 1403 1403 1404 VM_BUG_ON_PAGE(PageTail(page), page); ··· 1471 1470 * With hardware tag-based KASAN, memory tags must be set before the 1472 1471 * page becomes unavailable via debug_pagealloc or arch_free_page. 1473 1472 */ 1474 - if (!should_skip_kasan_poison(page, fpi_flags)) { 1473 + if (!skip_kasan_poison) { 1475 1474 kasan_poison_pages(page, order, init); 1476 1475 1477 1476 /* Memory is already initialized if KASAN did it internally. */
+23 -5
mm/vmalloc.c
··· 2883 2883 unsigned int order, unsigned int nr_pages, struct page **pages) 2884 2884 { 2885 2885 unsigned int nr_allocated = 0; 2886 + gfp_t alloc_gfp = gfp; 2887 + bool nofail = false; 2886 2888 struct page *page; 2887 2889 int i; 2888 2890 ··· 2895 2893 * more permissive. 2896 2894 */ 2897 2895 if (!order) { 2896 + /* bulk allocator doesn't support nofail req. officially */ 2898 2897 gfp_t bulk_gfp = gfp & ~__GFP_NOFAIL; 2899 2898 2900 2899 while (nr_allocated < nr_pages) { ··· 2934 2931 if (nr != nr_pages_request) 2935 2932 break; 2936 2933 } 2934 + } else if (gfp & __GFP_NOFAIL) { 2935 + /* 2936 + * Higher order nofail allocations are really expensive and 2937 + * potentially dangerous (pre-mature OOM, disruptive reclaim 2938 + * and compaction etc. 2939 + */ 2940 + alloc_gfp &= ~__GFP_NOFAIL; 2941 + nofail = true; 2937 2942 } 2938 2943 2939 2944 /* High-order pages or fallback path if "bulk" fails. */ 2940 - 2941 2945 while (nr_allocated < nr_pages) { 2942 2946 if (fatal_signal_pending(current)) 2943 2947 break; 2944 2948 2945 2949 if (nid == NUMA_NO_NODE) 2946 - page = alloc_pages(gfp, order); 2950 + page = alloc_pages(alloc_gfp, order); 2947 2951 else 2948 - page = alloc_pages_node(nid, gfp, order); 2949 - if (unlikely(!page)) 2950 - break; 2952 + page = alloc_pages_node(nid, alloc_gfp, order); 2953 + if (unlikely(!page)) { 2954 + if (!nofail) 2955 + break; 2956 + 2957 + /* fall back to the zero order allocations */ 2958 + alloc_gfp |= __GFP_NOFAIL; 2959 + order = 0; 2960 + continue; 2961 + } 2962 + 2951 2963 /* 2952 2964 * Higher order allocations must be able to be treated as 2953 2965 * indepdenent small pages by callers (as they can with
+3 -1
scripts/checksyscalls.sh
··· 114 114 #define __IGNORE_truncate 115 115 #define __IGNORE_stat 116 116 #define __IGNORE_lstat 117 - #define __IGNORE_fstat 118 117 #define __IGNORE_fcntl 119 118 #define __IGNORE_fadvise64 120 119 #define __IGNORE_newfstatat ··· 254 255 /* 64-bit ports never needed these, and new 32-bit ports can use statx */ 255 256 #define __IGNORE_fstat64 256 257 #define __IGNORE_fstatat64 258 + 259 + /* Newer ports are not required to provide fstat in favor of statx */ 260 + #define __IGNORE_fstat 257 261 EOF 258 262 } 259 263
+1 -2
tools/testing/selftests/mm/mdwe_test.c
··· 163 163 164 164 TEST_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 168 self->p = mmap(NULL, self->size, PROT_READ, self->flags, 0, 0); 170 169 ASSERT_NE(self->p, MAP_FAILED); 171 170