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]
Date:	Wed, 15 Aug 2007 09:58:29 -0400
From:	Kyle Moffett <mrmacman_g4@....com>
To:	Jan Engelhardt <jengelh@...putergmbh.de>
Cc:	Rene Herman <rene.herman@...il.com>,
	Jason Uhlenkott <jasonuhl@...onuhl.org>,
	Arjan van de Ven <arjan@...radead.org>,
	Tim Bird <tim.bird@...sony.com>,
	linux kernel <linux-kernel@...r.kernel.org>
Subject: Re: kfree(0) - ok?

On Aug 15, 2007, at 06:20:27, Jan Engelhardt wrote:
> On Aug 15 2007 11:58, Rene Herman wrote:
>>>> NULL is not 0 though.
>>> It is.  Its representation isn't guaranteed to be all-bits-zero,
>>
>> He said the null _pointer_ isn't guaranteed to be all-bits zero.  
>> And it isn't. Read the standard or the faq.
>
> 0 is all-bits-zero.
> NULL is 0. ("It is.", above)
>
> Transitively, this would make NULL all-bits-zero.  I might have  
> missed something, though, perhaps that the cast to void* makes it  
> intransitive.  But leave it at whatever the standard says.
>
>> but the constant value 0 when used in pointer context is always a  
>> null pointer (and in fact the standard requires that NULL be  
>> #defined as 0 or a cast thereof).

Irrespective of whatever the standard says, EVERY platform and  
compiler anybody makes nowadays has a NULL pointer value with all  
bits clear.  Theoretically the standard allows otherwise, but such a  
decision would break so much code.  Linux especially, we rely on the  
uninitialized data to have all bits clear and we depend on that  
producing NULL pointers; if a NULL pointer was not bitwise exactly 0  
then the test "if (some_ptr != NULL)" would fail and we would start  
dereferencing garbage.

Cheers,
Kyle Moffett

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ