From nobody Tue Dec 16 18:28:10 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 7430A304BA8 for ; Thu, 11 Dec 2025 10:44:05 +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=1765449845; cv=none; b=PSSj6ziU82OkVfDjfP6HiBCIAUXJ6zJUI0CxCm/uR/H/+U7Q3ZqYC9Luq60mCTBGrDXKP7+CptlBBtX2DFPrH7yJvrwjyuGgWY6WarlAp2dujrkA/pbkFeDQKG0vw8Y5jS713sxgiKnQ1Vdzdsr7EOJt45GczTM/ArV6m3vXqq4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765449845; 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=Z6IGHIHTbHD0JKGBf2GMJ+0tkHhv4zJ1ExcrmJeMJTikalKagR6k1LTmPBvmSedddxmbdvSAvwgacasxcDP/SAbnuI0vvLGJ82tO9UEGr7qmBAkt2yMyvapHnYrzkbojcvEDdsZc3t4I/nIaRTvqJX9y0Ae7aOYL/olTmDFzhJM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pFRMtGnp; 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="pFRMtGnp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB4F1C113D0; Thu, 11 Dec 2025 10:44:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1765449844; bh=59w6p5OIO0ukVj/H6iWXGVoWsjSUgZ8nYZ9Xx2PeP8w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pFRMtGnp9RaLnA9mlaRXpbbMcuS+xYuOfR1yP6HZrKcoc1/kbsmlAEIHzj+qjL/Ou U53bywg7t70e7VKIw/XqRSiv+S0O2zunvOs/eXkSnpZF0g8gt4Lae1hMLpmx4ywwNm mdTyld7hpKguk9olXKkALV9XX78jXdmALbMUCNzijnYtPlOKMlF/tlVhCFoeEoB+2K +PHtP9fdooYv+bVZMN46dtP3AHSa0okswCjS58gPniD6jvbPLIsii2pj0QLg7Px5cn KG/x74sgOdKag8Q6WbRyvmpuKMYgg8OSY4ykcYEM3Y4uobRBYPvGW/qDk8wxab+d+a gzpaE4JsJytvw== Date: Thu, 11 Dec 2025 11:44:00 +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 v6 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