Re: How is NULL pointer dereference handled inside kernel?

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

 



thanx for clearing that jon.
(btw. don't read my post regarding my explaination
on how NULL deref. is handled...that was a horribly
wrong statement i made :P)

this might be off-topic...(it's non-linux!)
while testing some add-on cards for the product we
work on, we came across a problem. we had two legacy
boards - one with PPC and the other with mips. somewhere
in the code of the OS that runs on them there was a null
pointer deref. On the PPC board the value cud be read but
the mips one gave a processor exception (both these boards
were using MMU-less config's) while trying to do the same.

it turned out that actually there was a memeory attached to
the 0 address but in mips we configured some region to be
protected from write's and that's why we were getting that
exception, whereas this fxn-ality was not available on the
PPC board so it was going through.

I wonder how uCLinux handles such cases???

-mandeep

On Fri, 2004-11-19 at 05:53, Jon Masters wrote:
> 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