From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 67D8931D38F for ; Wed, 10 Dec 2025 23:18:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765408739; cv=none; b=VCUUiw3I4LDMpeyLrL62X6lA0n8YV7bsNZHS2aiPXUm2hYrAEE8Gn5bdNM1VUDZGN09aA3IQLmkdeQ7DyVvVUsAjV3KbqvJvWs5iGuAnjYHtE6T0UBBsGEgeXf9Nxbdk85rXVohnilOkGRJNmj9rin4qWuiXJkMz0oe/UKqC6Co= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765408739; c=relaxed/simple; bh=ry7JUujyO9LI43NEsCg0bF7+NPHcsipy6vmhKC/aO+8=; h=Date:From:To:CC:Subject:In-Reply-To:References:Message-ID: MIME-Version:Content-Type; b=NxgFC5HwnVPRLt9CDmguKpuHtBbgTS2hXzssT2819uJoCFG4vYF4T4lRRpYNaeBB9+vBhk3L6em2ZlDT6NBzB7PiFfvBxT59A30ITuyZEqgUlKZD4cnO42dDyt6y+jddnPuTsk7T2n9MrT26b5J//urs/hkCOZGbE2upmJZFzAU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pmj/n4uM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pmj/n4uM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74D2EC4CEF1; Wed, 10 Dec 2025 23:18:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1765408739; bh=ry7JUujyO9LI43NEsCg0bF7+NPHcsipy6vmhKC/aO+8=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=pmj/n4uMG83Rk1lGX1UQyVXWINuA7QOIoWzjKBX4pmZv99iaCM9HpMWRaZy4J2pFq FF261DMdmW+pse0VTwj5J+CzC7LZDrrrXmazAdNH69PRx4fqCyqjbs1ZxyImnj887l R5SMpUKxQy+/bSvVxnhFJFSb7we3atpuce1bk8DWf4YNUZNTJUbvVMgz2loHcf1tVJ KzxsZ4Za+qGlAjrvYzFqY7Sf376o/CylxALpGb46YPd6pJZoDXoQco5k2pM96ix2mk F/Ypflid2lOsrCpyLN1tdSzlSe4Fg/b5P6n06n9ogmZ1Q4e3NJ6klPrSw0OkPhnGls fAKfiaDuNus0w== Date: Thu, 11 Dec 2025 08:18:56 +0900 From: Kees Cook To: Alejandro Colomar , linux-kernel@vger.kernel.org, linux-mm@kvack.org CC: Christopher Bazley , Rasmus Villemoes , Marco Elver , Michal Hocko , Linus Torvalds , Al Viro , Alexander Potapenko , Dmitry Vyukov , Jann Horn , Andrew Morton , "Maciej W. Rozycki" Subject: Re: [PATCH v5 4/4] mm: Use ARRAY_END() instead of open-coding it User-Agent: K-9 Mail for Android In-Reply-To: References: Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On December 11, 2025 7:46:49 AM GMT+09:00, Alejandro Colomar wrote: >Cc: Kees Cook >Cc: Linus Torvalds >Signed-off-by: Alejandro Colomar Hm, this seems to be missing a commit log body? Are there other open-coded instances that could be replaced? This seems li= ke a great task for a coccinelle script=2E -Kees >--- > mm/kmemleak=2Ec | 2 +- > mm/memcontrol-v1=2Ec | 4 ++-- > 2 files changed, 3 insertions(+), 3 deletions(-) > >diff --git a/mm/kmemleak=2Ec b/mm/kmemleak=2Ec >index 1ac56ceb29b6=2E=2Efe33f2edfe07 100644 >--- a/mm/kmemleak=2Ec >+++ b/mm/kmemleak=2Ec >@@ -510,7 +510,7 @@ static void mem_pool_free(struct kmemleak_object *obj= ect) > { > unsigned long flags; >=20 >- if (object < mem_pool || object >=3D mem_pool + ARRAY_SIZE(mem_pool)) { >+ if (object < mem_pool || object >=3D ARRAY_END(mem_pool)) { > kmem_cache_free(object_cache, object); > return; > } >diff --git a/mm/memcontrol-v1=2Ec b/mm/memcontrol-v1=2Ec >index 6eed14bff742=2E=2Eb2f37bd939fa 100644 >--- a/mm/memcontrol-v1=2Ec >+++ b/mm/memcontrol-v1=2Ec >@@ -1794,7 +1794,7 @@ static int memcg_numa_stat_show(struct seq_file *m,= void *v) >=20 > mem_cgroup_flush_stats(memcg); >=20 >- for (stat =3D stats; stat < stats + ARRAY_SIZE(stats); stat++) { >+ for (stat =3D stats; stat < ARRAY_END(stats); stat++) { > seq_printf(m, "%s=3D%lu", stat->name, > mem_cgroup_nr_lru_pages(memcg, stat->lru_mask, > false)); >@@ -1805,7 +1805,7 @@ static int memcg_numa_stat_show(struct seq_file *m,= void *v) > seq_putc(m, '\n'); > } >=20 >- for (stat =3D stats; stat < stats + ARRAY_SIZE(stats); stat++) { >+ for (stat =3D stats; stat < ARRAY_END(stats); stat++) { >=20 > seq_printf(m, "hierarchical_%s=3D%lu", stat->name, > mem_cgroup_nr_lru_pages(memcg, stat->lru_mask, --=20 Kees Cook