Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp723854rwb; Wed, 26 Jul 2023 01:34:04 -0700 (PDT) X-Google-Smtp-Source: APBJJlG0RKdnqwyUBzR6G+NxTavgb+7qxg8hwaQMvU3zLP3pGmdfnwsA2oyqp1qrZYlFd8B4yHSm X-Received: by 2002:a05:6358:429e:b0:131:b4c:b876 with SMTP id s30-20020a056358429e00b001310b4cb876mr1100414rwc.1.1690360443739; Wed, 26 Jul 2023 01:34:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690360443; cv=none; d=google.com; s=arc-20160816; b=ZCyTIDwLRlEso0REZyOT95kqREBOrW7kIC1Q3StU8ZIntkH5ULA1VUhUAx61LLMywm i6xWmHNDF/3w5SzFCujCYVWkiwD5a4xBDArB/fZQYxXMAfctTSjBPEvV+TQjdd0/+6jf 8zNevSrp/tXgJvrJHRxPbT/Rak+YMhRc9rujASygCd/dYIrMflKeh6ON0zQlXgfmKGkb OXyGXHdwG0I/XFuSHUml28gdn4iIDVXlmnJQoDUs3tPa1WHR38GuM2A+7mtDUo0kxr6O PKTHSU8J6A1CzeHsCgO18yCf7+ATvgop/YSbC9spJItMciIEmVbROncZilzBuCa69c5N ICow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CBWhUMSjOCubXY+PC9p9DMz2fuhl5l7G2DCnpXKXi44=; fh=83ed9mee+o5Uq0I46ZSfSA+aUr2+chEOwR4qsJ7tckA=; b=D1ma6v5qtafvoPlf59zvnhRK3dGdlnO3SS4G3gUbaHrjsp8ZpU0G50c8O4D/acuTF9 7WGwfndX794aNNtq2mBbYDezdtMrPFVc1eRCaUzQBgYHw2TDPJx5h1MFFr/r/A95ileJ yG79MESAsqqbKDaqc3wB5rXPmKIXGsZ1e48dntBlcbBzCShJRmxRhHUB4vRBPDXV//5B m0GKrCY/eErhnIeUgPw4NGLm6kkv5tCSQJSaj9C45+0p/64WH/kJxzkWDd6tuLkGgBEc ZKWGWbz7TJuIfITt3kTJ5E8RefLCOxjm0L+6sP3UjqNwFHW6Ldi5zRVsoBnsr1TXwJRm +UYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="RXB/luIX"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u190-20020a6385c7000000b00563dbd28951si1530626pgd.423.2023.07.26.01.33.48; Wed, 26 Jul 2023 01:34:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="RXB/luIX"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233128AbjGZIWy (ORCPT + 99 others); Wed, 26 Jul 2023 04:22:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232950AbjGZIWL (ORCPT ); Wed, 26 Jul 2023 04:22:11 -0400 Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C9844C13 for ; Wed, 26 Jul 2023 01:10:02 -0700 (PDT) Received: by mail-ot1-x333.google.com with SMTP id 46e09a7af769-6b9c434fe75so5317097a34.0 for ; Wed, 26 Jul 2023 01:10:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690359001; x=1690963801; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CBWhUMSjOCubXY+PC9p9DMz2fuhl5l7G2DCnpXKXi44=; b=RXB/luIXuwGwXY6rqH5frdTWpd6w9LTeUKn410+nFpUsNaJ23LLavNegSawCjRQMgP olOEFVPrbE0jXarH32neIg973IiVObAB37RV1Je7V6W6onAegs08yBYLMxWW4j27U03B hRTru99Vp9e2P5P7I1yZCu3hCHl6eDVSN3p1/mQN5OYlpRyyeZZmDVUBbwGJZaY20H4v +Q7yDQfwWSqQdd6nsa9TBmh2ADavZejwsPqQ3zGHYBIy3WOGxQ8Wc0Mt+U6dEDUIIa22 6tz1eEu1O31YEPOltcFul+d3p84JJlOgzZQar6fOQqG8Qibwy5TwOeiRi3r4Mzrf/Aam nPTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690359001; x=1690963801; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CBWhUMSjOCubXY+PC9p9DMz2fuhl5l7G2DCnpXKXi44=; b=bfVoGm7k8Cpk1pXl1ecNlOjAsPts8ptA9pNKiw6TfHPYoUPh9Q16EDe4m7kJEyzlCo rktko8wfJjPQ4BsadNqPOxSEtwCzUB6mWyT3Auo1q8nsCpv8dRwY4PWxCXoJkuu08ZDo djdqTOU1SmBzYWJvui+jfO5nza8mGSHZD46iEqHhXx+IUc8s5KWMCUqS71YaUXVMumlL a8+zPHgjJa+p5deX62i7A54bnyu2JwIwHW9D4zrr2HmnLoUSrqTFTVaXSpZUPhJSve5N I2IfAS0MAi0r0tVlhs61ChsfVwtTLW8Ju+/yPazm5GkbEdukRDEtyW2sl5Fog3+nMBvr UfsA== X-Gm-Message-State: ABy/qLYA39rEC1VVVfMWouznzgAmX0gOTFxI/6fbHxhwMjXRgbe/RxQ1 lZyAiI89o/6jEVs/E1KIU+Zwag== X-Received: by 2002:a05:6830:1e39:b0:6b9:ae94:c664 with SMTP id t25-20020a0568301e3900b006b9ae94c664mr1651229otr.13.1690359001292; Wed, 26 Jul 2023 01:10:01 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id gc17-20020a17090b311100b002680b2d2ab6sm756540pjb.19.2023.07.26.01.09.55 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 26 Jul 2023 01:10:00 -0700 (PDT) From: Peng Zhang To: Liam.Howlett@oracle.com, corbet@lwn.net, akpm@linux-foundation.org, willy@infradead.org, brauner@kernel.org, surenb@google.com, michael.christie@oracle.com, peterz@infradead.org, mathieu.desnoyers@efficios.com, npiggin@gmail.com, avagin@gmail.com Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Peng Zhang Subject: [PATCH 02/11] maple_tree: Validate MAPLE_ENODE and ma_nonleaf_data_end() Date: Wed, 26 Jul 2023 16:09:07 +0800 Message-Id: <20230726080916.17454-3-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230726080916.17454-1-zhangpeng.00@bytedance.com> References: <20230726080916.17454-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Updated mt_validate() to validate MAPLE_ENODE and ma_nonleaf_data_end(). Signed-off-by: Peng Zhang --- lib/maple_tree.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 98e4fdf6f4b9..e0e9a87bdb43 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -7130,6 +7130,11 @@ static void mas_validate_child_slot(struct ma_state *mas) MT_BUG_ON(mas->tree, 1); } + if (!slot_is_mte((unsigned long)child)) { + pr_err("Slot is not mte %p[%u]\n", mas_mn(mas), i); + MT_BUG_ON(mas->tree, 1); + } + if (mte_parent_slot(child) != i) { pr_err("Slot error at %p[%u]: child %p has pslot %u\n", mas_mn(mas), i, mte_to_node(child), @@ -7200,6 +7205,13 @@ static void mas_validate_limits(struct ma_state *mas) MT_BUG_ON(mas->tree, 1); } + if (!mte_is_leaf(mas->node) && + mas_data_end(mas) != mte_nonleaf_data_end(mas->tree, mas->node)) { + pr_err("node:%p mas_data_end() != mte_nonleaf_data_end()\n", + mas_mn(mas)); + MT_BUG_ON(mas->tree, 1); + } + for (i += 1; i < mt_slots[type]; i++) { void *entry = mas_slot(mas, slots, i); -- 2.20.1