From nobody Mon Feb 9 06:32:42 2026 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 D5F7B287508 for ; Sat, 8 Nov 2025 22:20:38 +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=1762640438; cv=none; b=NuGn10cFfePzjVr7X1+CBeldwlNQ9ejKNcD6ZAjo2f87xVLQD4C3DXV2LvgFolXaY7UmH9XNw2x9JCBq7TYRRFncxV9XEsDWkyJtJ3+DEHC6yOtn8AXY4IyOnHtU3sYRT7tyOOXBpUyZP2jmrxRVbdbKNKWKX/j3xoQ2cwdPu4g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762640438; c=relaxed/simple; bh=59w6p5OIO0ukVj/H6iWXGVoWsjSUgZ8nYZ9Xx2PeP8w=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VI7dgzeuPvl7hLjwvbq/Mo2y3BGDmUXEjRjtEwXj4bB/WX5jqoEgNopJSw2CVH8iKuZ6TknK15aoIj1RrZnQ++uy1qlpM940AqFE6O1QI0LHDejce9W2G6fEIroPoBJjeNKLkeZl/XG095Rgzl//NzzCt42r+qNWmATFx1FImrU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Mzyt1Yoy; 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="Mzyt1Yoy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4A42C113D0; Sat, 8 Nov 2025 22:20:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762640438; bh=59w6p5OIO0ukVj/H6iWXGVoWsjSUgZ8nYZ9Xx2PeP8w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Mzyt1Yoyty3gGLNjAe4JO4ekMYedwKfiNvmW76diuxT95rn8ERHxwndRMz6jMw+La h4K7MiqVPo8z9t/w94rg+JkPiyV/EbfyHYGNVFVEi/7cerLZFPkG7/jeE96FZt38uc jsagjnGF23DhNV3tZlVtcs+7LSDElYiwhj8Lua5f24oZVf/e/EhBq+r/MqrLpUuJ3b zGEioEununZPoNK5i3Hgpq6EZGy90NxapNRLv3D24NzaH86UqWt7HQM5yu4BpyhqZX xWEFvtoye8FKd25jgDwgKTxmNWtOD+v+iRYLQ006kdDkWzrgVTiSy0ZKDsQ2qXWmoY 1YPHKY/5hXgNA== Date: Sat, 8 Nov 2025 23:20:34 +0100 From: Alejandro Colomar To: linux-kernel@vger.kernel.org Cc: Alejandro Colomar , Kees Cook , Christopher Bazley , Rasmus Villemoes , Marco Elver , Michal Hocko , Linus Torvalds , Al Viro , Alexander Potapenko , Dmitry Vyukov , Jann Horn , Andrew Morton Subject: [PATCH v2 3/4] kernel: Fix off-by-one benign bugs Message-ID: <781cce547eb29aa82571d0aaa7423fb2a1f59a8c.1762637046.git.alx@kernel.org> X-Mailer: git-send-email 2.51.0 References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" We were wasting a byte due to an off-by-one bug. s[c]nprintf() doesn't write more than $2 bytes including the null byte, so trying to pass 'size-1' there is wasting one byte. This is essentially the same as the previous commit, in a different file. Cc: Marco Elver Cc: Kees Cook Cc: Christopher Bazley Cc: Alexander Potapenko Cc: Dmitry Vyukov Cc: Alexander Potapenko Cc: Jann Horn Cc: Andrew Morton Cc: Linus Torvalds Cc: Rasmus Villemoes Cc: Marco Elver Cc: Michal Hocko Cc: Al Viro Signed-off-by: Alejandro Colomar --- kernel/kcsan/kcsan_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/kcsan/kcsan_test.c b/kernel/kcsan/kcsan_test.c index 219d22857c98..8ef8167be745 100644 --- a/kernel/kcsan/kcsan_test.c +++ b/kernel/kcsan/kcsan_test.c @@ -176,7 +176,7 @@ static bool __report_matches(const struct expect_report= *r) =20 /* Title */ cur =3D expect[0]; - end =3D &expect[0][sizeof(expect[0]) - 1]; + end =3D ARRAY_END(expect[0]); cur +=3D scnprintf(cur, end - cur, "BUG: KCSAN: %s in ", is_assert ? "assert: race" : "data-race"); if (r->access[1].fn) { @@ -200,7 +200,7 @@ static bool __report_matches(const struct expect_report= *r) =20 /* Access 1 */ cur =3D expect[1]; - end =3D &expect[1][sizeof(expect[1]) - 1]; + end =3D ARRAY_END(expect[1]); if (!r->access[1].fn) cur +=3D scnprintf(cur, end - cur, "race at unknown origin, with "); =20 --=20 2.51.0