From mboxrd@z Thu Jan 1 00:00:00 1970 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 9D97E3783D1 for ; Mon, 30 Mar 2026 16:32:44 +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=1774888366; cv=pass; b=g/6/jDksvHvkEf18CpCQ/irDWVV6MXKnoQN+Fcznh/0/cJ1eyW/CkyDC0Q+NLb4tEbKlI7OjawFEyw9PKyMnUJrhfBLK5X3SMGbcyQjhSsF0jARZ0q6x7CvMMazZJI34ZnLkoZHQayxk5v8ycGHL5x+DyNcyy78uO7q9CAbBjnk= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774888366; c=relaxed/simple; bh=TIP+0EBIqv+zcn4wjjuRPO/GqJmaXnK+ghpX5fhj/OM=; h=Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject: MIME-Version:Content-Type; b=n42yLae8uJVwVsNQeCPxw9CjL7c2Nfj+egs4ifIw8a6I+hlK9PV5gRaAhHOVOOwr+/5VxnSi66bXCswqHQ9T3hXrMmuHULKeiQs0GLcixxxVNB2DGJV5SJB+fTpJZwgxg4aAylF8T/yEH59du4SkvcHe3iaqkT8U9sB/FybJMUo= 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=i99/udGg; 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="i99/udGg" ARC-Seal: i=1; a=rsa-sha256; t=1774888355; cv=none; d=zohomail.eu; s=zohoarc; b=JKoHZr958l/XQzeJr/jGD/wl3Gp3hSrTD/TkJ2dhL+Z/GgUOEQZbzmK+YdcDsFRIigSPsdXiH+AfNw5n4EHyU6MvrQhnm1mOTIDBs1saAU8DSO3mC1ACsTed2zgQcx2dxA6J/dD6C1WAtDIdQSHMznrQ/b6SYqjVgijGGXhEms8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1774888355; h=Content-Type: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=TIP+0EBIqv+zcn4wjjuRPO/GqJmaXnK+ghpX5fhj/OM=; b=FBLyIjBtd9OPYK3665cG5J5qtVmEtu8yU5qw62J1TLWC1gm7jZZTo3Rmbr6uLu68R7OwnlwqHhs9l7zMA0mEDn5WZk5ku14G8ddCIRrt0NxehQb8ZG7Y2jG04sxL9QXhO7Hnv48UPsikKtZ9LnMtVmGY8IWE6aPcZmDL/160OCo= 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=1774888355; s=zmail; d=objecting.org; i=objecting@objecting.org; h=Date:Date:From:From:To:To:Cc:Cc:Message-ID:In-Reply-To:References:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=TIP+0EBIqv+zcn4wjjuRPO/GqJmaXnK+ghpX5fhj/OM=; b=i99/udGgem+nDfYDXFuY7L9zq0ewRQQqytOLxOtAYUPZO/DiSIDsB0E+hpbWiltZ xu94PsDGfyFKdMSmddJHsopO2jOjHcjwXXQLUcgnUUb0o2vPiYtpds/kipRTpjHBwIo 0are5cIapXd2qfFXMefqpbGuVoslMufr/hVCQs/A= Received: from mail.zoho.com by mx.zoho.eu with SMTP id 1774888355654700.0796427805757; Mon, 30 Mar 2026 18:32:35 +0200 (CEST) Received: from mail.zoho.eu by mx.zoho.eu with SMTP id 1774888354603417.22188500157756; Mon, 30 Mar 2026 18:32:34 +0200 (CEST) Date: Mon, 30 Mar 2026 17:32:34 +0100 From: Josh Law To: Cc: , , , , , Message-ID: <19d3f97032a.3ff8b69f74802.6803095619902018101@objecting.org> In-Reply-To: <20260330123109.365934af@gandalf.local.home> References: <20260324224940.50508-1-objecting@objecting.org> <20260324224940.50508-3-objecting@objecting.org> <20260330123109.365934af@gandalf.local.home> Subject: Re: [PATCH 2/4] lib/vsprintf: fix OOB write in vbin_printf() when size is zero 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 Importance: Normal User-Agent: Zoho Mail X-Mailer: Zoho Mail ---- On Mon, 30 Mar 2026 17:30:19 +0100 rostedt@goodmis.org wrote ---- > On Tue, 24 Mar 2026 22:49:38 +0000 > Josh Law wrote: > > > 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 > > > --- > > 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) > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 spec); > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0if (str + 1 < end) > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0*str++ =3D '\0'; > > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0else > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0else if (end > (char *)bin_buf) > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0end[-1] =3D '\0'; /* Mus= t be nul terminated */ > > instead of doing a comparison, couldn't we just check size? > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0else if (size) /* do nothing if size is zero */ > > I'm guessing this would be slightly more efficient in the assembly. > > -- Steve > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0} > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0/* skip all alphanumeric pointer suffixes */