Received: by 10.223.164.202 with SMTP id h10csp430585wrb; Mon, 13 Nov 2017 08:38:27 -0800 (PST) X-Google-Smtp-Source: AGs4zMaeHhoPAsC1sEnEoRN0UuTCpNMsKKvug5cArS0ucHLymScP+p2RkIn7rngYjltBt+3FGHVU X-Received: by 10.99.179.65 with SMTP id x1mr3884967pgt.336.1510591107093; Mon, 13 Nov 2017 08:38:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510591107; cv=none; d=google.com; s=arc-20160816; b=veBkGg8Lwxs7p2xKJDFqe1qzdkQkVSj1omzgvuyl/6wv8uFjYKoDkMpQzhjuddgwjB f3TuDfdJ/BeIsphjJQtrw0+9jwd4eWBlzQF8JSBCaNQpMJ9dvf+s5xXHBZop7MXmkZFm tm9egcIfVmLA0mibuGyc/anMi356cwcLRM+Kdxp565/7EYuF4lWByhMUHY8o0cv+mOEi lDTsmKqwoNgIViszeKIBWAgid4dB3JfOEDK+RbFhcrD8nr5nS5eikk2DfmnSVAImJMSU 9uFhMyMTPoW+6fXTCC+Zv+uhPk7tNewr7GrNFB5I/o7wlwk/WqSMXotf5IaDFxa4PmTq cu0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :arc-authentication-results; bh=82ff9OhQBp9vJ86U0jjsNVuFHnpE+cmhj6BwOSx4g/U=; b=OhNApeJxM1N2BC9BlqDCHW4XvDSiiIXjBWebWkYkytD7/P7d5hX1lDjD37X1/sXae4 oiE3Y8FbnIJW15Dglk39VG46ZB1CQafaUzUVnSGViB5Iayg7WBfdKMQF4DwyGHLEB9Gy OC9kM8B+xFmoIkWH1+PZr3OH1VhsECO9qPCsXn232JgmkJ6TOlkwtodm/XnlM4HINZbt aJNGV+NL7SGizFV37uIFyCeZCjlvBnjYfPIPgCD5KaADhsHNjhhWEuSx2G7GyhPiK/DU luhyRLU4+0dY711m2ntqbWYnV3Ccb9GcoXbVOsw4sXNrQY05GChJNCWhP9fwwfGUWsdD 5h5A== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d2si13726740pgf.734.2017.11.13.08.38.14; Mon, 13 Nov 2017 08:38:27 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753824AbdKMQhk (ORCPT + 88 others); Mon, 13 Nov 2017 11:37:40 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:27902 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752421AbdKMQhi (ORCPT ); Mon, 13 Nov 2017 11:37:38 -0500 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id vADGZV2P002497 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Nov 2017 16:35:32 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id vADGZUuJ005545 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Nov 2017 16:35:30 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id vADGZNVc017675; Mon, 13 Nov 2017 16:35:25 GMT Received: from [192.168.1.16] (/24.9.64.241) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 13 Nov 2017 08:35:23 -0800 Subject: Re: linux-next: Tree for Nov 7 To: Michal Hocko , Michael Ellerman Cc: Joel Stanley , Stephen Rothwell , Andrew Morton , Linux-Next Mailing List , Linux Kernel Mailing List , Russell King , Benjamin Herrenschmidt , Abdul Haleem , Ralf Baechle , "James E.J. Bottomley" , Helge Deller , Yoshinori Sato , Rich Felker , "David S. Miller" , Chris Zankel , Max Filippov , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-mips@linux-mips.org, linux-parisc@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-xtensa@linux-xtensa.org References: <20171108142050.7w3yliulxjeco3b7@dhcp22.suse.cz> <20171110123054.5pnefm3mczsfv7bz@dhcp22.suse.cz> <20171113092006.cjw2njjukt6limvb@dhcp22.suse.cz> <20171113094203.aofz2e7kueitk55y@dhcp22.suse.cz> <87lgjawgx1.fsf@concordia.ellerman.id.au> <20171113120057.555mvrs4fjq5tyng@dhcp22.suse.cz> <20171113151641.yfqrecpcxllpn5mq@dhcp22.suse.cz> <20171113154939.6ui2fmpokpm7g4oj@dhcp22.suse.cz> <20171113160637.jhekbdyfpccme3be@dhcp22.suse.cz> From: Khalid Aziz Organization: Oracle Corp Message-ID: Date: Mon, 13 Nov 2017 09:35:22 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171113160637.jhekbdyfpccme3be@dhcp22.suse.cz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/13/2017 09:06 AM, Michal Hocko wrote: > OK, so this one should take care of the backward compatibility while > still not touching the arch code > --- > commit 39ff9bf8597e79a032da0954aea1f0d77d137765 > Author: Michal Hocko > Date: Mon Nov 13 17:06:24 2017 +0100 > > mm: introduce MAP_FIXED_SAFE > > MAP_FIXED is used quite often but it is inherently dangerous because it > unmaps an existing mapping covered by the requested range. While this > might be might be really desidered behavior in many cases there are > others which would rather see a failure than a silent memory corruption. > Introduce a new MAP_FIXED_SAFE flag for mmap to achive this behavior. > It is a MAP_FIXED extension with a single exception that it fails with > ENOMEM if the requested address is already covered by an existing > mapping. We still do rely on get_unmaped_area to handle all the arch > specific MAP_FIXED treatment and check for a conflicting vma after it > returns. > > Signed-off-by: Michal Hocko > > ...... deleted ....... > diff --git a/mm/mmap.c b/mm/mmap.c > index 680506faceae..aad8d37f0205 100644 > --- a/mm/mmap.c > +++ b/mm/mmap.c > @@ -1358,6 +1358,10 @@ unsigned long do_mmap(struct file *file, unsigned long addr, > if (mm->map_count > sysctl_max_map_count) > return -ENOMEM; > > + /* force arch specific MAP_FIXED handling in get_unmapped_area */ > + if (flags & MAP_FIXED_SAFE) > + flags |= MAP_FIXED; > + > /* Obtain the address to map to. we verify (or select) it and ensure > * that it represents a valid section of the address space. > */ Do you need to move this code above: if (!(flags & MAP_FIXED)) addr = round_hint_to_min(addr); /* Careful about overflows.. */ len = PAGE_ALIGN(len); if (!len) return -ENOMEM; Not doing that might mean the hint address will end up being rounded for MAP_FIXED_SAFE which would change the behavior from MAP_FIXED. -- Khalid From 1583967638937488736@xxx Mon Nov 13 16:07:35 +0000 2017 X-GM-THRID: 1583423641769727671 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread