Received: by 10.192.165.156 with SMTP id m28csp980480imm; Wed, 11 Apr 2018 10:14:45 -0700 (PDT) X-Google-Smtp-Source: AIpwx49Ii4lrcI1v1F/FkxmQ+wUy0gnOU3uDBWtz6DoK9ib7lTHFxhOt8NnKMI6M1Ml/UnxsPxOM X-Received: by 10.167.132.132 with SMTP id u4mr4798962pfn.17.1523466885600; Wed, 11 Apr 2018 10:14:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523466885; cv=none; d=google.com; s=arc-20160816; b=Ftrno47SWx4CvFaBsFTkZLzTGov4iKWwKOpKmB4703zo9ohj5I5LF9P+IjmuFZqYqe UqjORa5O/jCpJyYEakIq95e2WHX/p3Xxr8T7eBVtBbU1xiDyYPM2mxjYBiILRsTcETyU I2OJv5gt8QaT0iha4e373BKqWX2Lk0rwUDXiPDus5nElLBiR9lSvB9i/v2e771i64atB lfT/vWCcV3HGD2h+xhjmUylvVN2Cy6KueVCqWDNUccHtS8n+h31S44+24Yg2RyoxVSGI A07vakF0JWGahIzEFQFWW/NXTshZ5Mu1WNyZBEzUnCkN0BHBZjA0v8xqM7gLmBbRr16Z dWAQ== 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=yBG1KwuuVzRDrkuQKXwThttDPGxQltdFts3ONXMwJ5w=; b=yYhPNqA3bX1d1PDOyo2dIP13cGfjpPf9D8KRtwGOubOdv9Yq+0dk8jlcufYuUZEmJ0 ju8zgWh5VjvW2VQcdprlxOkXXIwQQgiz2EgoI9TqdNrxjOjoRER/UK9ryT4VaC9UN2wy 3+hpOsVhbClAzEiFbENAIW9oiVwk0osTC9Z1ku37dsDqUSlHnbjd2GDBXoxGJ7WL4JzN //JbVlZhTiqA9+QvBSFAS7FjY/Imic4Mn1pwv5OEcJQWyRnAvQIcMc9TbKHoDllMRv1V UNYGcPYF8kzESE77MDGnjHDq1pTNC/wiVbmXuT7OhvUJDKBEQeOPfoEV1T6qgO7NO1A+ APMg== 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 p2si1124752pff.253.2018.04.11.10.14.07; Wed, 11 Apr 2018 10:14:45 -0700 (PDT) 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 S1754032AbeDKRHK (ORCPT + 99 others); Wed, 11 Apr 2018 13:07:10 -0400 Received: from mx2.suse.de ([195.135.220.15]:47131 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753811AbeDKRGm (ORCPT ); Wed, 11 Apr 2018 13:06:42 -0400 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 DEC77ACC3; Wed, 11 Apr 2018 17:06:40 +0000 (UTC) Date: Wed, 11 Apr 2018 19:06:38 +0200 From: Michal Hocko To: Jann Horn Cc: Michael Kerrisk , John Hubbard , Andrew Morton , Linux-MM , LKML , Linux API Subject: Re: [PATCH] mmap.2: document new MAP_FIXED_NOREPLACE flag Message-ID: <20180411170356.GM23400@dhcp22.suse.cz> References: <20180411120452.1736-1-mhocko@kernel.org> <20180411163631.GL23400@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 11-04-18 18:40:09, Jann Horn wrote: > On Wed, Apr 11, 2018 at 6:36 PM, Michal Hocko wrote: > > On Wed 11-04-18 17:37:46, Jann Horn wrote: > >> On Wed, Apr 11, 2018 at 2:04 PM, wrote: > >> > From: Michal Hocko > >> > > >> > 4.17+ kernels offer a new MAP_FIXED_NOREPLACE flag which allows the caller to > >> > atomicaly probe for a given address range. > >> > > >> > [wording heavily updated by John Hubbard ] > >> > Signed-off-by: Michal Hocko > >> > --- > >> > Hi, > >> > Andrew's sent the MAP_FIXED_NOREPLACE to Linus for the upcoming merge > >> > window. So here we go with the man page update. > >> > > >> > man2/mmap.2 | 27 +++++++++++++++++++++++++++ > >> > 1 file changed, 27 insertions(+) > >> > > >> > diff --git a/man2/mmap.2 b/man2/mmap.2 > >> > index ea64eb8f0dcc..f702f3e4eba2 100644 > >> > --- a/man2/mmap.2 > >> > +++ b/man2/mmap.2 > >> > @@ -261,6 +261,27 @@ Examples include > >> > and the PAM libraries > >> > .UR http://www.linux-pam.org > >> > .UE . > >> > +Newer kernels > >> > +(Linux 4.17 and later) have a > >> > +.B MAP_FIXED_NOREPLACE > >> > +option that avoids the corruption problem; if available, MAP_FIXED_NOREPLACE > >> > +should be preferred over MAP_FIXED. > >> > >> This still looks wrong to me. There are legitimate uses for MAP_FIXED, > >> and for most users of MAP_FIXED that I'm aware of, MAP_FIXED_NOREPLACE > >> wouldn't work while MAP_FIXED works perfectly well. > >> > >> MAP_FIXED is for when you have already reserved the targeted memory > >> area using another VMA; MAP_FIXED_NOREPLACE is for when you haven't. > >> Please don't make it sound as if MAP_FIXED is always wrong. > > > > Well, this was suggested by John. I think, nobody is objecting that > > MAP_FIXED has legitimate usecases. The above text just follows up on > > the previous section which emphasises the potential memory corruption > > problems and it suggests that a new flag is safe with that regards. > > > > If you have specific wording that would be better I am open for changes. > > I guess I'd probably also want to change the previous text; so I > should probably send a followup patch once this one has landed. yeah, that sounds like a better plan. -- Michal Hocko SUSE Labs