Re: mremap() use is racy

From: Linus Torvalds
Date: Tue Aug 23 2005 - 19:08:52 EST




On Tue, 23 Aug 2005, Ulrich Drepper wrote:
>
> Linus Torvalds wrote:
> >
> > Especially if you use MAP_SHARED, you don't even need to mprotect
> > anything: you'll get a nice SIGBUS if you ever try to access past the last
> > page that maps the file.
>
> If you guarantee this (and test for this) it's fine with me.

It's how the kernel _should_ work, but very few apps seem to depend on it,
so no guarantees. I looked over the code, and I think we've lost the
SIGBUS thing.

Basically, if you don't ever access past the end, you should always be ok.
If you access past the end, at least some _really_ old kernel versions
will zero-fill the page with an anonymous page and lose coherency, while
more modern kernels should _either_ cause a SIGBUS or alternatively at
least have a coherent zero-filled page.

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