From nobody Mon Apr 6 21:30:59 2026 Received: from sender-of-o57.zoho.eu (sender-of-o57.zoho.eu [136.143.169.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DE603A1CE6 for ; Tue, 17 Mar 2026 22:30:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.169.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773786610; cv=pass; b=rhAHMhRUdWEVYMOMTRvJQ5vUAoT9noj3wHm9NhUxkfb1AiQDseZ+WmezRVo2iEsbLhmL9rHUBfqEW3RZIaEjnzIYnLXrytlwUq+Z/8z56Gdbq+PxwmgHxnLEfyGiZQy217uT3nvWXe4kkF495tRuYx5J5qjF9PjQC4ujGSV/Iz8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773786610; c=relaxed/simple; bh=PkOHgupVLrMB+HAL4rKkvlHrS8NZDDbz9sVynPdnbMo=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=JUMUdIgS271WlhG21s4eVrNQJyxAKnhm3vgEetMnbJRm9B1k8oEtAccbZRkVRIAckdPzHUd39QKHERi+qaAfvzalUYEwfYUByTSEVaRft8aP79sBst3JY9kZosHo3Ax+goG+yOUeqbxHrJWba0f0VyykVdlyh6JsRhrR0QRf7Sw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=objecting.org; spf=pass smtp.mailfrom=objecting.org; dkim=pass (1024-bit key) header.d=objecting.org header.i=objecting@objecting.org header.b=fyc1TcUA; arc=pass smtp.client-ip=136.143.169.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=objecting.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=objecting.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=objecting.org header.i=objecting@objecting.org header.b="fyc1TcUA" ARC-Seal: i=1; a=rsa-sha256; t=1773786569; cv=none; d=zohomail.eu; s=zohoarc; b=LrO8uIjgDsxf2WxX6XYuJaDHUGdDoot9AxxVOR4O6IxHTNsN3d1UPvS2jyxKbyguTP1sfftbjDMZh747aHwtGCDKaswO2aOb6bltzGvqUbNHQnTY7kdqY7TVhtU5llaSj/Y85EJeaKdYcw4dfl0usYYlz4AwGDvU8H+T3bZggKo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1773786569; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=tt4RF9KNtssGzdEl51RiADXjFbSZ7mpR4OrL6sbsIPM=; b=DBeo/PFN56NF5W2j7hD2ud/SKRHxpQ6iAPTAks6SMOsJHZzWR6DpgjTGy57hJUv/ATIi57jiaAnOds1eBl3fC8aVgDOO1iTNMCOVF3umrSIJK/QDF8tb8adwSB4JBv54EtXTytncJBYdzAkgPU4oF+gTRt6qCTk0Bn2ajjtV1+k= ARC-Authentication-Results: i=1; mx.zohomail.eu; dkim=pass header.i=objecting.org; spf=pass smtp.mailfrom=objecting@objecting.org; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1773786569; s=zmail; d=objecting.org; i=objecting@objecting.org; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=tt4RF9KNtssGzdEl51RiADXjFbSZ7mpR4OrL6sbsIPM=; b=fyc1TcUAwIjJbAp+5obQfgkztqugMkuE1xp8ijhx8QH3XDTSG6/p26aWk2pMquq2 C5yl9E9iivYoLCRvyIm8dHFwcztQTosxy4I9bf7xIThsROy9hAbaHnsFvO96GRb/dVm n0eWcIplvI8EKkxRfuX6UPdRE2R6RB+6uaSke9Xo= Received: by mx.zoho.eu with SMTPS id 1773786567108939.6708811150448; Tue, 17 Mar 2026 23:29:27 +0100 (CET) From: Josh Law To: "Liam R . Howlett" , Andrew Morton Cc: Alice Ryhl , Andrew Ballance , Matthew Wilcox , maple-tree@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Josh Law Subject: [PATCH] lib/maple_tree: fix incorrect dead range comparison in mas_topiary_replace() Date: Tue, 17 Mar 2026 22:29:25 +0000 Message-Id: <20260317222925.87929-1-objecting@objecting.org> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" When collecting old nodes for destruction, the dead range check uses tmp_next->index and tmp_next->last, which implicitly dereferences tmp_next[0] rather than the intended dead range. This means children at indices n=3D1 or n=3D2 are compared against the first child's state instead of the replacement range [mas->index, mas->last]. This currently produces correct results by coincidence -- mas_find_child() copies the parent state and mas_descend() preserves index/last, so the values always equal mas->index/last. Fix it to use the canonical source directly, as documented: "Nodes within [index, last] are dead subtrees". Fixes: 54a611b60590 ("Maple Tree: add new data structure") Signed-off-by: Josh Law --- lib/maple_tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 1eaaa5f964e9..64ba117ec254 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -1874,8 +1874,8 @@ static inline void mas_topiary_replace(struct ma_stat= e *mas, if (!mas_find_child(&tmp[i], &tmp_next[n])) break; =20 - if ((tmp_next[n].min >=3D tmp_next->index) && - (tmp_next[n].max <=3D tmp_next->last)) { + if ((tmp_next[n].min >=3D mas->index) && + (tmp_next[n].max <=3D mas->last)) { mat_add(&subtrees, tmp_next[n].node); tmp_next[n].status =3D ma_none; } else { --=20 2.34.1