From nobody Sun Feb 8 06:49:23 2026 Received: from mail-ej1-f65.google.com (mail-ej1-f65.google.com [209.85.218.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48D072BCF68 for ; Tue, 6 Jan 2026 21:08:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767733692; cv=none; b=cjZM7+QU/4T/ItCoqONLMrDyfDFxFntL/DCfKLrkh5KxUPXmJxoKaRifIIkpNBEI1qXE15wAkV2DLWKoP2h2Lxbzw0IDC8eArodaX4xrL2uzyVM6kc0z4wxPXlLtEibjrjQ43DZC8fPrPBueYHt7xquy/xaKBsEUDmj/40GFieY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767733692; c=relaxed/simple; bh=nqLZ0kcjmTIwQv7Ao0i9CZzCQq05XDNsdJgQuDyuKP8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hKf88OOfazMnWt+xsFNZXyk2Py5uRP3WPB47NKFmOEVTgjlkH0Q7hTjQFnDkrMIqxDkdX5yME1jRxMPKXSW0ZdrDQZUvWrGSHrAY4eYq3eTBGWynacULciiO4/OREOy7Ph80bvZgp/GktMRLvh4QJYlQ1HVpzX2eNqT6Rkvbs1s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=delta-utec.com; spf=none smtp.mailfrom=delta-utec.com; dkim=pass (2048-bit key) header.d=delta-utec-com.20230601.gappssmtp.com header.i=@delta-utec-com.20230601.gappssmtp.com header.b=apQZh2X4; arc=none smtp.client-ip=209.85.218.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=delta-utec.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=delta-utec.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=delta-utec-com.20230601.gappssmtp.com header.i=@delta-utec-com.20230601.gappssmtp.com header.b="apQZh2X4" Received: by mail-ej1-f65.google.com with SMTP id a640c23a62f3a-b832c65124cso227150966b.0 for ; Tue, 06 Jan 2026 13:08:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=delta-utec-com.20230601.gappssmtp.com; s=20230601; t=1767733686; x=1768338486; darn=vger.kernel.org; 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=RqqUNyuXR+Yvt4RTDI+UgqNMmHuV3qmM4zjaX+NQuDM=; b=apQZh2X4gNGqAZEqT1/D0DSVDgaSB8Ac/MKCr/WWSVpV4bv3Uqt/7Oer69nRXq7X0P wVLmMnSiMzYFezLwecYTyQELdbUZol/v1eYs3yOqMf1KutdWeiLqQM+sPjtkM3KlP/3O p9cLEywpuBXCrRy5PTw3RTzZnp59sRhX7SSzOiJ/Q+gVtihjTzZZBxtIHD6AvQby8uds 0THhA9WSXYJgvZg6uokrBVOmVsG3HtrUud7q+GdS5M+x6QGfPS/4uUUURwCxnwjka3hA uISzeDYRi4TE+zBOHDy2YHHHH3KF3mJeDI9EP7B3lOWHQ8u4SIt6Vp/dWLkskhOSlYwH MxpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767733686; x=1768338486; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=RqqUNyuXR+Yvt4RTDI+UgqNMmHuV3qmM4zjaX+NQuDM=; b=MGTUfxaPC2jy65iOB6l/GR2WxqY77EpXijOdFVSWxDOLkkxBiFuCoTwJqeYkBa9QXM KAB0/qjxK5ds2EQa3xtxW89wzTL6eTbL4AUQesR4+ilqp1R8j5y/T381K7P8Octn0+sd JpauHlxne20SnIhaapM/Gstmn4uX/MZX32WjHcf9l9li54JliNjiswrQ985d2l3SxFjd TAzTh4Gy9QOJ+Abb1PrtvCBYubd7BbKwRWnx7Yixve/7BxPDQQ/7iMu5hB4ODz1cbz9b ursprjJAex+19COzNFLWsmgfvCYF/w50o/1ujVaxSqWX8YmQusoYhGPS0I3iSQBeGpC2 dRpg== X-Forwarded-Encrypted: i=1; AJvYcCXyT2AdM68vYE3NCFEqALTaLPd6JoveRh8MPpzLOzcxUQ2xeXnuuew8NYou0gYsdzhZNpk2NJjVSstKcQU=@vger.kernel.org X-Gm-Message-State: AOJu0Yz5bFPW9bjHcYfWpWA4AMU150dFQHf8IVW+mCWWKhYPe57rsrEY j5Znowtq2PVi18Y+IpdLGwWViZZrthFRyyBZUO/rhbhpHETx+V/M6pkECiuJD8q8+A== X-Gm-Gg: AY/fxX43zqy68tSYoVa1L9/7+CC4zgHLwvopRWnzOdTlyJmxhpyOXg5goSW1zAKoFjM aO2cTHwrpXyet3m7tROy+dNaJlAuinRKK/xdJ7JM+pbc9OA5Le/JeDVo9LyBZw2hmHRwhvYmo0Y LiiFmob0EiNO4oeZibKYVHDDL4NoJJ4J0+FOD4kjqDHkajCVyxKhBEi95Ne8Iy2YfZ6GdJ6MXax IigWal3keSQKjuTHSHl3QIhKCSDi/WAm0UfKOJBHVffZwyP8H+JHJJ+VOP9SYWD/w4ZBt+khQ4Q 9SMbUPw0tMQUXO/H1ph3C3FvupTFxQIVP41Psrgo5626jrAnn2MZEPzVabV9h1x1JNQvaj+uapo toCUdmXAGHdh0BVibz+fCISW1jl4EAU0nhhA5VaNQIxUy2aF5csBVS74p+DymV0shRH12/9psQI SffhoNAQwOzvYeEBl/o3xpJt7XLnVhxc+aGx8ow+STxv1clfokM+Ik53maCqFVJ8klWuxi+cTvz dpGJ4r6ZvamO/PgzlC+8+fbf9WGr//gS10cWBrUS6xzS5ufDfE= X-Google-Smtp-Source: AGHT+IFUzgn3IMAbiaVWy1jakAZv6/wUacnrCtIooZwJJw+s/NPGplo36j3Vx+jccIDOiDOSIvcdMA== X-Received: by 2002:a17:906:ef0c:b0:b76:d54b:849e with SMTP id a640c23a62f3a-b8444f4ab76mr46587066b.34.1767733686468; Tue, 06 Jan 2026 13:08:06 -0800 (PST) Received: from localhost.localdomain (2001-1c00-3405-d100-fd78-186a-9428-6b97.cable.dynamic.v6.ziggo.nl. [2001:1c00:3405:d100:fd78:186a:9428:6b97]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6507b22c3absm3033836a12.0.2026.01.06.13.08.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jan 2026 13:08:05 -0800 (PST) From: Boudewijn van der Heide To: Liam.Howlett@oracle.com Cc: boudewijn@delta-utec.com, akpm@linux-foundation.org, aliceryhl@google.com, andrewjballance@gmail.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, maple-tree@lists.infradead.org Subject: [PATCH v2] maple_tree: Add lockdep assertion in mas_dup_alloc() Date: Tue, 6 Jan 2026 22:07:57 +0100 Message-ID: <20260106210757.465586-1-boudewijn@delta-utec.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260103165758.74094-1-boudewijn@delta-utec.com> References: <20260103165758.74094-1-boudewijn@delta-utec.com> 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 Content-Type: text/plain; charset="utf-8" The __mt_dup() function requires callers to hold the appropriate write lock when duplicating a maple tree. Without proper locking, concurrent modifications during duplication could access invalid node slots. Add a lockdep assertion to catch such API misuse during development. This is API hardening rather than a bug fix - all in-tree callers already follow the proper locking rules as documented above __mt_dup(). Signed-off-by: Boudewijn van der Heide --- Changes in v2: - Replaced runtime deadnode check with a lockdep assertion v1: https://lore.kernel.org/lkml/20260103165758.74094-1-boudewijn@delta-ute= c.com/ diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 5aa4c9500018..3b4357f16352 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -6248,6 +6248,8 @@ static inline void mas_dup_alloc(struct ma_state *mas= , struct ma_state *new_mas, void __rcu **new_slots; unsigned long val; =20 + lockdep_assert(mt_write_locked(mas->tree)); + /* Allocate memory for child nodes. */ type =3D mte_node_type(mas->node); new_slots =3D ma_slots(new_node, type); -- 2.47.3