From: Liam R. Howlett Date: Tue, 11 Apr 2023 15:10:43 +0000 (-0400) Subject: maple_tree: fix potential rcu issue X-Git-Tag: v6.2.11~12 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d478ff0ca89f06c36d9fe45654ddf76d768ac8e7;p=thirdparty%2Fkernel%2Fstable.git maple_tree: fix potential rcu issue commit 65be6f058b0eba98dc6c6f197ea9f62c9b6a519f upstream. Ensure the node isn't dead after reading the node end. Link: https://lkml.kernel.org/r/20230120162650.984577-3-Liam.Howlett@oracle.com Cc: Fixes: 54a611b60590 ("Maple Tree: add new data structure") Signed-off-by: Liam R. Howlett Signed-off-by: Greg Kroah-Hartman --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 0b8353c6ee8ed..e0a76f6368e4e 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4655,13 +4655,13 @@ static inline void *mas_next_nentry(struct ma_state *mas, pivots = ma_pivots(node, type); slots = ma_slots(node, type); mas->index = mas_safe_min(mas, pivots, mas->offset); + count = ma_data_end(node, type, pivots, mas->max); if (ma_dead_node(node)) return NULL; if (mas->index > max) return NULL; - count = ma_data_end(node, type, pivots, mas->max); if (mas->offset > count) return NULL;