From nobody Tue Dec 16 23:58:44 2025 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 7CBCA26056D for ; Wed, 10 Dec 2025 22:46:49 +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=1765406809; cv=none; b=nSYz1rD9B/AGYrI0W7/2t1fTqO3fzwEsgR+BQFsGUNiPOOQtNbCeZI0m+tFIr13Z4b6JQQFqE+ZejFdYQB27o3rspfs7Se9dtdatPVGDHSgunnj1864sp+lezDqmOTYbiJVSehxkz0Aq3BAxPIOZfRFaxjYcF/nA1ym2ZBe+Pzg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765406809; 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=Fc03TNmhlbF3T1SoTDOSWwoMMQsn7HlRcQgn4g5vclF9JRsG/zdz6m4DK04kgTryqm77n5VtLnIrofd2DDApMnj91Mpf0jUhm1rUv0Pu/VDKsArHymz7IhXHiV4D2dGxsRcsxvej+/m2tE3NDSqTtdBg6O2DEg4tpyhUkuXmIUc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uFWUzHtI; 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="uFWUzHtI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8716C4CEF1; Wed, 10 Dec 2025 22:46:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1765406808; bh=59w6p5OIO0ukVj/H6iWXGVoWsjSUgZ8nYZ9Xx2PeP8w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uFWUzHtIKq0MdPLcgSoXxbDdivKFxFKV1hp7nbScDSw1btmYrugRIksf/Ptp01M6P MH/3J8wMmqP/NL0xrOyoLEBzAV5DQ+QdLkUn0SgOnVnNi3aQGTOQ/EQYFE2ZfVY8H1 ovFvbVl0+hw+plYIJRA4vCwoRvqijDh/qoAduzz2EuOgrrpmdesVezoJqdTpp1seyY A9avXq9Rh6ynPSwej7BJ6us7vJZ7qwBKNlTLq/Ni8QWAJ6YPTO7fHRDdngC+frYVyg uUCHwHPv+9I5WsIRW5WKvWB5Pgbsi9FqrOpZScgd/Vq+4SSF7iFhzE6nvTqCjhd/bb jnVTodwRHhf0w== Date: Wed, 10 Dec 2025 23:46:44 +0100 From: Alejandro Colomar To: linux-kernel@vger.kernel.org, linux-mm@kvack.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 , "Maciej W. Rozycki" Subject: [PATCH v5 3/4] kernel: Fix off-by-one benign bugs Message-ID: 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