From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751421AbdJEQmw (ORCPT ); Thu, 5 Oct 2017 12:42:52 -0400 Received: from mx2.suse.de ([195.135.220.15]:60708 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751319AbdJEQmv (ORCPT ); Thu, 5 Oct 2017 12:42:51 -0400 Date: Thu, 5 Oct 2017 18:42:48 +0200 From: Michal Hocko To: Oleg Nesterov Cc: Baoquan He , Linus Torvalds , Kees Cook , Jiri Kosina , Al Viro , Ingo Molnar , LKML Subject: Re: MAP_FIXED for ELF mappings Message-ID: <20171005164248.h3brmuj4opq2ql4e@dhcp22.suse.cz> References: <20171004075059.bbx7madwgwflb7ky@dhcp22.suse.cz> <20171004150334.GB31992@x1> <20171004151238.GG24886@x1> <20171004151700.k4fvivvmi7pm5sl7@dhcp22.suse.cz> <20171005163320.GA20848@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171005163320.GA20848@redhat.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 05-10-17 18:33:20, Oleg Nesterov wrote: > On 10/04, Michal Hocko wrote: > > > > On Wed 04-10-17 23:12:38, Baoquan He wrote: > > > if (total_size) { > > > total_size = ELF_PAGEALIGN(total_size); > > > - map_addr = vm_mmap(filep, addr, total_size, prot, flags, off); > > > - if (!BAD_ADDR(map_addr)) > > > - vm_munmap(map_addr+size, total_size-size); > > > - } else > > > - map_addr = vm_mmap(filep, addr, size, prot, flags, off); > > > + addr = get_unmapped_area(file, addr, total_size, off, flags); > > > > So how does this prevent clobbering an existing VMA when flags contains > > MAP_FIXED? > > I got lost... > > this is just cleanup, it should not change the behaviour, with or without > MAP_FIXED. It just avoids the mmap(total_size) + munmap(extra_size). OK, I have clearly misunderstood the intention then. -- Michal Hocko SUSE Labs