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 9D9083783CE 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=1774888367; cv=pass; b=OXAwNR40RCHl/tkFjgzACuV8nmQ/tA5zZOAkPH/6vwXvr4stRCpX6A5XbtWJplI/a1wbPFFWTvbthIwkRXT+LP/Tr6AdypGvurnj6cCfU9MaxGXYCWvGghtBfD6+045tqGwxR11ryxcyGb7rCuiuQVNpu3IHN5XWc21GS/3Khn4= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774888367; 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=bJgJy0WfDWh/6WZSWCWdAYL52f219APjMei6nyqGT+HyoT6j4IQyyuABy2LF3utQVsz4T0/1dECwH1LEXV3vBPEHEr/iOSKyxzSPwDztSXZQEKkMTmlVhEMt+LxVxZjB8JwCu0aDOAgQXOBpGcjySS2P5Z4PGL+JRiQt+ieM4Pk= 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=oFJb429L; 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="oFJb429L" ARC-Seal: i=1; a=rsa-sha256; t=1774888355; cv=none; d=zohomail.eu; s=zohoarc; b=Fypk50yqdQuh6tMldY96NkXkyo+rHc+1MuqZqqvoE7xE0ULzbqnwI03Hc1Dop4Gkt7G1vStRRsYUECRn6SgXSpeJLF5DkH4+CMec0Ud61wn0ghqr+lUdhHSzFNGhRhyKrtZAmIDUWDPgxxuYK5wG/Lc+W5VjnEL6tyNzGWMHwPM= 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=PkzMDfBrt+P1LqQCoA0NI305chXz8gXNpZlFTATAT8XyKH7T+V+Qwen5J40lXc6K0xjd87yUfa2fleSmBEB0tz5gPmqC9Z3GOrrorln7YKZ+t4ft8Xsimw2ItiXA6/PR7wUCdIwM0w5ksmDLfpT2ps1W40XtBvpxzqr50j9douc= 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=oFJb429LKR8SvihpRYPxyBwnjTmqRKt7AB0KHQxqc5f0S18kLPVn1PHkXdE06SPy McT1sQCR64r0N4HIpPEz0Bs5R6BGG/USlqkWRbBzBugxfhiJrWv35VbCtKUTqoCxZBf JsTX6qGdZcUnHYCCQGG/0/pKcQ5Rc+M1jWTAhUR0= Received: from mail.zoho.com by mx.zoho.eu with SMTP id 1774888355525711.9762170532266; Mon, 30 Mar 2026 18:32:35 +0200 (CEST) Received: from mail.zoho.eu by mx.zoho.eu with SMTP id 1774888354658307.4142962035569; 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: <19d3f970362.6bc07dc174804.6879885943227337854@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 */