mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hugh Dickins <hugh@veritas.com>
To: Stas Sergeev <stsp@aknet.ru>
Cc: Andrew Morton <akpm@osdl.org>, Christoph Rohland <cr@sap.com>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [patch][rfc] expandable anonymous shared mappings
Date: Tue, 29 Jun 2004 18:41:06 +0100 (BST)	[thread overview]
Message-ID: <Pine.LNX.4.44.0406291828030.16640-100000@localhost.localdomain> (raw)
In-Reply-To: <40E1A19C.6090607@aknet.ru>

On Tue, 29 Jun 2004, Stas Sergeev wrote:
> Now I understand, however, the problems I had with
> mremap(), have nothing special to do with the anon-shm,
> it just seems to be the usual thing with that syscall.
> It is full of surprises, it will map a zero-page to you,
> it will give you a SIGBUS, it will do everything
> but not what you really want from it:) I always
> wanted to have the more reliable mremap(). Not the
> one that can expand everything in the world, but
> the one that returns the value you can rely upon,
> as all the other syscalls do.

>From this attack on poor little mremap(), I think perhaps there's
something else you didn't realize, that I'd assumed you did realize.

If you have a file of size, say, 2 pages; and you mmap 3 pages of
it (from offset 0 for simplicity); then you try to access the third
page of your mapping... you get SIGBUS.  That's so whether it's a
shared or a private mapping.  It's even so if it's a private mapping,
you write your own data into the second page, you truncate the file
to 1 page, you try to access your own data in the second page again.
That's how mmap is specified to behave, not just on Linux.

So mremap() is entirely consistent to allow you to extend a mapping
beyond the end of the object, such that you'll get SIGBUS if you
try to access the end of your mapping.

The deficiency with shared anonymous is that there's no way to expand
or shrink the underlying object to match the mapping, whereas you can
ftruncate a real file.

Hugh


  reply	other threads:[~2004-06-29 17:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-16 18:12 Stas Sergeev
2004-06-18 20:46 ` Hugh Dickins
2004-06-19  9:07   ` Stas Sergeev
2004-06-20  0:20     ` Hugh Dickins
2004-06-20  9:46       ` Stas Sergeev
2004-06-23 11:23         ` Christoph Rohland
2004-06-23 18:45           ` Stas Sergeev
2004-06-28 14:25             ` Christoph Rohland
2004-06-28 14:22         ` Hugh Dickins
2004-06-28 18:48           ` Stas Sergeev
2004-06-28 21:44             ` Hugh Dickins
2004-06-29 17:06               ` Stas Sergeev
2004-06-29 17:41                 ` Hugh Dickins [this message]
2004-06-29 19:03                   ` Stas Sergeev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.44.0406291828030.16640-100000@localhost.localdomain \
    --to=hugh@veritas.com \
    --cc=akpm@osdl.org \
    --cc=cr@sap.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stsp@aknet.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®