public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* mmap() return value when length == 0
@ 2001-08-23 22:12 jacob berkman
  2001-08-23 23:43 ` Justin Guyett
  0 siblings, 1 reply; 3+ messages in thread
From: jacob berkman @ 2001-08-23 22:12 UTC (permalink / raw)
  To: linux-kernel

hello,

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?

thanks,
jacob


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: mmap() return value when length == 0
  2001-08-23 22:12 mmap() return value when length == 0 jacob berkman
@ 2001-08-23 23:43 ` Justin Guyett
  0 siblings, 0 replies; 3+ messages in thread
From: Justin Guyett @ 2001-08-23 23:43 UTC (permalink / raw)
  To: jacob berkman; +Cc: linux-kernel

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: mmap() return value when length == 0
       [not found] <Pine.LNX.4.10.10108231945450.8694-100000@coffee.psychology.mcmaster.ca>
@ 2001-08-23 23:48 ` Justin Guyett
  0 siblings, 0 replies; 3+ messages in thread
From: Justin Guyett @ 2001-08-23 23:48 UTC (permalink / raw)
  To: Mark Hahn; +Cc: linux-kernel

On Thu, 23 Aug 2001, Mark Hahn wrote:

> I hope you meant close.
yeah, sorry :)  close not fclose.


justin


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-08-23 23:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-08-23 22:12 mmap() return value when length == 0 jacob berkman
2001-08-23 23:43 ` Justin Guyett
     [not found] <Pine.LNX.4.10.10108231945450.8694-100000@coffee.psychology.mcmaster.ca>
2001-08-23 23:48 ` Justin Guyett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox