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 21E63C636CC for ; Tue, 7 Feb 2023 13:02:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231974AbjBGNC1 (ORCPT ); Tue, 7 Feb 2023 08:02:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232026AbjBGNB4 (ORCPT ); Tue, 7 Feb 2023 08:01:56 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14A2A3C16 for ; Tue, 7 Feb 2023 05:01:44 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id A65DFB81986 for ; Tue, 7 Feb 2023 13:01:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF1E7C433EF; Tue, 7 Feb 2023 13:01:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1675774899; bh=KK8sJKIOmClHvWY61f9nqWgtbjl/md6WzbvYW/0qXMc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J8C6RvLtbJIgVWIPVE74tmnlTIaje13g2bWKPceQtSrb0E3GYu8rvzHrnBNhzSXGP blkzilWqqtJa22kCE/rTRs5rXsOZtrbjm5Xj9YeCg+EvnBYsStMVow5H9L2URiSDq8 hpv+Lus1AHRThvCZsrQo3S7vr1yZLbWAC6tmU5Sk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Wei Yang , "Liam R. Howlett" , Andrew Morton , Sasha Levin Subject: [PATCH 6.1 070/208] maple_tree: should get pivots boundary by type Date: Tue, 7 Feb 2023 13:55:24 +0100 Message-Id: <20230207125637.493594695@linuxfoundation.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207125634.292109991@linuxfoundation.org> References: <20230207125634.292109991@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: Wei Yang [ Upstream commit ab6ef70a8b0d314c2160af70b0de984664d675e0 ] We should get pivots boundary by type. Fixes a potential overindexing of mt_pivots[]. Link: https://lkml.kernel.org/r/20221112234308.23823-1-richard.weiyang@gmail.com Fixes: 54a611b60590 ("Maple Tree: add new data structure") Signed-off-by: Wei Yang Reviewed-by: Liam R. Howlett Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin --- lib/maple_tree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index fe21bf276d91..5bfaae60ed8b 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -665,12 +665,13 @@ static inline unsigned long mte_pivot(const struct maple_enode *mn, unsigned char piv) { struct maple_node *node = mte_to_node(mn); + enum maple_type type = mte_node_type(mn); - if (piv >= mt_pivots[piv]) { + if (piv >= mt_pivots[type]) { WARN_ON(1); return 0; } - switch (mte_node_type(mn)) { + switch (type) { case maple_arange_64: return node->ma64.pivot[piv]; case maple_range_64: -- 2.39.0