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 2E99F34572B for ; Mon, 30 Mar 2026 16:34: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=1774888486; cv=pass; b=VQEFS0VQl3Gn76HRgmbccTHMwamO1RNGc42M2BT4jTksFxI+7gYOuOI0CBuUifQXqwjfyZKEAA1N5m9HUwqXYh2cGuzZsUGdhGumH5PwupnV6tS96OXZ56v9iX9ngob7a9BWIcFE9JSoSUA9XqRxuo0W/Py98cuo3OEOsA9hc9o= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774888486; c=relaxed/simple; bh=gIPMDcKIt5+tvqxsCaNcm5IPOR4rkRoaTySBjHkZAks=; h=Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject: MIME-Version:Content-Type; b=r24+Hz8OOf5fnFiG7mgk8I9qhI2oCt7U9ApK5nbn/cNGqP0Q7eZQE8gqpL08Mk5wvgkzq0Lr5kqBV9Ue995+no/xoazLmgPO5glMauitMGzxIsnSe01TLswGBVlhpgZFesluGAGo81Qbu2jVWuNPiXcIVsFuzdOverdT19tdFQI= 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=cvuZJz9D; 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="cvuZJz9D" ARC-Seal: i=1; a=rsa-sha256; t=1774888476; cv=none; d=zohomail.eu; s=zohoarc; b=RBGnu2h6AOo+eklY33bIZCw3G+xw/lAHKPB2Fyi+UXVk0NQyoMygo4wA6/NTk3oNnYlfqUYU13OJTJItXGvwYfVqj7De1ewk3c+aHUKeJhpOhO2PyLCxnMrG9BlKeVkuIZvdKzlTUjvpuf7LZzUk1oBFnFqzeBpeCzCuOwaB6Bg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1774888476; 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=gIPMDcKIt5+tvqxsCaNcm5IPOR4rkRoaTySBjHkZAks=; b=VLpSpp/GclvpRV4sppi7KQhOc1RMZTy1x1KFIaOJD+5DssG081eWTBMaZ+VUHit1s0ZClhn6POGy5uCDjOqbYbA1TeF0to74tIDPBru3b2gZWJU20ueIjtJqHtAaGroR3aiOcSfkB/PmX8Dv+bT64oCzz7uZXj0+yr4lKPsn3UE= 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=1774888476; 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=gIPMDcKIt5+tvqxsCaNcm5IPOR4rkRoaTySBjHkZAks=; b=cvuZJz9Dd59I4Y5fGZJZC67KAWqM01XnlHhvL1lwxTHh6Xy12GyjZhswH4X2FrP+ pnMLCpRsXoAaJpDaqSDuStEUXYmGJLkXMcMHYtp8aI5Ila2w6P9W2QlDJO7F6RZhvGY 177jboyjp/A4XRnVGEzdBLK0UACeRPt/X02Ktp/4= Received: from mail.zoho.com by mx.zoho.eu with SMTP id 1774888476447319.9886967860791; Mon, 30 Mar 2026 18:34:36 +0200 (CEST) Received: from mail.zoho.eu by mx.zoho.eu with SMTP id 1774888475027535.7815700665611; Mon, 30 Mar 2026 18:34:35 +0200 (CEST) Date: Mon, 30 Mar 2026 17:34:35 +0100 From: Josh Law To: Cc: , , , , , Message-ID: <19d3f98d992.f61991a74853.632916888619988017@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 */ Good call. I'll make a V2 soon on that patch. > > 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 */