From: Greg Kroah-Hartman Date: Sat, 12 Jul 2025 12:49:48 +0000 (+0200) Subject: 6.1-stable patches X-Git-Tag: v5.15.188~76 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5718cc9de56ddbf73f2971a16c53b306952bf11e;p=thirdparty%2Fkernel%2Fstable-queue.git 6.1-stable patches added patches: maple_tree-fix-ma_state_prealloc-flag-in-mas_preallocate.patch --- diff --git a/queue-6.1/maple_tree-fix-ma_state_prealloc-flag-in-mas_preallocate.patch b/queue-6.1/maple_tree-fix-ma_state_prealloc-flag-in-mas_preallocate.patch new file mode 100644 index 0000000000..4201033dc5 --- /dev/null +++ b/queue-6.1/maple_tree-fix-ma_state_prealloc-flag-in-mas_preallocate.patch @@ -0,0 +1,65 @@ +From fba46a5d83ca8decb338722fb4899026d8d9ead2 Mon Sep 17 00:00:00 2001 +From: "Liam R. Howlett" +Date: Mon, 16 Jun 2025 14:45:20 -0400 +Subject: maple_tree: fix MA_STATE_PREALLOC flag in mas_preallocate() + +From: Liam R. Howlett + +commit fba46a5d83ca8decb338722fb4899026d8d9ead2 upstream. + +Temporarily clear the preallocation flag when explicitly requesting +allocations. Pre-existing allocations are already counted against the +request through mas_node_count_gfp(), but the allocations will not happen +if the MA_STATE_PREALLOC flag is set. This flag is meant to avoid +re-allocating in bulk allocation mode, and to detect issues with +preallocation calculations. + +The MA_STATE_PREALLOC flag should also always be set on zero allocations +so that detection of underflow allocations will print a WARN_ON() during +consumption. + +User visible effect of this flaw is a WARN_ON() followed by a null pointer +dereference when subsequent requests for larger number of nodes is +ignored, such as the vma merge retry in mmap_region() caused by drivers +altering the vma flags (which happens in v6.6, at least) + +Link: https://lkml.kernel.org/r/20250616184521.3382795-3-Liam.Howlett@oracle.com +Fixes: 54a611b60590 ("Maple Tree: add new data structure") +Signed-off-by: Liam R. Howlett +Reported-by: Zhaoyang Huang +Reported-by: Hailong Liu +Link: https://lore.kernel.org/all/1652f7eb-a51b-4fee-8058-c73af63bacd1@oppo.com/ +Link: https://lore.kernel.org/all/20250428184058.1416274-1-Liam.Howlett@oracle.com/ +Link: https://lore.kernel.org/all/20250429014754.1479118-1-Liam.Howlett@oracle.com/ +Cc: Lorenzo Stoakes +Cc: Suren Baghdasaryan +Cc: Hailong Liu +Cc: zhangpeng.00@bytedance.com +Cc: Steve Kang +Cc: Matthew Wilcox +Cc: Sidhartha Kumar +Cc: +Signed-off-by: Andrew Morton +Signed-off-by: Liam R. Howlett +Signed-off-by: Greg Kroah-Hartman +--- + lib/maple_tree.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +--- a/lib/maple_tree.c ++++ b/lib/maple_tree.c +@@ -5802,10 +5802,12 @@ int mas_preallocate(struct ma_state *mas + { + int ret; + ++ mas->mas_flags &= ~MA_STATE_PREALLOC; + mas_node_count_gfp(mas, 1 + mas_mt_height(mas) * 3, gfp); +- mas->mas_flags |= MA_STATE_PREALLOC; +- if (likely(!mas_is_err(mas))) ++ if (likely(!mas_is_err(mas))) { ++ mas->mas_flags |= MA_STATE_PREALLOC; + return 0; ++ } + + mas_set_alloc_req(mas, 0); + ret = xa_err(mas->node); diff --git a/queue-6.1/series b/queue-6.1/series index 4e9d966f22..1924547006 100644 --- a/queue-6.1/series +++ b/queue-6.1/series @@ -17,3 +17,4 @@ atm-clip-fix-infinite-recursive-call-of-clip_push.patch atm-clip-fix-null-pointer-dereference-in-vcc_sendmsg.patch net-sched-abort-__tc_modify_qdisc-if-parent-class-do.patch x86-cpu-amd-properly-check-the-tsa-microcode.patch +maple_tree-fix-ma_state_prealloc-flag-in-mas_preallocate.patch