Re: don't let mmap allocate down to zero

From: Bryn Reeves
Date: Wed Jan 26 2005 - 18:34:57 EST


On Wed, 2005-01-26 at 17:34, Chris Friesen wrote:
> linux-os wrote:
>
> > Does this mean that we can't mmap the screen regen buffer at
> > 0x000b8000 anymore?
> >
> > How do I look at the real-mode interrupt table starting at
> > offset 0? You know that the return value of mmap is to be
> > checked for MAP_FAILED, not for NULL, don't you?
>
> Can't you still map those physical addresses to other virtual addresses?
>

I think that's the case. The 0 address as refered to here is only for
the user virtual address space.

> > What 'C' standard do you refer to? Seg-faults on null pointers
> > have nothing to do with the 'C' standard and everything to
> > do with the platform.
>
> I believe the ISO/IEC 9899:1999 C Standard explicitly states that
> dereferencing a null pointer with the unary * operator results in
> undefined behavior.

Exactly. Undefined. VAX/UNIX allowed assignment to null pointers. BUT
it's now such a commonly held assumption that a null pointer is not
valid that things will break if this is changed. Doesn't glibc malloc
use mmap for small allocations? From the man page:

RETURN VALUE
For calloc() and malloc(), the value returned is a pointer to the
allocated memory, which is suitably aligned for any kind of
variable, or NULL if the request fails.

This could get pretty confusing if NULL was a valid address...

Cheers,

Bryn.

The DBX manual contrasts this behaviour on different systems:
http://acs.ucsd.edu/info/dbx.debug.php


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