From patchwork Wed Nov 27 01:27:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13886475 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 620FDD66BA5 for ; Wed, 27 Nov 2024 01:28:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DE0AA6B0089; Tue, 26 Nov 2024 20:28:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D6B8F6B008C; Tue, 26 Nov 2024 20:28:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B6ED96B0092; Tue, 26 Nov 2024 20:28:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 959E66B0089 for ; Tue, 26 Nov 2024 20:28:36 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 147801616B2 for ; Wed, 27 Nov 2024 01:28:36 +0000 (UTC) X-FDA: 82830140106.05.B1E848B Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by imf12.hostedemail.com (Postfix) with ESMTP id C4C4240015 for ; Wed, 27 Nov 2024 01:28:31 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="l/IoSkzZ"; spf=pass (imf12.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.221.47 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732670908; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references:dkim-signature; bh=cTjCN0HxFnKdxfML0LSXNamo6sJegygcfTLnMer1j14=; b=VPsb/riDGzmX5rd3PmWW/XgQtaJ/HtviPB561VF5vnc1P/FUxFbb/y5O+xIFnTZxjxA9NE bm6AfKfhDfi2ZCujg2UpHoLmSlqFvRJIwKaRkTjZoreBTPOGyTDwr6ROQXSr8VdS/uuxes DR2Guh+azgMegbPltadBxJCh5aBG41I= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732670908; a=rsa-sha256; cv=none; b=NJjIuTtQ57RsJWHrE5k++3qbbbWiDlZuTXLrfMCJAKHIzLfWzTOSzqdFIDVbJ5dDG0HIRe P1Lqs5s0wzEiDWjuBYr3SJCFZQ+MoLlrDxRk3TogENXZEm79T7+XjPA24wjs6JZjmpqGKK us14dmsgdwoOeORDqXP40wGuPDxCNCE= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="l/IoSkzZ"; spf=pass (imf12.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.221.47 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-38231f84dccso4312567f8f.1 for ; Tue, 26 Nov 2024 17:28:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732670912; x=1733275712; darn=kvack.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=cTjCN0HxFnKdxfML0LSXNamo6sJegygcfTLnMer1j14=; b=l/IoSkzZUuoA4fqC7qtymIVmPYGF67QH8n26psC0SN5zfVcIHUlqyFlPRZMy3NAC7m qCBL1WF/z5Fd+qe9WEmjR6SOwt89uJ840aVTt3KVAVl8arXRBCYvxbgLHydbMQqAVs3+ ppiVegjgbNSUEBZtMkchdqTAYZTTSQJo6x31N4SqN/wieqz35Ti6h6fUIIrQK9a7FAH8 i3ejE/ycHFj0+tI494SfNX2bzgMXnraCoO8v8xjhy674tfSaMX/6SRJ2r6iT+xts2zpA qa9agzGYW3ARd+OFvM1nD0JaVVTPU2URPVvNger6+Mygoykf90W6zduZ/m72i1jMyqIz xAEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732670912; x=1733275712; h=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=cTjCN0HxFnKdxfML0LSXNamo6sJegygcfTLnMer1j14=; b=FIl/mez+OTvjGObumo5+qUWoFm+7o7ISa5+ptfAZqNCgim6gIWGyP2/9Wi1vcpG/d+ k5xiJ8//BOfNf5dw1n0dHKZJILYYQADzCj83IT6mIJRG+TrFpJkQy7Gvu4XnC3Q6fOOd Vy6KawN8AzZb5aXxVQ0B60WRPd9jKOC23PGdsDMWeurc6gheHqMp2W9PkO7/J4rDewOE dKPMrF1G4AIvsfYZrbt8wjobGtnvoOpzYn6Cgtr+IIFAbK7DkTdsWEtHV8J/9H/bGHMP 0lILA6dsoLo5sOIMNHuXSGyRhPIOK7J2BIRFkiF2n9HNoxn+0+7DL2weYPSbEdiA5Pez 2pxQ== X-Forwarded-Encrypted: i=1; AJvYcCUUs/2Iw0hrZQb6CWyVsPaywUn1LFRm3or5JdtFWt8cZpESjIMg0riIcxtiN7eMyCTq61Ka+e0BfQ==@kvack.org X-Gm-Message-State: AOJu0YywWeDD4keXH1se2ukXLJetGk4ePoiEZtAgVSjDNF5YOJUinBCk g6aed9ZQOFJC06scv0gHd46f2oLciNXSWc0Fw2p9cdIxRLO7zCHH X-Gm-Gg: ASbGncu5K+Px8FLXLwuvahP+WYiv2XCPhaoixtxIABFTyieFNghz8JtUUH2ldSNRTa3 SiOynzcnqUNEKht0cZavVyLhDC80ZPI2t/YIbOIvl8EivLYxKoAgyh7wtLy5XIta+bPvwd7wPra 4lHuuDpQPI3ddoaUfb0Dxm/xAzmqGTipWS4J5ZQdcn741FVCn44zZPFSwN9IiexOA6bUxkY85p0 7UDJk7W1v0715GGtSHLn9XVTvA7OxxSfI3DlLz7nW5GeDmjHg== X-Google-Smtp-Source: AGHT+IHeIlv6DIn7C3nJzI4w7AVDqBcGxbvBAXJZKnCiXNHUm7UatNfs+UkxA+pdXpRKbOr/kGmRsA== X-Received: by 2002:a5d:5f43:0:b0:374:c847:852 with SMTP id ffacd0b85a97d-385c6ec0d52mr663373f8f.29.1732670912523; Tue, 26 Nov 2024 17:28:32 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d01d3a2345sm5590189a12.2.2024.11.26.17.28.30 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Nov 2024 17:28:31 -0800 (PST) From: Wei Yang To: akpm@linux-foundation.org, Liam.Howlett@oracle.com Cc: maple-tree@lists.infradead.org, linux-mm@kvack.org, Wei Yang , "Liam R . Howlett" , Sidhartha Kumar , Lorenzo Stoakes Subject: [PATCH 2/7] maple_tree: validate we won't split on NULL Date: Wed, 27 Nov 2024 01:27:48 +0000 Message-Id: <20241127012753.3393-3-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20241127012753.3393-1-richard.weiyang@gmail.com> References: <20241127012753.3393-1-richard.weiyang@gmail.com> X-Rspamd-Queue-Id: C4C4240015 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: joete5a67jyg1bg7gw3wpkkpphektkrp X-HE-Tag: 1732670911-754454 X-HE-Meta: U2FsdGVkX19IOZWJEsjLxoIoy/UoRc0aFgbp/y258mnz2G1gGfmdJ+xyhpUMLKCcnF42+zzUX2vGxIWaBKb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H+4W2Tkp+km+1BJfhJi740pDij707Bmxpke76zYw+cm6zhOuE/7Iw58xNPDcAsDdwvCGhAJwiX/S0aI6DzGsewFoAph9Tv7ZPLpYJ4FnCW2Mqm9VVZ4x+iq2pfyAHfik0sG2gORXShBXfBbAdqWvRGVFoSLXaO4bepp6C4IVr+frNS2UVyskdPrtbbgU6YV9UTfI4DkDfi+9/s/X8BqLbLWYylJw64GYLzXsm6ep725/3X/q3nemoFTFZEsysvCPeyD7c6Xo3W7nf+4ujHrfo+011r80OAKvI7Gw/TrBeqBWEEOPA0fnIFa0J/2eKZ540BLCVgPz6IArjVdMpU+e6 X-Bogosity: Ham, tests=bogofilter, spamicity=0.004853, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: If this is not the right most node, we don't expect its last slot to be NULL. Let's validate this. Signed-off-by: Wei Yang CC: Liam R. Howlett CC: Sidhartha Kumar CC: Lorenzo Stoakes --- lib/maple_tree.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 98692704d773..2a00441130ee 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -7522,6 +7522,12 @@ static void mt_validate_nulls(struct maple_tree *mt) MT_BUG_ON(mt, !last && !entry); last = entry; if (offset == mas_data_end(&mas)) { + if ((mas.max != ULONG_MAX) && !entry) { + pr_err("Last slot %p end with NULL\n", + mas_mn(&mas)); + MT_BUG_ON(mas.tree, 1); + } + mas_next_node(&mas, mas_mn(&mas), ULONG_MAX); if (mas_is_overflow(&mas)) return;