Received: by 10.223.164.202 with SMTP id h10csp3052124wrb; Mon, 13 Nov 2017 01:21:34 -0800 (PST) X-Google-Smtp-Source: AGs4zMa6edrT0clD63R0vlGCUPP2vypy7WZAvKszY1994pmV92ZXytUholuL7B9FGuxTaXdF9e70 X-Received: by 10.101.74.4 with SMTP id s4mr7948444pgq.259.1510564894811; Mon, 13 Nov 2017 01:21:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510564894; cv=none; d=google.com; s=arc-20160816; b=iBOPsgn7/XfqYQLfCKb2LSz5IFTaiSNGyDO+EfBKV8q2jyv9P4EWvVQbW0LiSbnaC3 L4TJX9uX3gRg5K7re+1k1DMnhOWzGYxS5vFY4l4rLDX6Qvs3+v9HuHVu84lZPwQJTrv+ PrimKMExnPYz3aehUjWiNxJY3WOEFB8PzqVlhvRJhhN4VOyfoe2HbK3eSJ5TdfQibpHT nuymx5DpsYwAwCsqUhogwCpSo9vDz/OYYjzvdYqDtziZ6VvA+/ND0jjFgd1OQ6ib+Xz2 Xizh0D60IjxGtESrredHZYhIFdqz3xHcaI2l3yw/zLUEgyCLyj0i4Z9WTkBvfbzjdvxu 6o+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=sgXmCPmQvg5PFD3WZFpWflAGHfee0rgPyQ0ZEQjd0Sg=; b=HLBaVuxx2/N/UdRAhgTjeZJXJio2lIcZ58CMcl8bjJ7d+VKjF4VWFN4EMiB7M8U4a3 jqzuaZX0jnwNOhbcj+rgzK3y4a2QiV9k9JywxrIKgVJr4VcPy7nWAhcUuNkQPYm678c1 ytgOP3rrm/TltKhb5Oo2zhaEY1zvJ8F5ODn+YpCRx7LMN/eiiyRJbQv29TxgSxp3go9X b6XZzmZCwedke7DqNyLWeOzwvVosS8boBOybihk7gh0bwZWI4SdHSopumLmk2ivUC8O2 omlXuqCFUmbO4qZ5kdtaRZd1L57JtCiF2utSonsC7TyjD+DwT0mn7ML4T+9Kbt/00R3x 7s2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a186si2702212pgc.699.2017.11.13.01.21.22; Mon, 13 Nov 2017 01:21:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751371AbdKMJUO (ORCPT + 92 others); Mon, 13 Nov 2017 04:20:14 -0500 Received: from mx2.suse.de ([195.135.220.15]:34120 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751128AbdKMJUK (ORCPT ); Mon, 13 Nov 2017 04:20:10 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 566BFAAC3; Mon, 13 Nov 2017 09:20:08 +0000 (UTC) Date: Mon, 13 Nov 2017 10:20:06 +0100 From: Michal Hocko To: Joel Stanley Cc: Stephen Rothwell , Andrew Morton , Linux-Next Mailing List , Linux Kernel Mailing List , Russell King , linux-arm-kernel@lists.infradead.org, Benjamin Herrenschmidt , Michael Ellerman , Abdul Haleem , linuxppc-dev@lists.ozlabs.org Subject: Re: linux-next: Tree for Nov 7 Message-ID: <20171113092006.cjw2njjukt6limvb@dhcp22.suse.cz> References: <20171107162217.382cd754@canb.auug.org.au> <20171108142050.7w3yliulxjeco3b7@dhcp22.suse.cz> <20171110123054.5pnefm3mczsfv7bz@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [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 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. We do not do that for MAP_FIXED. Powepc, reported earlier [1] seems to suffer from the similar problem. slice_get_unmapped_area alignes to slices, whatever that means. I can see two possible ways around that. Either we explicitly request non-aligned mappings via a special MAP_$FOO (e.g. MAP_FIXED_SAFE) or simply opt out from the MAP_FIXED protection via ifdefs. The first option sounds more generic to me but also more tricky to not introduce other user visible effects. The later is quite straightforward. What do you think about the following on top of the previous patch? It is rather terse and disables the MAP_FIXED protection for arm comletely because I couldn't find a way to make it conditional on CACHEID_VIPT_ALIASING. But this can be always handled later. I find the protection for other archtectures useful enough to have this working for most architectures now and handle others specially. [1] http://lkml.kernel.org/r/1510048229.12079.7.camel@abdul.in.ibm.com --- diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 61a0cb15067e..018d041a30e6 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -99,6 +99,7 @@ config ARM select PERF_USE_VMALLOC select RTC_LIB select SYS_SUPPORTS_APM_EMULATION + select ARCH_ALIGNED_MMAPS # Above selects are sorted alphabetically; please add new ones # according to that. Thanks. help diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype index 2f629e0551e9..156f69c09c7f 100644 --- a/arch/powerpc/platforms/Kconfig.cputype +++ b/arch/powerpc/platforms/Kconfig.cputype @@ -368,6 +368,7 @@ config PPC_MM_SLICES bool default y if PPC_STD_MMU_64 default n + select ARCH_ALIGNED_MMAPS config PPC_HAVE_PMU_SUPPORT bool diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index a22718de42db..d23eb89f31c0 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -345,13 +345,19 @@ static unsigned long elf_vm_mmap(struct file *filep, unsigned long addr, unsigned long size, int prot, int type, unsigned long off) { unsigned long map_addr; + unsigned long map_type = type; /* * If caller requests the mapping at a specific place, make sure we fail * rather than potentially clobber an existing mapping which can have - * security consequences (e.g. smash over the stack area). + * security consequences (e.g. smash over the stack area). Be careful + * about architectures which do not respect the address hint due to + * aligning restrictions for !fixed mappings. */ - map_addr = vm_mmap(filep, addr, size, prot, type & ~MAP_FIXED, off); + if (!IS_ENABLED(ARCH_ALIGNED_MMAPS)) + map_type &= ~MAP_FIXED; + + map_addr = vm_mmap(filep, addr, size, prot, map_type, off); if (BAD_ADDR(map_addr)) return map_addr; -- Michal Hocko SUSE Labs From 1583820551383618353@xxx Sun Nov 12 01:09:41 +0000 2017 X-GM-THRID: 1583423641769727671 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread