From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751430AbdJEQdY (ORCPT ); Thu, 5 Oct 2017 12:33:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41030 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751144AbdJEQdX (ORCPT ); Thu, 5 Oct 2017 12:33:23 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1A80480B29 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=oleg@redhat.com Date: Thu, 5 Oct 2017 18:33:20 +0200 From: Oleg Nesterov To: Michal Hocko Cc: Baoquan He , Linus Torvalds , Kees Cook , Jiri Kosina , Al Viro , Ingo Molnar , LKML Subject: Re: MAP_FIXED for ELF mappings Message-ID: <20171005163320.GA20848@redhat.com> References: <20171004075059.bbx7madwgwflb7ky@dhcp22.suse.cz> <20171004150334.GB31992@x1> <20171004151238.GG24886@x1> <20171004151700.k4fvivvmi7pm5sl7@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171004151700.k4fvivvmi7pm5sl7@dhcp22.suse.cz> User-Agent: Mutt/1.5.24 (2015-08-30) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 05 Oct 2017 16:33:23 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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). Oleg.