Re: don't let mmap allocate down to zero

From: Sytse Wielinga
Date: Wed Jan 26 2005 - 22:33:23 EST


On Wed, Jan 26, 2005 at 11:38:15AM -0500, linux-os wrote:
> On Wed, 26 Jan 2005, Rik van Riel wrote:
>
> >With some programs the 2.6 kernel can end up allocating memory
> >at address zero, for a non-MAP_FIXED mmap call! This causes
> >problems with some programs and is generally rude to do. This
> >simple patch fixes the problem in my tests.
>
> Does this mean that we can't mmap the screen regen buffer at
> 0x000b8000 anymore?

If you would have looked inside mmap.c, you would have seen that his check
is executed *after* trying for a specific address if it was given. Mmapping
0x000b8000 should still work. I don't know if this patch was very clean (it
probably isn't) but what it's supposed to do is only fail if no specific
address has been given to it.

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

Oh come on. Every normal program checks whether a variable has been allocated
or not by comparing it to NULL. I have no knowledge of the internals of glibc
though, and wouldn't know whether this should be handled inside the kernel or
if having it checked in glibc and userspace programs that use mmap directly
should be enough, but AFAIK every C coder assumes that NULL pointers point to
nothing.

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