assoc_array-discard-shortcut-when-collapsing-a-leaf-only-node.patch removed from -mm tree
Subsystems (2)
The quilt patch titled
Subject: assoc_array: discard shortcut when collapsing a leaf-only node
has been removed from the -mm tree. Its filename was
assoc_array-discard-shortcut-when-collapsing-a-leaf-only-node.patch
This patch was dropped because it was merged into the mm-hotfixes-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Daehyeon Ko <[email protected]>
Subject: assoc_array: discard shortcut when collapsing a leaf-only node
Date: Fri, 25 Sep 2026 17:05:48 +0900
assoc_array_delete() can collapse a subtree into a node that contains only leaves while retaining the shortcut that led to it. If that node later fills, all_leaves_cluster_together replaces it with another shortcut. The first shortcut then points directly to the second one.
assoc_array_apply_edit() publishes this topology and propagates branch counts from the new child node. It skips the inner shortcut, encounters the outer shortcut where it requires a node and triggers the BUG_ON().
Linux v7.2 and v6.12.105 are affected. The same root remains at the base-commit below and in every supported stable branch checked down to 5.10. It requires CONFIG_KEYS, but no capability, user namespace or race. A UID/GID 1000 process produced:
CONTROL_BEGIN mode=exact uid=1000 gid=1000
CONTROL_CapEff: 0000000000000000
kernel BUG at lib/assoc_array.c:1388!
Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI CPU: 0 UID: 1000 PID: 154 Comm: exploit RIP: assoc_array_apply_edit+0x4aa/0x690 Call Trace: __key_link __key_instantiate_and_link __key_create_or_update __do_sys_add_key Kernel panic - not syncing: Fatal exception
When deletion produces a leaf-only node, bypass its preceding shortcut as garbage collection already does. Retire the shortcut and old node together after an RCU grace period; reused leaves keep their references and the deleted leaf is still freed separately.
The exact trigger reached the BUG in 3/3 unmodified v7.2 KASAN boots and completed cleanly in 3/3 fixed boots. Fixed v6.12.105 also passed 3/3. A source reproducer is available privately on request.
---
lib/assoc_array.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-)
lib/assoc_array.c renamed from lib/assoc_array.c~assoc_array-discard-shortcut-when-collapsing-a-leaf-only-node +22 -14
@@ -1210,8 +1210,22 @@ found_leaf: goto enomem; edit->new_meta[0 ] =assoc_array_node_to_ptr (new_n0); - new_n0->back_pointer = node->back_pointer; - new_n0->parent_slot = node->parent_slot; +/* A shortcut above a leaf-only node is redundant. Drop it as +* GC does so that a later split can't create two shortcuts in a row. +*/ + ptr = node->back_pointer; +if (assoc_array_ptr_is_shortcut (ptr)) { +struct assoc_array_shortcut *s = +assoc_array_ptr_to_shortcut (ptr); + + new_n0->back_pointer = s->back_pointer; + new_n0->parent_slot = s->parent_slot; + edit->excised_subtree = ptr; + }else { + new_n0->back_pointer = ptr; + new_n0->parent_slot = node->parent_slot; + edit->excised_subtree =assoc_array_node_to_ptr (node); + } new_n0->nr_leaves_on_branch = node->nr_leaves_on_branch; edit->adjust_count_on = new_n0;
@@ -1225,21 +1239,15 @@ found_leaf:pr_devel ("collapsed %d,%lu\n" , collapse.slot, new_n0->nr_leaves_on_branch);BUG_ON (collapse.slot != new_n0->nr_leaves_on_branch -1 ); -if (!node->back_pointer) { +if (!new_n0->back_pointer) { edit->set[1 ].ptr = &array->root; - }else if (assoc_array_ptr_is_leaf (node->back_pointer)) { -BUG (); - }else if (assoc_array_ptr_is_node (node->back_pointer)) { -struct assoc_array_node *p = -assoc_array_ptr_to_node (node->back_pointer); - edit->set[1 ].ptr = &p->slots[node->parent_slot]; - }else if (assoc_array_ptr_is_shortcut (node->back_pointer)) { -struct assoc_array_shortcut *s = -assoc_array_ptr_to_shortcut (node->back_pointer); - edit->set[1 ].ptr = &s->next_node; + }else { +struct assoc_array_node *p; + + p =assoc_array_ptr_to_node (new_n0->back_pointer); + edit->set[1 ].ptr = &p->slots[new_n0->parent_slot]; } edit->set[1 ].to =assoc_array_node_to_ptr (new_n0); - edit->excised_subtree =assoc_array_node_to_ptr (node); } }
_
Patches currently in -mm which might be from [email protected] are
iov_iter-validate-extracted-segment-for-bvec-alignment.patch mm-hugetlb_cgroup-prevent-use-after-free-during-cgroup-offlining.patch
Quoted 105 lines · Andrew Morton
The quilt patch titled
Subject:assoc_array: discard shortcut when collapsing a leaf-only node
has been removed from the -mm tree. Its filename was
assoc_array-discard-shortcut-when-collapsing-a-leaf-only-node.patchThis patch was dropped because it was merged into the mm-hotfixes-stable branch of
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm------------------------------------------------------
From: Daehyeon Ko <[email protected]>
Subject:assoc_array: discard shortcut when collapsing a leaf-only node
Date: Fri, 25 Sep 2026 17:05:48 +0900
assoc_array_delete()can collapse a subtree into a node that contains only leaves while retaining the shortcut that led to it. If that node later fills,all_leaves_cluster_togetherreplaces it with another shortcut. The first shortcut then points directly to the second one.
assoc_array_apply_edit()publishes this topology and propagates branch counts from the new child node. It skips the inner shortcut, encounters the outer shortcut where it requires a node and triggers theBUG_ON().Linux v7.2 and v6.12.105 are affected. The same root remains at the base-commit below and in every supported stable branch checked down to 5.10. It requires
CONFIG_KEYS, but no capability, user namespace or race. A UID/GID 1000 process produced:
CONTROL_BEGINmode=exact uid=1000 gid=1000
CONTROL_CapEff: 0000000000000000
kernel BUG atlib/assoc_array.c:1388!Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI CPU: 0 UID: 1000 PID: 154 Comm: exploit RIP: assoc_array_apply_edit+0x4aa/0x690 Call Trace: __key_link __key_instantiate_and_link __key_create_or_update __do_sys_add_key Kernel panic - not syncing: Fatal exceptionWhen deletion produces a leaf-only node, bypass its preceding shortcut as garbage collection already does. Retire the shortcut and old node together after an RCU grace period; reused leaves keep their references and the deleted leaf is still freed separately.
The exact trigger reached the BUG in 3/3 unmodified v7.2 KASAN boots and completed cleanly in 3/3 fixed boots. Fixed v6.12.105 also passed 3/3. A source reproducer is available privately on request.
Fixes 3cb989501c26 ("Add a generic associative array implementation.")Signed-off-by Daehyeon Ko <[email protected]>Signed-off-by Andrew Morton <[email protected]>Reviewed-by Jarkko Sakkinen <[email protected]>Cc David Howells <[email protected]>Cc <[email protected]>---
lib/assoc_array.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-)lib/assoc_array.c renamed from lib/assoc_array.c~assoc_array-discard-shortcut-when-collapsing-a-leaf-only-node +17
-13@@ -1210,8 +1210,22 @@ found_leaf: goto enomem; edit->new_meta[0 ] =assoc_array_node_to_ptr (new_n0); - new_n0->back_pointer = node->back_pointer; - new_n0->parent_slot = node->parent_slot; +/* A shortcut above a leaf-only node is redundant. Drop it as +* GC does so that a later split can't create two shortcuts in a row. +*/ + ptr = node->back_pointer; +if (assoc_array_ptr_is_shortcut (ptr)) { +struct assoc_array_shortcut *s = +assoc_array_ptr_to_shortcut (ptr); + + new_n0->back_pointer = s->back_pointer; + new_n0->parent_slot = s->parent_slot; + edit->excised_subtree = ptr; + }else { + new_n0->back_pointer = ptr; + new_n0->parent_slot = node->parent_slot; + edit->excised_subtree =assoc_array_node_to_ptr (node); + } new_n0->nr_leaves_on_branch = node->nr_leaves_on_branch; edit->adjust_count_on = new_n0;@@ -1225,21 +1239,15 @@ found_leaf:pr_devel ("collapsed %d,%lu\n" , collapse.slot, new_n0->nr_leaves_on_branch);BUG_ON (collapse.slot != new_n0->nr_leaves_on_branch -1 ); -if (!node->back_pointer) { +if (!new_n0->back_pointer) { edit->set[1 ].ptr = &array->root; - }else if (assoc_array_ptr_is_leaf (node->back_pointer)) { -BUG (); - }else if (assoc_array_ptr_is_node (node->back_pointer)) { -struct assoc_array_node *p = -assoc_array_ptr_to_node (node->back_pointer); - edit->set[1 ].ptr = &p->slots[node->parent_slot]; - }else if (assoc_array_ptr_is_shortcut (node->back_pointer)) { -struct assoc_array_shortcut *s = -assoc_array_ptr_to_shortcut (node->back_pointer); - edit->set[1 ].ptr = &s->next_node;
lib/assoc_array.c found_leaf: · line 1252
Quoted 10 lines
lib/assoc_array.c renamed from lib/assoc_array.c~assoc_array-discard-shortcut-when-collapsing-a-leaf-only-node +5
-1+ }else { +struct assoc_array_node *p; + + p =assoc_array_ptr_to_node (new_n0->back_pointer); + edit->set[1 ].ptr = &p->slots[new_n0->parent_slot]; } edit->set[1 ].to =assoc_array_node_to_ptr (new_n0); - edit->excised_subtree =assoc_array_node_to_ptr (node); } }
This causes conflicts with upstream. I suspect with Linus' cleanups part of
commit 666539eecdf4db623f5e3c3e55cf9f2dfad24aa4 (origin/master, origin/HEAD, master, base)
Merge: 141b164bbe18 bbab563c5131
Author: Linus Torvalds <[email protected]>
Date: Mon Nov 16 09:35:38 2026 -0800
Merge tag 'assoc-array-fixes-v2'
Clean up assoc_array library code
It's in akpm/mm-hotfixes-unstable, but is this really MM material?
Sounds more like nonmm stuff.
Anyhow, I'll drop this from now from mm-next as I couldn't easily figure out how to resolve this (or if it is still required).
Signature · 3 lines
Cheers, David
Quoted 127 lines · David Hildenbrand (Arm)
Quoted 105 lines · Andrew Morton
The quilt patch titled
Subject:assoc_array: discard shortcut when collapsing a leaf-only node
has been removed from the -mm tree. Its filename was
assoc_array-discard-shortcut-when-collapsing-a-leaf-only-node.patchThis patch was dropped because it was merged into the mm-hotfixes-stable branch of
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm------------------------------------------------------
From: Daehyeon Ko <[email protected]>
Subject:assoc_array: discard shortcut when collapsing a leaf-only node
Date: Fri, 25 Sep 2026 17:05:48 +0900
assoc_array_delete()can collapse a subtree into a node that contains only leaves while retaining the shortcut that led to it. If that node later fills,all_leaves_cluster_togetherreplaces it with another shortcut. The first shortcut then points directly to the second one.
assoc_array_apply_edit()publishes this topology and propagates branch counts from the new child node. It skips the inner shortcut, encounters the outer shortcut where it requires a node and triggers theBUG_ON().Linux v7.2 and v6.12.105 are affected. The same root remains at the base-commit below and in every supported stable branch checked down to 5.10. It requires
CONFIG_KEYS, but no capability, user namespace or race. A UID/GID 1000 process produced:
CONTROL_BEGINmode=exact uid=1000 gid=1000
CONTROL_CapEff: 0000000000000000
kernel BUG atlib/assoc_array.c:1388!Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI CPU: 0 UID: 1000 PID: 154 Comm: exploit RIP: assoc_array_apply_edit+0x4aa/0x690 Call Trace: __key_link __key_instantiate_and_link __key_create_or_update __do_sys_add_key Kernel panic - not syncing: Fatal exceptionWhen deletion produces a leaf-only node, bypass its preceding shortcut as garbage collection already does. Retire the shortcut and old node together after an RCU grace period; reused leaves keep their references and the deleted leaf is still freed separately.
The exact trigger reached the BUG in 3/3 unmodified v7.2 KASAN boots and completed cleanly in 3/3 fixed boots. Fixed v6.12.105 also passed 3/3. A source reproducer is available privately on request.
Fixes 3cb989501c26 ("Add a generic associative array implementation.")Signed-off-by Daehyeon Ko <[email protected]>Signed-off-by Andrew Morton <[email protected]>Reviewed-by Jarkko Sakkinen <[email protected]>Cc David Howells <[email protected]>Cc <[email protected]>---
lib/assoc_array.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-)lib/assoc_array.c renamed from lib/assoc_array.c~assoc_array-discard-shortcut-when-collapsing-a-leaf-only-node +17
-13@@ -1210,8 +1210,22 @@ found_leaf: goto enomem; edit->new_meta[0 ] =assoc_array_node_to_ptr (new_n0); - new_n0->back_pointer = node->back_pointer; - new_n0->parent_slot = node->parent_slot; +/* A shortcut above a leaf-only node is redundant. Drop it as +* GC does so that a later split can't create two shortcuts in a row. +*/ + ptr = node->back_pointer; +if (assoc_array_ptr_is_shortcut (ptr)) { +struct assoc_array_shortcut *s = +assoc_array_ptr_to_shortcut (ptr); + + new_n0->back_pointer = s->back_pointer; + new_n0->parent_slot = s->parent_slot; + edit->excised_subtree = ptr; + }else { + new_n0->back_pointer = ptr; + new_n0->parent_slot = node->parent_slot; + edit->excised_subtree =assoc_array_node_to_ptr (node); + } new_n0->nr_leaves_on_branch = node->nr_leaves_on_branch; edit->adjust_count_on = new_n0;@@ -1225,21 +1239,15 @@ found_leaf:pr_devel ("collapsed %d,%lu\n" , collapse.slot, new_n0->nr_leaves_on_branch);BUG_ON (collapse.slot != new_n0->nr_leaves_on_branch -1 ); -if (!node->back_pointer) { +if (!new_n0->back_pointer) { edit->set[1 ].ptr = &array->root; - }else if (assoc_array_ptr_is_leaf (node->back_pointer)) { -BUG (); - }else if (assoc_array_ptr_is_node (node->back_pointer)) { -struct assoc_array_node *p = -assoc_array_ptr_to_node (node->back_pointer); - edit->set[1 ].ptr = &p->slots[node->parent_slot]; - }else if (assoc_array_ptr_is_shortcut (node->back_pointer)) { -struct assoc_array_shortcut *s = -assoc_array_ptr_to_shortcut (node->back_pointer); - edit->set[1 ].ptr = &s->next_node;lib/assoc_array.c found_leaf: · line 1252
Quoted 10 lines
lib/assoc_array.c renamed from lib/assoc_array.c~assoc_array-discard-shortcut-when-collapsing-a-leaf-only-node +5
-1+ }else { +struct assoc_array_node *p; + + p =assoc_array_ptr_to_node (new_n0->back_pointer); + edit->set[1 ].ptr = &p->slots[new_n0->parent_slot]; } edit->set[1 ].to =assoc_array_node_to_ptr (new_n0); - edit->excised_subtree =assoc_array_node_to_ptr (node); } }This causes conflicts with upstream. I suspect with Linus' cleanups part of
commit
666539eecdf4db623f5e3c3e55cf9f2dfad24aa4(origin/master, origin/HEAD, master, base)
Merge:141b164bbe18bbab563c5131
Author: Linus Torvalds <[email protected]>
Date: Mon Nov 16 09:35:38 2026 -0800Merge tag 'assoc-array-fixes-v2'
Quoted 8 lines
Clean up
assoc_arraylibrary codeIt's in akpm/mm-hotfixes-unstable, but is this really MM material?
Sounds more like nonmm stuff.
Anyhow, I'll drop this from now from mm-next as I couldn't easily figure out how to resolve this (or if it is still required).
I think you're right, thanks.
I temporarily removed the commits from my next mirror branch.
I'll go through this with time and re-push them later.
Quoted 5 lines
Signature · 4 lines
-- Cheers, David
Br, Jarkko
Quoted 10 lines · On Tue, 17 Nov 2026 16:17:23 +0200 Jarkko Sakkinen <[email protected]> wrote:
Quoted 10 lines
Quoted 1 line
}
This causes conflicts with upstream. I suspect with Linus' cleanups part of
commit
666539eecdf4db623f5e3c3e55cf9f2dfad24aa4(origin/master, origin/HEAD, master, base)
Merge:141b164bbe18bbab563c5131
Author: Linus Torvalds <[email protected]>
Date: Mon Nov 16 09:35:38 2026 -0800
Quoted 7 lines
Quoted 7 lines
Merge tag 'assoc-array-fixes-v2'
Clean up
assoc_arraylibrary codeIt's in akpm/mm-hotfixes-unstable, but is this really MM material?
Sounds more like nonmm stuff.
Crap, I keep putting nonmm stuff into mm-hotfixes. Muscle memory :(
Quoted 8 lines
Quoted 2 lines
Anyhow, I'll drop this from now from mm-next as I couldn't easily figure out how to resolve this (or if it is still required).
I think you're right, thanks.
I temporarily removed the commits from my next mirror branch.
I'll go through this with time and re-push them later.
Thanks. I've removed Daehyeon's patch from mm.git.
Here's the latest version:
From: Daehyeon Ko <[email protected]>
Subject: assoc_array: discard shortcut when collapsing a leaf-only node
Date: Fri, 25 Sep 2026 17:05:48 +0900
assoc_array_delete() can collapse a subtree into a node that contains only leaves while retaining the shortcut that led to it. If that node later fills, all_leaves_cluster_together replaces it with another shortcut. The first shortcut then points directly to the second one.
assoc_array_apply_edit() publishes this topology and propagates branch counts from the new child node. It skips the inner shortcut, encounters the outer shortcut where it requires a node and triggers the BUG_ON().
Linux v7.2 and v6.12.105 are affected. The same root remains at the base-commit below and in every supported stable branch checked down to 5.10. It requires CONFIG_KEYS, but no capability, user namespace or race. A UID/GID 1000 process produced:
CONTROL_BEGIN mode=exact uid=1000 gid=1000
CONTROL_CapEff: 0000000000000000
kernel BUG at lib/assoc_array.c:1388!
Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI CPU: 0 UID: 1000 PID: 154 Comm: exploit RIP: assoc_array_apply_edit+0x4aa/0x690 Call Trace: __key_link __key_instantiate_and_link __key_create_or_update __do_sys_add_key Kernel panic - not syncing: Fatal exception
When deletion produces a leaf-only node, bypass its preceding shortcut as garbage collection already does. Retire the shortcut and old node together after an RCU grace period; reused leaves keep their references and the deleted leaf is still freed separately.
The exact trigger reached the BUG in 3/3 unmodified v7.2 KASAN boots and completed cleanly in 3/3 fixed boots. Fixed v6.12.105 also passed 3/3. A source reproducer is available privately on request.
---
lib/assoc_array.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-)
lib/assoc_array.c renamed from lib/assoc_array.c~assoc_array-discard-shortcut-when-collapsing-a-leaf-only-node +22 -14
@@ -1210,8 +1210,22 @@ found_leaf: goto enomem; edit->new_meta[0 ] =assoc_array_node_to_ptr (new_n0); - new_n0->back_pointer = node->back_pointer; - new_n0->parent_slot = node->parent_slot; +/* A shortcut above a leaf-only node is redundant. Drop it as +* GC does so that a later split can't create two shortcuts in a row. +*/ + ptr = node->back_pointer; +if (assoc_array_ptr_is_shortcut (ptr)) { +struct assoc_array_shortcut *s = +assoc_array_ptr_to_shortcut (ptr); + + new_n0->back_pointer = s->back_pointer; + new_n0->parent_slot = s->parent_slot; + edit->excised_subtree = ptr; + }else { + new_n0->back_pointer = ptr; + new_n0->parent_slot = node->parent_slot; + edit->excised_subtree =assoc_array_node_to_ptr (node); + } new_n0->nr_leaves_on_branch = node->nr_leaves_on_branch; edit->adjust_count_on = new_n0;
@@ -1225,21 +1239,15 @@ found_leaf:pr_devel ("collapsed %d,%lu\n" , collapse.slot, new_n0->nr_leaves_on_branch);BUG_ON (collapse.slot != new_n0->nr_leaves_on_branch -1 ); -if (!node->back_pointer) { +if (!new_n0->back_pointer) { edit->set[1 ].ptr = &array->root; - }else if (assoc_array_ptr_is_leaf (node->back_pointer)) { -BUG (); - }else if (assoc_array_ptr_is_node (node->back_pointer)) { -struct assoc_array_node *p = -assoc_array_ptr_to_node (node->back_pointer); - edit->set[1 ].ptr = &p->slots[node->parent_slot]; - }else if (assoc_array_ptr_is_shortcut (node->back_pointer)) { -struct assoc_array_shortcut *s = -assoc_array_ptr_to_shortcut (node->back_pointer); - edit->set[1 ].ptr = &s->next_node; + }else { +struct assoc_array_node *p; + + p =assoc_array_ptr_to_node (new_n0->back_pointer); + edit->set[1 ].ptr = &p->slots[new_n0->parent_slot]; } edit->set[1 ].to =assoc_array_node_to_ptr (new_n0); - edit->excised_subtree =assoc_array_node_to_ptr (node); } }
_
Quoted 11 lines
Quoted 7 lines
Quoted 1 line
to resolve this (or if it is still required).
I think you're right, thanks.
I temporarily removed the commits from my next mirror branch.
I'll go through this with time and re-push them later.
Thanks. I've removed Daehyeon's patch from mm.git.
Here's the latest version:
Yeah, my problem is oversupply of improvements ATM; not complaining :-) And I just fulfilled my new year's promise to empty my kernel backlog as rootns namespace was the last remaining bullet (draining took 11 months). I guess next year goes scheduling all of this to kernel releases.
Br, Jarkko