From: Liam R. Howlett Date: Wed, 4 Jan 2023 02:37:29 +0000 (-0500) Subject: maple_tree: Add smp_rmb() to dead node detection X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=2f38e34ea80f7c6525f518ff567c29f6e63266a6;p=users%2Fjedix%2Flinux-maple.git maple_tree: Add smp_rmb() to dead node detection Add an smp_rmb() before reading the parent pointer to ensure that anything read from the node prior to the parent pointer hasn't been reordered ahead of this check. The is necessary for RCU mode. Fixes: 54a611b60590 ("Maple Tree: add new data structure") Signed-off-by: Liam R. Howlett --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 17a4fc3b1cc0..27d153dcbe34 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -530,9 +530,10 @@ static inline struct maple_node *mte_parent(const struct maple_enode *enode) */ static inline bool ma_dead_node(const struct maple_node *node) { - struct maple_node *parent = (void *)((unsigned long) - node->parent & ~MAPLE_NODE_MASK); + struct maple_node *parent; + smp_rmb(); + parent = (void *)((unsigned long) node->parent & ~MAPLE_NODE_MASK); return (parent == node); } @@ -547,6 +548,7 @@ static inline bool mte_dead_node(const struct maple_enode *enode) struct maple_node *parent, *node; node = mte_to_node(enode); + smp_rmb(); parent = mte_parent(enode); return (parent == node); }