Skip to content

Commit 65aca32

Browse files
committed
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 ...
2 parents 90c8ce3 + d0072ca commit 65aca32

File tree

19 files changed

+140
-53
lines changed

19 files changed

+140
-53
lines changed

.mailmap

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ Dmitry Safonov <[email protected]> <[email protected]>
133133
Domen Puncer <[email protected]>
134134
Douglas Gilbert <[email protected]>
135135
Ed L. Cashin <[email protected]>
136+
Enric Balletbo i Serra <[email protected]> <[email protected]>
137+
Enric Balletbo i Serra <[email protected]> <[email protected]>
136138
137139
138140
Evgeniy Polyakov <[email protected]>
@@ -379,6 +381,7 @@ Quentin Monnet <[email protected]> <[email protected]>
379381
380382
381383
384+
382385
Rajesh Shah <[email protected]>
383386
Ralf Baechle <[email protected]>
384387
Ralf Wildenhues <[email protected]>
@@ -387,6 +390,9 @@ Rémi Denis-Courmont <[email protected]>
387390
388391
Ricardo Ribalda <[email protected]> Ricardo Ribalda Delgado <[email protected]>
389392
393+
394+
395+
390396
391397
392398
@@ -397,6 +403,7 @@ Ross Zwisler <[email protected]> <[email protected]>
397403
Rudolf Marek <[email protected]>
398404
Rui Saraiva <[email protected]>
399405
Sachin P Sant <[email protected]>
406+
Sai Prakash Ranjan <[email protected]> <[email protected]>
400407
401408
Sam Ravnborg <[email protected]>
402409
Sankeerth Billakanti <[email protected]> <[email protected]>
@@ -437,6 +444,10 @@ Thomas Graf <[email protected]>
437444
438445
Thomas Pedersen <[email protected]>
439446
447+
448+
449+
450+
440451
441452
Tony Luck <[email protected]>
442453

arch/powerpc/include/asm/kasan.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#ifndef __ASM_KASAN_H
33
#define __ASM_KASAN_H
44

5-
#ifdef CONFIG_KASAN
5+
#if defined(CONFIG_KASAN) && !defined(CONFIG_CC_HAS_KASAN_MEMINTRINSIC_PREFIX)
66
#define _GLOBAL_KASAN(fn) _GLOBAL(__##fn)
77
#define _GLOBAL_TOC_KASAN(fn) _GLOBAL_TOC(__##fn)
88
#define EXPORT_SYMBOL_KASAN(fn) EXPORT_SYMBOL(__##fn)

arch/powerpc/include/asm/string.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,17 @@ extern int memcmp(const void *,const void *,__kernel_size_t);
3030
extern void * memchr(const void *,int,__kernel_size_t);
3131
void memcpy_flushcache(void *dest, const void *src, size_t size);
3232

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 */
3340
void *__memset(void *s, int c, __kernel_size_t count);
3441
void *__memcpy(void *to, const void *from, __kernel_size_t n);
3542
void *__memmove(void *to, const void *from, __kernel_size_t n);
36-
37-
#if defined(CONFIG_KASAN) && !defined(__SANITIZE_ADDRESS__)
43+
#ifndef __SANITIZE_ADDRESS__
3844
/*
3945
* For files that are not instrumented (e.g. mm/slub.c) we
4046
* should use not instrumented version of mem* functions.
@@ -46,8 +52,9 @@ void *__memmove(void *to, const void *from, __kernel_size_t n);
4652
#ifndef __NO_FORTIFY
4753
#define __NO_FORTIFY /* FORTIFY_SOURCE uses __builtin_memcpy, etc. */
4854
#endif
49-
50-
#endif
55+
#endif /* !__SANITIZE_ADDRESS__ */
56+
#endif /* CONFIG_CC_HAS_KASAN_MEMINTRINSIC_PREFIX */
57+
#endif /* CONFIG_KASAN */
5158

5259
#ifdef CONFIG_PPC64
5360
#ifndef CONFIG_KASAN

arch/powerpc/kernel/prom_init_check.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@
1313
# If you really need to reference something from prom_init.o add
1414
# it to the list below:
1515

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
1823
then
1924
MEM_FUNCS="__memcpy __memset"
2025
else

fs/nilfs2/ioctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs,
7171
if (argv->v_index > ~(__u64)0 - argv->v_nmembs)
7272
return -EINVAL;
7373

74-
buf = (void *)__get_free_pages(GFP_NOFS, 0);
74+
buf = (void *)get_zeroed_page(GFP_NOFS);
7575
if (unlikely(!buf))
7676
return -ENOMEM;
7777
maxmembs = PAGE_SIZE / argv->v_size;

include/trace/events/mmap.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ TRACE_EVENT(vm_unmapped_area,
3535
__entry->align_offset = info->align_offset;
3636
),
3737

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",
3939
IS_ERR_VALUE(__entry->addr) ? 0 : __entry->addr,
4040
IS_ERR_VALUE(__entry->addr) ? __entry->addr : 0,
4141
__entry->total_vm, __entry->flags, __entry->length,
@@ -110,7 +110,7 @@ TRACE_EVENT(exit_mmap,
110110
__entry->mt = &mm->mm_mt;
111111
),
112112

113-
TP_printk("mt_mod %p, DESTROY\n",
113+
TP_printk("mt_mod %p, DESTROY",
114114
__entry->mt
115115
)
116116
);

kernel/kcsan/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ obj-y := core.o debugfs.o report.o
1616
KCSAN_INSTRUMENT_BARRIERS_selftest.o := y
1717
obj-$(CONFIG_KCSAN_SELFTEST) += selftest.o
1818

19-
CFLAGS_kcsan_test.o := $(CFLAGS_KCSAN) -g -fno-omit-frame-pointer
19+
CFLAGS_kcsan_test.o := $(CFLAGS_KCSAN) -fno-omit-frame-pointer
2020
CFLAGS_kcsan_test.o += $(DISABLE_STRUCTLEAK_PLUGIN)
2121
obj-$(CONFIG_KCSAN_KUNIT_TEST) += kcsan_test.o

lib/dhry_run.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ MODULE_PARM_DESC(iterations,
3131

3232
static void dhry_benchmark(void)
3333
{
34+
unsigned int cpu = get_cpu();
3435
int i, n;
3536

3637
if (iterations > 0) {
@@ -45,9 +46,10 @@ static void dhry_benchmark(void)
4546
}
4647

4748
report:
49+
put_cpu();
4850
if (n >= 0)
49-
pr_info("CPU%u: Dhrystones per Second: %d (%d DMIPS)\n",
50-
smp_processor_id(), n, n / DHRY_VAX);
51+
pr_info("CPU%u: Dhrystones per Second: %d (%d DMIPS)\n", cpu,
52+
n, n / DHRY_VAX);
5153
else if (n == -EAGAIN)
5254
pr_err("Please increase the number of iterations\n");
5355
else

lib/maple_tree.c

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5099,35 +5099,21 @@ static inline bool mas_rewind_node(struct ma_state *mas)
50995099
*/
51005100
static inline bool mas_skip_node(struct ma_state *mas)
51015101
{
5102-
unsigned char slot, slot_count;
5103-
unsigned long *pivots;
5104-
enum maple_type mt;
5102+
if (mas_is_err(mas))
5103+
return false;
51055104

5106-
mt = mte_node_type(mas->node);
5107-
slot_count = mt_slots[mt] - 1;
51085105
do {
51095106
if (mte_is_root(mas->node)) {
5110-
slot = mas->offset;
5111-
if (slot > slot_count) {
5107+
if (mas->offset >= mas_data_end(mas)) {
51125108
mas_set_err(mas, -EBUSY);
51135109
return false;
51145110
}
51155111
} else {
51165112
mas_ascend(mas);
5117-
slot = mas->offset;
5118-
mt = mte_node_type(mas->node);
5119-
slot_count = mt_slots[mt] - 1;
51205113
}
5121-
} while (slot > slot_count);
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];
5114+
} while (mas->offset >= mas_data_end(mas));
51305115

5116+
mas->offset++;
51315117
return true;
51325118
}
51335119

lib/test_maple_tree.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2670,6 +2670,49 @@ static noinline void check_empty_area_window(struct maple_tree *mt)
26702670
rcu_read_unlock();
26712671
}
26722672

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+
26732716
static DEFINE_MTREE(tree);
26742717
static int maple_tree_seed(void)
26752718
{
@@ -2926,6 +2969,11 @@ static int maple_tree_seed(void)
29262969
check_empty_area_window(&tree);
29272970
mtree_destroy(&tree);
29282971

2972+
mt_init_flags(&tree, MT_FLAGS_ALLOC_RANGE);
2973+
check_empty_area_fill(&tree);
2974+
mtree_destroy(&tree);
2975+
2976+
29292977
#if defined(BENCH)
29302978
skip:
29312979
#endif

0 commit comments

Comments
 (0)