[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1322837127.2762.11.camel@edumazet-laptop>
Date: Fri, 02 Dec 2011 15:45:27 +0100
From: Eric Dumazet <eric.dumazet@...il.com>
To: Sébastien Paumier
<sebastien.paumier@...v-mlv.fr>
Cc: linux-kernel@...r.kernel.org
Subject: Re: mmap
Le vendredi 02 décembre 2011 à 13:20 +0100, Sébastien Paumier a écrit :
> Hi,
> I have a question about mmap's behavior when one tries to map a file asking for
> a length greater than the actual file size. When I run the attached code on a
> 100 bytes file, I have the following output:
>
> (... file content followed by zeros...)
> n=4096
> write: Bad address
>
> So, it seems that the actual memory area provided by mmap is one page large and
> not the requested length of filesize+10000. I guess that 'write' writes less
> than requested because it was interrupted by the SIGBUS signal. And my question is:
>
> shouldn't mmap either complain about the requested length or provide an
> accessible area of the requested length, instead of silently failing ?
Accessing non existing memory leads to SIGBUS signal, not a silent
failure. Its documented behavior.
man mmap
SIGBUS Attempted access to a portion of the buffer that does not corre‐
spond to the file (for example, beyond the end of the file,
including the case where another process has truncated the
file).
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists