From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A052C77B6E for ; Wed, 12 Apr 2023 08:47:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231205AbjDLIrD (ORCPT ); Wed, 12 Apr 2023 04:47:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231239AbjDLIrA (ORCPT ); Wed, 12 Apr 2023 04:47:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F357729B for ; Wed, 12 Apr 2023 01:46:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A7D6B630AE for ; Wed, 12 Apr 2023 08:46:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBFBEC433D2; Wed, 12 Apr 2023 08:46:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1681289161; bh=zZ2ergzcAwS1s1lOESQ1K7PgQ/K8JBGAd+W8O9pH6+k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e2AfAnlsdJ0FBtcrcmys9h2wMYc8qh/3GnqTufSkYMCH39FUYTWNbBEIdXPn7LLqt vH7swRdZEA+yH9ei8N3IrnvVMqqtRPYKMrfh/2IHJeLuLl5VTm7IMIoNdRhPFSGp0+ seDGoMoBVjPStjt+Knvp6/FU6f3eEAzaocQ1HKLc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Stable@vger.kernel.org, Liam Howlett Subject: [PATCH 6.1 159/164] maple_tree: detect dead nodes in mas_start() Date: Wed, 12 Apr 2023 10:34:41 +0200 Message-Id: <20230412082843.387472314@linuxfoundation.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230412082836.695875037@linuxfoundation.org> References: <20230412082836.695875037@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: "Liam R. Howlett" commit a7b92d59c885018cb7bb88539892278e4fd64b29 upstream. When initially starting a search, the root node may already be in the process of being replaced in RCU mode. Detect and restart the walk if this is the case. This is necessary for RCU mode of the maple tree. Link: https://lkml.kernel.org/r/20230227173632.3292573-3-surenb@google.com Cc: Fixes: 54a611b60590 ("Maple Tree: add new data structure") Signed-off-by: Liam Howlett Signed-off-by: Greg Kroah-Hartman --- lib/maple_tree.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -1352,12 +1352,16 @@ static inline struct maple_enode *mas_st mas->max = ULONG_MAX; mas->depth = 0; +retry: root = mas_root(mas); /* Tree with nodes */ if (likely(xa_is_node(root))) { mas->depth = 1; mas->node = mte_safe_root(root); mas->offset = 0; + if (mte_dead_node(mas->node)) + goto retry; + return NULL; }