Re: How is NULL pointer dereference handled inside kernel?

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

 



On Thu, 18 Nov 2004 10:27:49 +0530, Mandeep Sandhu
<mandeep_sandhu@xxxxxxxxxxx> wrote:

> a basic question. How does the kernel handle NULL pointer
> dereferencing inside kernel space.

Indeed. Since everyone else jumped on to a fantastic discussion of
NULL vs. 0 and other pointerisms but failed to answer your original
question concisely, I'll pipe up now.

This varies by architecture, but the kernel essentially contains a
deliberately bad NULL page which is mapped at zero so that any
dereferences to that virtual address will result in a processor
exception calling the page_fault_handler, and having an oops error
result. It's just a simple case of throwing away a single page to try
to handle bad code.

> I think on PowerPC 0 is a valid address

On some processors, zero is not a valid address, on PowerPC processors
which substantially follow the specification then it is valid to have
a mapping at that location in virtual memory and zero is certainly a
valid physical memory address (as it usually is on most processors
Linux supports). So it's valid but deliberately triggers a page fault.

Jon.

--
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