From nobody Fri Apr 3 04:37:59 2026 Received: from sender-of-o57.zoho.eu (sender-of-o57.zoho.eu [136.143.169.57]) (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 7501C3C5DBB for ; Tue, 24 Mar 2026 22:50:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.169.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774392624; cv=pass; b=tXL0LQ23qNIPHIjzqrro02XBaUn1V5LpTHB3ya9PHzsulyH/1E8bGp52qtEH1dOdm8EPMSFCXyhfk1RIzVYO87NfyK09d+WS1L7aj3PA9LZ+6DoXoXBTz3flX7PZQJto2pY9b5RuqwVNgrlCR+MI3r2m0M3xLUTuMtk2ROfNIck= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774392624; c=relaxed/simple; bh=/jX0D+33NUHGgBEM2k/7Y9W0NyRLJ4LXot3399eNdE0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uE2BN66Ek40G5euAwVW07+Hj3wXcD/2au4UOVa+T4Eg1k+/3uvaTqI1Fv+Xrw83Ea2br1sMcD/xBnurMW3Tymt7RHIgBfNhFos/4fMtBDW0OSB+XOsXK1vj/vxh6YW6omdiMP+X5s3Nc5ZA12FdIntALH5AC5UAPsOm1tDJlOmQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=objecting.org; spf=pass smtp.mailfrom=objecting.org; dkim=pass (1024-bit key) header.d=objecting.org header.i=objecting@objecting.org header.b=eHxEnFMm; arc=pass smtp.client-ip=136.143.169.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=objecting.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=objecting.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=objecting.org header.i=objecting@objecting.org header.b="eHxEnFMm" ARC-Seal: i=1; a=rsa-sha256; t=1774392585; cv=none; d=zohomail.eu; s=zohoarc; b=IISazmoMRfKdJt56DNqX30HA4dFnmK1gV8OXrbrSYFN22xNNnf9wpotz5gZTvuVAU3lPSK+lcKLfC0/l1dAFjnNvDdlYa/CMsmB2ZkUQaGkT/hpI5gQ8zNvpGnm2gavAw5KB558QypNUks0inq9QGuKPaEJv8R4InDd/URXAfT0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1774392585; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=4lvJu8mTYc831qvqwbt15ZPA0/Qf6sOrkpF7oTDTbRE=; b=XBvtg4lJo8wR2xTA3VBjFo8UmG9kibS2F19Lio1QA0NwfKOUavQ0G54GrkCdkD+pgFKVOCNxOmvlI92ViVahFE7xmssEnuET7ZP7jraV7bgN20HpPAanBott5jmzpz84AtuwOBBGWtonyLqFWU03bWbE0nyUBSXbT1cMSDlbvDE= ARC-Authentication-Results: i=1; mx.zohomail.eu; dkim=pass header.i=objecting.org; spf=pass smtp.mailfrom=objecting@objecting.org; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1774392585; s=zmail; d=objecting.org; i=objecting@objecting.org; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=4lvJu8mTYc831qvqwbt15ZPA0/Qf6sOrkpF7oTDTbRE=; b=eHxEnFMm6TtI6azRYivrQ3+dtBf0fvYpoIvUQ2k41HlkqI8QVhyWfS7FofP3Y+Jk 32sx1w7UM5mosbABP8UsAZoZTgc4JWpVYYo4tS+0Snf4h/skOUGAWrah4RfKTEfd7Lx fpXBS9tZ6cnSg99lNqtJP8I/N9X5xFLfjff3hPR4= Received: by mx.zoho.eu with SMTPS id 1774392583116445.98965947533577; Tue, 24 Mar 2026 23:49:43 +0100 (CET) From: Josh Law To: Petr Mladek , Steven Rostedt Cc: Andy Shevchenko , Rasmus Villemoes , Sergey Senozhatsky , Andrew Morton , Josh Law , linux-kernel@vger.kernel.org Subject: [PATCH 2/4] lib/vsprintf: fix OOB write in vbin_printf() when size is zero Date: Tue, 24 Mar 2026 22:49:38 +0000 Message-Id: <20260324224940.50508-3-objecting@objecting.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260324224940.50508-1-objecting@objecting.org> References: <20260324224940.50508-1-objecting@objecting.org> 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 X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" When vbin_printf() is called with size=3D=3D0, end equals bin_buf and the else branch writes end[-1], which is one byte before the buffer. Guard the write so it only happens when the buffer is non-empty. Signed-off-by: Josh Law Reviewed-by: Petr Mladek --- lib/vsprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 7898fb998b21..72fbfe181076 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -3234,7 +3234,7 @@ int vbin_printf(u32 *bin_buf, size_t size, const char= *fmt_str, va_list args) spec); if (str + 1 < end) *str++ =3D '\0'; - else + else if (end > (char *)bin_buf) end[-1] =3D '\0'; /* Must be nul terminated */ } /* skip all alphanumeric pointer suffixes */ --=20 2.34.1