Received: by 10.223.164.202 with SMTP id h10csp192166wrb; Mon, 13 Nov 2017 23:10:09 -0800 (PST) X-Google-Smtp-Source: AGs4zMavciz5HGrsHPDvyfLBgj+ZFJLgW99ZF4XPRqzWyJxJYyhCWIhxVuAmklBkZaaKAjRnM03r X-Received: by 10.99.67.195 with SMTP id q186mr10790505pga.186.1510643409362; Mon, 13 Nov 2017 23:10:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510643409; cv=none; d=google.com; s=arc-20160816; b=IQaseDXjU743bgX67BA1ESbMNDijbJ1qCuR5C/cD6beAMPnB3eNA/uXpbr3e85afiF xCVjoaIFqPRc/4KKPOL74hI01jK4xiDmAjBpGwF+GaeK3NNeaEoKpsAtoXqU/NByL7+q Kp9WKqJobpRUJ28I+Clq/Od5s33PPSg4YVVu0i8Po3hH0btsEP8r9J/loxB4xtswwl7P tQca0JxfPbP0Drx2ejco28Rz+nmISEvVta5A+ArB0U74iqAged2DxB+wOsslD2AQ0hMa 3m1tNIpPNJW2fv/YU65yQYK1HOpo9lKeHOtbcVaMqKlUHnl0enDE3vmRmyvOKQ8Ecu+x IDXQ== 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=briPDu56pOoqaBzXn9KeaDjV8ZAZar6IcsTNk8UjNsY=; b=LBak3TY2s60j6mYTnVO2Yz4jGdgS/LlLtl1prl9px0z/Q87aJKx4Bg/2nam85WqyOM +/0Se9KiOAbJrs4D3nbDbyfHuIFTnD+zYkc7gigNkZCHOMXGt3V6LI9tVrpRM03M7a5O wy4awMBvJH7xr7JWB30JAxDiJnAaKKOF0RIzz3dUHpUWGnHXnO+AFlGAxeVL/16SXxqX wen7a5jP55rTsGF4MrM4uzAqKYByJWYgKV0/k9GUv/3Kab+r8SiB817DDXOajXcseHAC R4fkrHN2v8dzESNaBzt78ScXrY4S9gF0RzFiYLbJZWkJ6gvpjPgkCWrEMfxnP9KO6tek vjYw== 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 39si15603208ple.489.2017.11.13.23.09.57; Mon, 13 Nov 2017 23:10:09 -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 S1753220AbdKNHIE (ORCPT + 89 others); Tue, 14 Nov 2017 02:08:04 -0500 Received: from mx2.suse.de ([195.135.220.15]:57748 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752583AbdKNHH4 (ORCPT ); Tue, 14 Nov 2017 02:07:56 -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 3AA358130F; Tue, 14 Nov 2017 07:07:53 +0000 (UTC) Date: Tue, 14 Nov 2017 08:07:48 +0100 From: Michal Hocko To: Khalid Aziz Cc: Michael Ellerman , 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 Subject: Re: linux-next: Tree for Nov 7 Message-ID: <20171114070748.in5zdc4giqbxowjy@dhcp22.suse.cz> References: <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> 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 On Mon 13-11-17 09:35:22, Khalid Aziz wrote: > 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. Yes, I will move it. -- Michal Hocko SUSE Labs From 1583999917533601435@xxx Tue Nov 14 00:40:38 +0000 2017 X-GM-THRID: 1583423641769727671 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread