All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: Russell King - ARM Linux <linux@armlinux.org.uk>
Cc: Joel Stanley <joel@jms.id.au>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linux-Next Mailing List <linux-next@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-arm-kernel@lists.infradead.org,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Abdul Haleem <abdhalee@linux.vnet.ibm.com>,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: linux-next: Tree for Nov 7
Date: Mon, 13 Nov 2017 16:31:42 +0100	[thread overview]
Message-ID: <20171113153142.aoznpjivgjjihlef@dhcp22.suse.cz> (raw)
In-Reply-To: <20171113150908.GL12318@n2100.armlinux.org.uk>

On Mon 13-11-17 15:09:09, Russell King - ARM Linux wrote:
> On Mon, Nov 13, 2017 at 03:11:40PM +0100, Michal Hocko wrote:
> > On Mon 13-11-17 10:20:06, Michal Hocko wrote:
> > > [Cc arm and ppc maintainers]
> > > 
> > > Thanks a lot for testing!
> > > 
> > > On Sun 12-11-17 11:38:02, Joel Stanley wrote:
> > > > On Fri, Nov 10, 2017 at 11:00 PM, Michal Hocko <mhocko@kernel.org> wrote:
> > > > > Hi Joel,
> > > > >
> > > > > On Wed 08-11-17 15:20:50, Michal Hocko wrote:
> > > > > [...]
> > > > >> > There are a lot of messages on the way up that look like this:
> > > > >> >
> > > > >> > [    2.527460] Uhuuh, elf segement at 000d9000 requested but the
> > > > >> > memory is mapped already
> > > > >> > [    2.540160] Uhuuh, elf segement at 000d9000 requested but the
> > > > >> > memory is mapped already
> > > > >> > [    2.546153] Uhuuh, elf segement at 000d9000 requested but the
> > > > >> > memory is mapped already
> > > > >> >
> > > > >> > And then trying to run userspace looks like this:
> > > > >>
> > > > >> Could you please run with debugging patch posted
> > > > >> http://lkml.kernel.org/r/20171107102854.vylrtaodla63kc57@dhcp22.suse.cz
> > > > >
> > > > > Did you have chance to test with this debugging patch, please?
> > > > 
> > > > Lots of this:
> > > > 
> > > > [    1.177266] Uhuuh, elf segement at 000d9000 requested but the  memory is mapped already, got 000dd000
> > > > [    1.177555] Clashing vma [dd000, de000] flags:100873 name:(null)
> > > 
> > > This smells like the problem I've expected that mmap with hint doesn't
> > > respect the hint even though there is no clashing mapping. The above
> > > basically says that we didn't map at 0xd9000 but it has placed it at
> > > 0xdd000. The nearest (clashing) vma is at 0xdd000 so this is our new
> > > mapping. find_vma returns the closest vma (with addr < vm_end) for the
> > > given address 0xd9000 so this address cannot be mapped by any other vma.
> > > 
> > > Now that I am looking at arm's arch_get_unmapped_area it does perform
> > > aligning for shared vmas.
> > 
> > Sorry for confusion here. These are not shared mappings as pointed out
> > by Russell in a private email. I got confused by the above flags which I
> > have misinterpreted as bit 0 set => MAP_SHARED. These are vm_flags
> > obviously so the bit 0 is VM_READ. Sorry about the confusion. The real
> > reason we are doing the alignment is that we do a file mapping
> > 	/*
> > 	 * We only need to do colour alignment if either the I or D
> > 	 * caches alias.
> > 	 */
> > 	if (aliasing)
> > 		do_align = filp || (flags & MAP_SHARED);
> > 
> > I am not really familiar with this architecture to understand why do we
> > need aliasing for file mappings, though.
> 
> I think it's there so that flush_dcache_page() works - possibly
> get_user_pages() being used on a private mapping of page cache pages,
> but that's guessing.

I fail to see how the mixure of MAP_FIXED and regular mapping of the
same file work then, but as I've said I really do not understand this
code.

> I'm afraid I don't remember all the details, this is code from around
> 15 years ago, and I'd be very nervous about changing it now without
> fully understanding the issues.

Ohh, absolutely! I didn't dare to touch this code and that's why I took
the easy way and simply opt-out from the harding for all those archs
that are basically sharing this pattern. But after a closer look it
seems that we can really introduce MAP_FIXED_SAFE that would keep the
arch mmap code intact yet we would get the hardening for all archs.
It would allow also allow a safer MAP_FIXED semantic for userspace.
-- 
Michal Hocko
SUSE Labs

WARNING: multiple messages have this Message-ID (diff)
From: mhocko@kernel.org (Michal Hocko)
To: linux-arm-kernel@lists.infradead.org
Subject: linux-next: Tree for Nov 7
Date: Mon, 13 Nov 2017 16:31:42 +0100	[thread overview]
Message-ID: <20171113153142.aoznpjivgjjihlef@dhcp22.suse.cz> (raw)
In-Reply-To: <20171113150908.GL12318@n2100.armlinux.org.uk>

On Mon 13-11-17 15:09:09, Russell King - ARM Linux wrote:
> On Mon, Nov 13, 2017 at 03:11:40PM +0100, Michal Hocko wrote:
> > On Mon 13-11-17 10:20:06, Michal Hocko wrote:
> > > [Cc arm and ppc maintainers]
> > > 
> > > Thanks a lot for testing!
> > > 
> > > On Sun 12-11-17 11:38:02, Joel Stanley wrote:
> > > > On Fri, Nov 10, 2017 at 11:00 PM, Michal Hocko <mhocko@kernel.org> wrote:
> > > > > Hi Joel,
> > > > >
> > > > > On Wed 08-11-17 15:20:50, Michal Hocko wrote:
> > > > > [...]
> > > > >> > There are a lot of messages on the way up that look like this:
> > > > >> >
> > > > >> > [    2.527460] Uhuuh, elf segement at 000d9000 requested but the
> > > > >> > memory is mapped already
> > > > >> > [    2.540160] Uhuuh, elf segement at 000d9000 requested but the
> > > > >> > memory is mapped already
> > > > >> > [    2.546153] Uhuuh, elf segement at 000d9000 requested but the
> > > > >> > memory is mapped already
> > > > >> >
> > > > >> > And then trying to run userspace looks like this:
> > > > >>
> > > > >> Could you please run with debugging patch posted
> > > > >> http://lkml.kernel.org/r/20171107102854.vylrtaodla63kc57 at dhcp22.suse.cz
> > > > >
> > > > > Did you have chance to test with this debugging patch, please?
> > > > 
> > > > Lots of this:
> > > > 
> > > > [    1.177266] Uhuuh, elf segement at 000d9000 requested but the  memory is mapped already, got 000dd000
> > > > [    1.177555] Clashing vma [dd000, de000] flags:100873 name:(null)
> > > 
> > > This smells like the problem I've expected that mmap with hint doesn't
> > > respect the hint even though there is no clashing mapping. The above
> > > basically says that we didn't map at 0xd9000 but it has placed it at
> > > 0xdd000. The nearest (clashing) vma is at 0xdd000 so this is our new
> > > mapping. find_vma returns the closest vma (with addr < vm_end) for the
> > > given address 0xd9000 so this address cannot be mapped by any other vma.
> > > 
> > > Now that I am looking at arm's arch_get_unmapped_area it does perform
> > > aligning for shared vmas.
> > 
> > Sorry for confusion here. These are not shared mappings as pointed out
> > by Russell in a private email. I got confused by the above flags which I
> > have misinterpreted as bit 0 set => MAP_SHARED. These are vm_flags
> > obviously so the bit 0 is VM_READ. Sorry about the confusion. The real
> > reason we are doing the alignment is that we do a file mapping
> > 	/*
> > 	 * We only need to do colour alignment if either the I or D
> > 	 * caches alias.
> > 	 */
> > 	if (aliasing)
> > 		do_align = filp || (flags & MAP_SHARED);
> > 
> > I am not really familiar with this architecture to understand why do we
> > need aliasing for file mappings, though.
> 
> I think it's there so that flush_dcache_page() works - possibly
> get_user_pages() being used on a private mapping of page cache pages,
> but that's guessing.

I fail to see how the mixure of MAP_FIXED and regular mapping of the
same file work then, but as I've said I really do not understand this
code.

> I'm afraid I don't remember all the details, this is code from around
> 15 years ago, and I'd be very nervous about changing it now without
> fully understanding the issues.

Ohh, absolutely! I didn't dare to touch this code and that's why I took
the easy way and simply opt-out from the harding for all those archs
that are basically sharing this pattern. But after a closer look it
seems that we can really introduce MAP_FIXED_SAFE that would keep the
arch mmap code intact yet we would get the hardening for all archs.
It would allow also allow a safer MAP_FIXED semantic for userspace.
-- 
Michal Hocko
SUSE Labs

  reply	other threads:[~2017-11-13 15:31 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-07  5:22 linux-next: Tree for Nov 7 Stephen Rothwell
2017-11-07 22:22 ` Joel Stanley
2017-11-08 14:20   ` Michal Hocko
2017-11-10 12:30     ` Michal Hocko
2017-11-12  1:08       ` Joel Stanley
2017-11-13  9:20         ` Michal Hocko
2017-11-13  9:20           ` Michal Hocko
2017-11-13  9:34           ` Russell King - ARM Linux
2017-11-13  9:34             ` Russell King - ARM Linux
2017-11-13  9:42           ` Michal Hocko
2017-11-13  9:42             ` Michal Hocko
2017-11-13  9:42             ` Michal Hocko
2017-11-13  9:42             ` Michal Hocko
2017-11-13 11:34             ` Michael Ellerman
2017-11-13 11:34               ` Michael Ellerman
2017-11-13 11:34               ` Michael Ellerman
2017-11-13 11:34               ` Michael Ellerman
2017-11-13 11:34               ` Michael Ellerman
2017-11-13 12:00               ` Michal Hocko
2017-11-13 12:00                 ` Michal Hocko
2017-11-13 12:00                 ` Michal Hocko
2017-11-13 12:00                 ` Michal Hocko
2017-11-13 12:00                 ` Michal Hocko
2017-11-13 15:16                 ` Michal Hocko
2017-11-13 15:16                   ` Michal Hocko
2017-11-13 15:16                   ` Michal Hocko
2017-11-13 15:16                   ` Michal Hocko
2017-11-13 15:16                   ` Michal Hocko
2017-11-13 15:48                   ` Russell King - ARM Linux
2017-11-13 15:48                     ` Russell King - ARM Linux
2017-11-13 15:48                     ` Russell King - ARM Linux
2017-11-13 15:48                     ` Russell King - ARM Linux
2017-11-13 15:48                     ` Russell King - ARM Linux
2017-11-13 15:59                     ` Michal Hocko
2017-11-13 15:59                       ` Michal Hocko
2017-11-13 15:59                       ` Michal Hocko
2017-11-13 15:59                       ` Michal Hocko
2017-11-13 15:59                       ` Michal Hocko
2017-11-13 15:49                   ` Michal Hocko
2017-11-13 15:49                     ` Michal Hocko
2017-11-13 15:49                     ` Michal Hocko
2017-11-13 15:49                     ` Michal Hocko
2017-11-13 15:49                     ` Michal Hocko
2017-11-13 16:06                     ` Michal Hocko
2017-11-13 16:06                       ` Michal Hocko
2017-11-13 16:06                       ` Michal Hocko
2017-11-13 16:06                       ` Michal Hocko
2017-11-13 16:06                       ` Michal Hocko
2017-11-13 16:35                       ` Khalid Aziz
2017-11-13 16:35                         ` Khalid Aziz
2017-11-13 16:35                         ` Khalid Aziz
2017-11-13 16:35                         ` Khalid Aziz
2017-11-13 16:35                         ` Khalid Aziz
2017-11-14  7:07                         ` Michal Hocko
2017-11-14  7:07                           ` Michal Hocko
2017-11-14  7:07                           ` Michal Hocko
2017-11-14  7:07                           ` Michal Hocko
2017-11-14  9:18                       ` Michael Ellerman
2017-11-14  9:18                         ` Michael Ellerman
2017-11-14  9:18                         ` Michael Ellerman
2017-11-14  9:18                         ` Michael Ellerman
2017-11-14  9:18                         ` Michael Ellerman
2017-11-14  9:29                         ` Michal Hocko
2017-11-14  9:29                           ` Michal Hocko
2017-11-14  9:29                           ` Michal Hocko
2017-11-14  9:29                           ` Michal Hocko
2017-11-14  9:29                           ` Michal Hocko
2017-11-14  9:02                   ` Michael Ellerman
2017-11-14  9:02                     ` Michael Ellerman
2017-11-14  9:02                     ` Michael Ellerman
2017-11-14  9:02                     ` Michael Ellerman
2017-11-14  9:02                     ` Michael Ellerman
2017-11-14  8:54                 ` Michael Ellerman
2017-11-14  8:54                   ` Michael Ellerman
2017-11-14  8:54                   ` Michael Ellerman
2017-11-14  8:54                   ` Michael Ellerman
2017-11-14  8:54                   ` Michael Ellerman
2017-11-14  9:04                   ` Michal Hocko
2017-11-14  9:04                     ` Michal Hocko
2017-11-14  9:04                     ` Michal Hocko
2017-11-14  9:04                     ` Michal Hocko
2017-11-14  9:04                     ` Michal Hocko
2017-11-14 14:52                     ` Khalid Aziz
2017-11-14 14:52                       ` Khalid Aziz
2017-11-14 14:52                       ` Khalid Aziz
2017-11-14 14:52                       ` Khalid Aziz
2017-11-13 14:11           ` Michal Hocko
2017-11-13 14:11             ` Michal Hocko
2017-11-13 15:09             ` Russell King - ARM Linux
2017-11-13 15:09               ` Russell King - ARM Linux
2017-11-13 15:31               ` Michal Hocko [this message]
2017-11-13 15:31                 ` Michal Hocko
2017-11-14  0:03         ` Andrew Morton
2017-11-14  0:36           ` Stephen Rothwell
  -- strict thread matches above, loose matches on Subject: below --
2023-11-07  1:17 Stephen Rothwell
2022-11-07  3:44 Stephen Rothwell
2019-11-07  8:07 Stephen Rothwell
2018-11-07  3:16 Stephen Rothwell
2013-11-07  7:31 Stephen Rothwell
2013-11-07  7:31 ` Stephen Rothwell
2012-11-07  5:15 Stephen Rothwell
2012-11-07  5:15 ` Stephen Rothwell

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=20171113153142.aoznpjivgjjihlef@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=abdhalee@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=benh@kernel.crashing.org \
    --cc=joel@jms.id.au \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=sfr@canb.auug.org.au \
    /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.