All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: John David Anglin <dave.anglin@bell.net>, carlos@redhat.com
Cc: Aaro Koskinen <aaro.koskinen@iki.fi>,
	Helge Deller <deller@gmx.de>,
	linux-parisc@vger.kernel.org
Subject: Re: parisc: fix mmap(MAP_FIXED|MAP_SHARED) to already mmapped address
Date: Thu, 19 Dec 2013 18:02:37 -0500	[thread overview]
Message-ID: <201312191802.39169.vapier@gentoo.org> (raw)
In-Reply-To: <BLU0-SMTP458FC9FB0E8F5D98CB7B8897C50@phx.gbl>

[-- Attachment #1: Type: Text/Plain, Size: 3155 bytes --]

On Thursday 19 December 2013 17:38:37 John David Anglin wrote:
> On 12/19/2013 4:19 PM, Mike Frysinger wrote:
> > On Thursday 19 December 2013 14:44:40 John David Anglin wrote:
> >> On 12/19/2013 2:17 PM, Aaro Koskinen wrote:
> >>> This commit (0576da2c08e3d332f1b0653030d28ab804585ab6) and the current
> >>> mainline kernel (3.13-rc4) gives me the following with GLIBC 2.18:
> >>> 
> >>> $ localedef -c -i en_US -f UTF-8 en_US.UTF-8
> >>> cannot map archive header: Invalid argument
> >>> 
> >>> strace looks like this:
> >>> 
> >>> mmap2(NULL, 536870912, PROT_NONE, MAP_SHARED, 3, 0) = 0x42f34000
> >>> mmap2(0x43000000, 1607632, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED,
> >>> 3, 0) = -1 EINVAL (Invalid argument)
> >>> 
> >>> With the patch reverted, it works:
> >>> 
> >>> mmap2(NULL, 536870912, PROT_NONE, MAP_SHARED, 3, 0) = 0x42d74000
> >>> mmap2(0x43000000, 1607632, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED,
> >>> 3, 0) = 0x43000000
> >>> 
> >>> BTW, note that for GLIBC 2.18 some changes were done regarding this:
> >>> https://sourceware.org/bugzilla/show_bug.cgi?id=10283
> >> 
> >> Are you sure the glibc changes are correct?  PARISC addresses are not
> >> strictly aligned to SHMLBA.
> >> There's also a page offset and "random" offset derived from the kernel
> >> address of the mapping struct.
> > 
> > the glibc changes were to use SHMLBA as the min alignment where as before
> > it was using PAGE_SIZE.  the kernel shouldn't reject us because we
> > manually increased our alignment ... the mappings should still be
> > overlapping, so it shouldn't be an "out of mapping space" issue.
> > 
> > the first one gets a really large map (not fixed), and then the second
> > does a small mapping inside of that first one.
> 
> The mmap check is here:
> 
>          if (flags & MAP_FIXED) {
>                  if ((flags & MAP_SHARED) &&
>                      (addr - shared_align_offset(filp, pgoff)) & (SHMLBA
> - 1))
>                          return -EINVAL;
>                  return addr;
>          }
> 
> In the case at hand, the addr value passed is not equivalent to the value
> returned on first mmap2 call.  So, the error is correct.  The
> application has to
> preserve the "SHMLBA - 1" part of the address when selecting a new map
> address.
> 
> The error is EINVAL (i.e., bad address).
> 
> The old code wouldn't have returned an error but the second mapping
> would not
> have been equivalent to the first.
> 
> My head spins regarding mappings inside mappings as it seems they may
> conflict.

we designed the new locale code to work on all systems (including fixing the 
behavior on older parisc64 kernels).  the assumption is that, if we want to do 
overlapping mappings, we need to use SHMLBA as the min alignment (since that's 
what the define represents -- shared mapping alignments that the hardware is 
restricted by).  and that is what the new locale code is doing.  glibc defines 
SHMLBA to 0x00400000 for parisc which is why 0x42d74000 turned into 
0x43000000.

so either SHMLBA on parisc is wrong, or the new kernel code is wrong
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2013-12-19 23:02 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-19 19:17 parisc: fix mmap(MAP_FIXED|MAP_SHARED) to already mmapped address Aaro Koskinen
2013-12-19 19:44 ` John David Anglin
2013-12-19 20:28   ` Aaro Koskinen
2013-12-19 21:19   ` Mike Frysinger
2013-12-19 22:38     ` John David Anglin
2013-12-19 23:02       ` Mike Frysinger [this message]
2013-12-20 22:10         ` Helge Deller
2013-12-23 20:26           ` Aaro Koskinen
2013-12-29 20:50             ` Helge Deller
2013-12-29 21:26               ` Aaro Koskinen
2013-12-21 18:18         ` John David Anglin
2014-03-02 21:22     ` Helge Deller
2014-04-01 18:26       ` Aaro Koskinen
2014-04-01 18:49         ` Helge Deller
2014-04-02 19:09           ` Carlos O'Donell
2014-04-02 21:09             ` Helge Deller
2014-04-02 21:41               ` John David Anglin
2014-04-03 19:41                 ` Helge Deller
2014-04-03 20:03                   ` John David Anglin
2014-04-03 20:26                     ` Helge Deller
2015-02-20 21:36                       ` Carlos O'Donell
2015-02-21 20:31                         ` John David Anglin
2015-02-21 20:40                           ` John David Anglin
2015-02-21 23:09                             ` James Bottomley
2015-02-21 23:26                               ` Helge Deller
2015-02-21 23:57                                 ` James Bottomley
2015-02-22 16:45                                   ` John David Anglin
2015-02-22 17:17                                     ` James Bottomley
2015-02-22 17:53                                       ` Helge Deller
2015-02-22 17:54                                       ` John David Anglin
2015-02-22 17:58                                         ` James Bottomley
2015-02-22 18:07                                           ` Helge Deller
2015-02-22 19:13                                             ` James Bottomley
2015-02-22 19:16                                               ` Helge Deller
2015-02-22 19:42                                                 ` James Bottomley
2015-03-07 19:05                                                   ` Carlos O'Donell
2015-02-22 18:28                                         ` parisc: fix mmap(MAP_FIXED|MAP_SHARED) to already mmapped address - optimized patches Helge Deller
2015-02-22 17:28                                     ` parisc: fix mmap(MAP_FIXED|MAP_SHARED) to already mmapped address James Bottomley
2015-02-22 18:02                                       ` John David Anglin
2015-02-21 21:04                           ` Helge Deller
2014-04-03 20:12                   ` John David Anglin
2014-04-03 20:27                     ` Helge Deller
2014-04-04 15:45                     ` Jeroen Roovers
2013-12-19 20:28 ` Helge Deller
2013-12-19 20:53   ` Aaro Koskinen
2013-12-23 20:34 ` Rolf Eike Beer
2013-12-24  2:39   ` John David Anglin
2013-12-24  9:32     ` Rolf Eike Beer
2014-01-27 11:23   ` Rolf Eike Beer

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=201312191802.39169.vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=aaro.koskinen@iki.fi \
    --cc=carlos@redhat.com \
    --cc=dave.anglin@bell.net \
    --cc=deller@gmx.de \
    --cc=linux-parisc@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.