* + xarray-clear-the-new-heads-parent-before-freeing-the-old-head.patch added to mm-hotfixes-unstable branch
@ 2026-10-30 15:46 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-10-30 15:46 UTC (permalink / raw)
To: mm-commits, willy, nickolai, akpm
The patch titled
Subject: xarray: clear the new head's parent before freeing the old head
has been added to the -mm mm-hotfixes-unstable branch. Its filename is
xarray-clear-the-new-heads-parent-before-freeing-the-old-head.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/xarray-clear-the-new-heads-parent-before-freeing-the-old-head.patch
This patch will later appear in the mm-hotfixes-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Nickolai Zeldovich <nickolai@csail.mit.edu>
Subject: xarray: clear the new head's parent before freeing the old head
Date: Tue, 27 Oct 2026 15:20:14 -0400
xas_shrink() passes the old head to xa_node_free(), which queues it with
call_rcu(), before it clears the new head's parent pointer. A lockless
walker that loads the new head after the grace period has started can
still climb from it into the old head through xa_parent(), as xas_find(),
xas_find_marked(), xas_next() and xas_prev() do when they step past the
end of a node, and read the old head after it is freed.
Clear the parent pointer before freeing the old head, as
radix_tree_shrink() does.
With a delay injected after xa_node_free() in xas_shrink(), KASAN reports
a slab-use-after-free in the walker; with this patch it does not.
Link: https://lore.kernel.org/20261027192014.844878-1-nickolai@csail.mit.edu
Fixes: 58d6ea3085f2 ("xarray: Add XArray unconditional store operations")
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
---
lib/xarray.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/lib/xarray.c~xarray-clear-the-new-heads-parent-before-freeing-the-old-head
+++ a/lib/xarray.c
@@ -471,11 +471,12 @@ static void xas_shrink(struct xa_state *
if (!xa_is_node(entry))
RCU_INIT_POINTER(node->slots[0], XA_RETRY_ENTRY);
xas_update(xas, node);
+ if (xa_is_node(entry))
+ xa_to_node(entry)->parent = NULL;
xa_node_free(node);
if (!xa_is_node(entry))
break;
node = xa_to_node(entry);
- node->parent = NULL;
}
}
_
Patches currently in -mm which might be from nickolai@csail.mit.edu are
xarray-clear-the-new-heads-parent-before-freeing-the-old-head.patch
panic-zero-the-dynamically-allocated-taint-buffer.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-30 15:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-30 15:46 + xarray-clear-the-new-heads-parent-before-freeing-the-old-head.patch added to mm-hotfixes-unstable branch Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.