lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260121095405.58fa513f@pumpkin>
Date: Wed, 21 Jan 2026 09:54:05 +0000
From: David Laight <david.laight.linux@...il.com>
To: David Desobry <david.desobry@...malgen.com>
Cc: "H. Peter Anvin" <hpa@...or.com>, tglx@...nel.org, mingo@...hat.com,
 bp@...en8.de, dave.hansen@...ux.intel.com, x86@...nel.org,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] x86/lib: Optimize num_digits() and fix INT_MIN
 overflow

On Wed, 21 Jan 2026 01:04:39 +0100
David Desobry <david.desobry@...malgen.com> wrote:

> On 1/21/26 00:49, H. Peter Anvin wrote:
..
> Actually, the V3 change: 	
> if (val < 0) {
> -		d++;
> -		val = -val;
> +		d = 1;
> +		v = -val;
> +	} else {
> +		d = 0;
> +		v = val;
>   	}
> reintroduced the undefined behavior for val == INT_MIN.
> So this V3 version is incorrect.

Change to:
	v = -(val + 1); v++;
The compiler notices the two '+ 1' cancel each other out.

	David

> I'm not familiar enough with the rest of the codebase to know if 
> changing the function signature to unsigned int is correct here.

In theory you'd need to change the name and all the callers.

	David



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ