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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250305213501.496ea4bf@pumpkin>
Date: Wed, 5 Mar 2025 21:35:01 +0000
From: David Laight <david.laight.linux@...il.com>
To: Dan Carpenter <dan.carpenter@...aro.org>
Cc: Markus Elfring <Markus.Elfring@....de>, Dmitry Baryshkov
 <dmitry.baryshkov@...aro.org>, kernel-janitors@...r.kernel.org,
 freedreno@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
 linux-arm-msm@...r.kernel.org, Abhinav Kumar <quic_abhinavk@...cinc.com>,
 Archit Taneja <architt@...eaurora.org>, Daniel Vetter <daniel@...ll.ch>,
 David Airlie <airlied@...il.com>, Jeykumar Sankaran
 <jsanka@...eaurora.org>, Jordan Crouse <jordan@...micpenguin.net>, Marijn
 Suijten <marijn.suijten@...ainline.org>, Rob Clark <robdclark@...il.com>,
 Sean Paul <sean@...rly.run>, Simona Vetter <simona@...ll.ch>, Vinod Koul
 <vkoul@...nel.org>, cocci@...ia.fr, LKML <linux-kernel@...r.kernel.org>
Subject: Re: [RFC] Clarification for “undefined behaviour”?

On Wed, 5 Mar 2025 17:30:28 +0300
Dan Carpenter <dan.carpenter@...aro.org> wrote:

> On Wed, Mar 05, 2025 at 02:17:32PM +0000, David Laight wrote:
...
> > And the 'fun' starts because NULL isn't required to use the all-zero
> > bit pattern.
> > Regardless of the bit-pattern, things like (void *)(1 - 1) are valid
> > NULL pointers.
> > 
> > Of course, while C allows this, I doubt NULL has ever been other than 0.
> > (It was 0 on a system I used many years ago where the O/S invalid pointer
> > was ~0.)  
> 
> Kernel style guidelines don't even allow if (p == NULL) so we would be
> screwed.  :P

Doesn't matter:
	if (!p) ...
	if (p == 0) ...
	if (p == (void *)0) ...
	if (p == NULL) ...
	if (p == (void *)(constant integer expression with value 0)) ...
and the equivalent assignments all behave the same regardless of the
bit-pattern use for NULL.
So:
	union { long l; void *p; } lpu;
	lpu.p = 0;
	return lpu.l;
Returns ABI (implementation) defined constant value.
I think the only requirement is that it can never be the address
of a valid variable.

	David

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ