Re: NULL dereference ? why not ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ramagudi Naziir wrote:
> Hello.
> 
> I want to ask why NULL dereference is never valid.
> Why isn't it possible that an application will have some data at
> virtual address zero ?
> is it platform-specific issue or is it by-design in linux ?

  For various reasons, it's convenient on most platforms to use a
representation of the null pointer, which representation consists of all
bits 0.  A null pointer must be different from all pointers to objects
(6.3.2.3 [#3]).  Thus the system must not allocate objects at address 0,
 by may, in principle, at address 1.  However, it's convenient to have
the system trap dereferencing null pointers (which is undefined
behavior) in order to aid in debugging programs.  Thus a whole page at
address 0 must be unmapped, since that's the granularity the memory
protection works.

~chill


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux