lkml.org 
[lkml]   [2012]   [Sep]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] mm: fix mmap overflow checking
On Tue, 4 Sep 2012 17:23:00 +0800
Wanlong Gao <gaowanlong@cn.fujitsu.com> wrote:

> POSIX said that if the file is a regular file and the value of "off"
> plus "len" exceeds the offset maximum established in the open file
> description associated with fildes, mmap should return EOVERFLOW.

That's what POSIX says, but what does Linux do? It is important that
we precisely describe and understand the behaviour change, as there is
potential here to break existing applications.

I'm assuming that Linux presently permits the mmap() and then generates
SIGBUS if an access is attempted beyond the max file size?

> /* offset overflow? */
> - if ((pgoff + (len >> PAGE_SHIFT)) < pgoff)
> - return -EOVERFLOW;
> + if (off + len < off)
> + return -EOVERFLOW;

Well, this treats sizeof(off_t) as the "offset maximum established in
the open file". But from my reading of the above excerpt, we should in
fact be checking against the underlying fs's s_maxbytes?



\
 
 \ /
  Last update: 2012-09-05 00:04    [W:0.121 / U:23.580 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site