On 23 Aug 2001, jacob berkman wrote:
> on linux (2.4.9 and 2.2.18), the mmap() syscall will return NULL if the
> length argument is 0 rather than returning MAP_FAILED (-1). this is
> different than both solaris and hp-ux, and the linux man page doesn't
> indicate that it should do this.
>
> so, is this indeed the desired behaviour or a longstanding bug?
Surely the posix standard would say.
The sol8 manpage says specifically that EINVAL is returned if len <= 0;
And an openbsd and freebsd box i tried it on happily do the mmaps as
well.
All three (linux, sol8, fbsd) segfault with the following code for various
values of x and y.
fd = open();
marea = mmap(0, x, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
munmap(marea, y);
fclose(fd);
mmap:
linux
succeeds
sol8
succeeds if x>0, fails otherwise
fbsd4.3
succeeds
munmap:
linux
succeeds unless x>0 and y>x, in which case it segfaults
sol8
succeeds
fbsd
succeeds
close:
linux
succeeds
sol8
segfaults if y>x
fbsd
segfaults if y>x
justin
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Thu Aug 23 2001 - 21:01:03 EST