From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.alien8.de (mail.alien8.de [65.109.113.108]) (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 3F286477E55 for ; Tue, 20 Jan 2026 19:17:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=65.109.113.108 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768936641; cv=none; b=fhixEpHmAV50sfy9mVjWaSakieWFkS8Pyn1dqAnCvk/wJWJ2JxCII8lnTlY03YLsEMqq826WjxEMbJy7hTzaVoaBGNl2lUxGEJo5mFpjNFZSqa1KKqMTIO59ISQQJSS/1M5UWyWcnazW4s2N/D89FT7AlFeJvBx6ZwL/g/r+eLU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768936641; c=relaxed/simple; bh=ZzEgMRrYI9OZfjs/IgnpsJ4iKt5UodAG9p0uFKVnscw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HNzIiHExEZZ39ETRdbAJoIggq10RsFln4sym0sbP+rWROY+KY/0kaMU92apviU36sh/IksYFg6DOFRlNrMvD2w52iwdmNVM0jVzVNQWG85hdni7svCw5GzzsHukah/0uTUoUQLTZfO5PH6mV73gF0w46Tx0+FLF1C+8rrOiuh40= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alien8.de; spf=pass smtp.mailfrom=alien8.de; dkim=fail (4096-bit key) header.d=alien8.de header.i=@alien8.de header.b=C9UWDM10 reason="signature verification failed"; arc=none smtp.client-ip=65.109.113.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alien8.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=alien8.de Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (4096-bit key) header.d=alien8.de header.i=@alien8.de header.b="C9UWDM10" Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTP id 47CD540E0194; Tue, 20 Jan 2026 19:17:14 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at mail.alien8.de Authentication-Results: mail.alien8.de (amavisd-new); dkim=fail (4096-bit key) reason="fail (body has been altered)" header.d=alien8.de Received: from mail.alien8.de ([127.0.0.1]) by localhost (mail.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id kRARyq9ef5Vo; Tue, 20 Jan 2026 19:17:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=alien8; t=1768936628; bh=mS1Y3Grzxlc3VBIQh1crCiq9ytNRphrilucAANy4wIA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=C9UWDM10YIFeoIGgXfnaJC+/hlqoe8q8JHXyyXTG+4ZD7zhI+bMuEcIGCegvrjPBv 41GkS4ziByU64vcWxLQNN9Kc1NVMe3FoRWaqbf3SgvS4kGSjIHvYX+Wj2AUOuBZf// R/cMErBSyGlc3Z3v1XS40R38863mIAMJW4p7kwVYdqaoVBAGaMwAqm6Wo+2I0ifFNj j6nsuKNOnBGnZYInKc5uN2JvwFai/PuFB9JQPbLuyoftmYaD8glXtx6tVSFths9MZe fqvxaRVNlE6FW3lkMGZgKS+GgDrXsGbHToqTux3Ow3+Pl5tlonMk7+673isXqAymYe B4BvyP2uak6rmkJnMoPiVO/7Oht8yxGxUrhi+HhbYGFNcUflsXmq0g6rC885Z+8Onk q5NS8YLckRFSgUllcKU99v3zmERows9BM1wqhxuP9/zW/5vM/0L6BuJ7f/VVHkpGQO 6a4BcjkbZUrWihaOPCd2gbEZJ7jNziCmNuPTXsbEe7zHnY65X+g1aRCYd8cO554122 4Bnn0UIb5HFOCjM8tZmbrPF6Y20ol8qXLJBu+4qCAAyGKgiRDWaZ2g0C7YZ2/uMbzz pZjIsu23T6yBeSuUnFJ2S6AYhET6lTep80JEHjKdBSQcw9AcQSHLFYhmDUM74CYZRQ g7p0ge+TbrSBpgS0dAVvgGIc= Received: from zn.tnic (pd953023b.dip0.t-ipconnect.de [217.83.2.59]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with UTF8SMTPSA id 42E0440E016A; Tue, 20 Jan 2026 19:17:01 +0000 (UTC) Date: Tue, 20 Jan 2026 20:16:55 +0100 From: Borislav Petkov To: "H. Peter Anvin" , David Desobry Cc: tglx@kernel.org, mingo@redhat.com, dave.hansen@linux.intel.com, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] x86/lib: Fix num_digits() signed overflow for INT_MIN Message-ID: <20260120191655.GDaW_Up2ZOv5AHhbq7@fat_crate.local> References: <20260120094258.41313-1-david.desobry@formalgen.com> <53DB5B87-BA96-44B1-AE1B-9055CB7B9350@zytor.com> <20260120164050.GBaW-wEvzp9WVFj9n9@fat_crate.local> <7C458D74-49E8-4FFE-BD60-74CA3ABFDC6C@zytor.com> 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-Disposition: inline In-Reply-To: <7C458D74-49E8-4FFE-BD60-74CA3ABFDC6C@zytor.com> Content-Transfer-Encoding: quoted-printable On Tue, Jan 20, 2026 at 10:17:09AM -0800, H. Peter Anvin wrote: > Seriously, though. As Linus likes to point out, there is a huge differe= nce > between "this is stupid" and "you are stupid." Yap. > I have said "this is stupid" about my own code more times than I can co= unt. > For good reason.=20 Same here. > To be honest, I didn't even need to see the comment to know that that w= as > probably my code in the first place. I recognized my own style at a gla= nce; > in particular the kind of code I tend to write specifically for the pur= pose > of small as opposed to fast code. I remember writing this code while wa= iting > for a table in a restaurant :) but I don't remember the context. You sent it and I productized it into a patch by saying: Change num_digits() to hpa's division-avoiding, cell-phone-typed version which he went at great lengths and pains to submit on a Saturday evening. > Anyway, I do not mind anyone calling my code stupid, especially if it > actually is. It may or may not have been stupid in the first place, or = the > context might have changed, but it doesn't really matter =E2=80=94 repl= acing stupid > code is how we improve Linux :) Absolutely. We do that all the time and it used to work back then. Hell, = it works fine for CPU numbers but if someone wants to give it INT_MIN... we didn't care about that. We needed it for this gunk: a17bce4d1dce ("x86/boot: Further compress CPUs bootup message") Which reminds me: @David, are you staring at the code or are you using this function somewh= ere and hitting this corner case? Thx. --=20 Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette