Received: by 10.192.165.156 with SMTP id m28csp1672642imm; Thu, 12 Apr 2018 01:13:36 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+ykUHxZQdTMvzDBqUjfRdJ0WqwT9p06lwe7oLW49miUiHs+2D5M4ss4we7h/79KyPscemt X-Received: by 2002:a17:902:6b86:: with SMTP id p6-v6mr8457593plk.32.1523520815960; Thu, 12 Apr 2018 01:13:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523520815; cv=none; d=google.com; s=arc-20160816; b=T7Z+mn6IKWFnaffF9IlSfAbJf3eI+oFQ2pm5XThBFYmHKSkbnuuj/LYIRffWhNFnFO VSX3tYm1QXVztL9oXn7kvhsVb7PSgRQPrCCK+WRj75Cghzqko9f64qnzHOq1H16EzR7y EDEtr1o8tr1VwEs/uXrGeH7d1dm3cgOonH+WrqJh0ycvx+yNwKJkLwlTyGiM2yZqeVzN 1d38zDNeh84+dF50qQkTt13qeu4wtUThQAsmPaQgfubReQVuEy2sheS8EMBWuYDVnfvQ TTP90Wok4Yi5HIcztvonnpyuoTXW0eyTBqWwmKJOAlTV1w8+7rwD/B8x8i2Aeqxp/vLy O88A== 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:from:references:to:subject:cc:dkim-signature :arc-authentication-results; bh=CMTkYYya8YiBVDmzsy+sRB6wquhRFFguqSS9kS5b+n4=; b=c+dxnhKhctIIDlwv7xhEqbj2PIn0BF0yvC6IL/8ZKAywjMqtmbPJpQ7iTwQ+Z9XoCk O4MNFi3OTJudf1fH0V7fXOXojP3j3Qc1dDOT1s+d4pDjH6kn71L+pcVxHQP5L4/XVkCV Ptr1EwV31Y7zeYmvZyyoBiI3KmBm9cw6SASjE1sKTKhpyU92ovCEYgeRnLuEqm7Wt+0m ifWj1YNVnM1JomWWSKETSMb9E4Lxk0I6RuWHUCxcdZLZfdoelFzND0E3ZhV4qvvzN8As LNTZf9GOwHB8tc5rzeXOLQqsFx0zTKLZKYnIGk/4uL2hbrb6cdHGoMm+17JhDdXNyVz+ j73w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=slcDXr1s; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m18si1877366pgv.360.2018.04.12.01.12.58; Thu, 12 Apr 2018 01:13:35 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=slcDXr1s; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752742AbeDLIKW (ORCPT + 99 others); Thu, 12 Apr 2018 04:10:22 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:50894 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751836AbeDLIKU (ORCPT ); Thu, 12 Apr 2018 04:10:20 -0400 Received: by mail-wm0-f67.google.com with SMTP id t67so9656704wmt.0; Thu, 12 Apr 2018 01:10:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=cc:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=CMTkYYya8YiBVDmzsy+sRB6wquhRFFguqSS9kS5b+n4=; b=slcDXr1snEFTxWpTMldrO2lXr5mI+l9Yj4nr+Si8xrljPTbEv7M+pklMA27BFM1vr6 LppEeD3sR/6AmSlSrLQDSrUtGD54T7bQT5WISdaml5YzlQG1Bby5ow1IkZDpNGZ9+e7C cuToLB2LCnpSHgyF20jUirSV1EQfiYzpRv9wFjTEnM4aR8QGEBPQE4D25d7oLUAgi6Gk Fk0TTo9q5JcleL1b9nTvSD9Y+6IhrHmDCynU7XV12L9dsD2drWh3cuSiYweBAxCJ3ewO 64IM7L6DgQ79X1LitW9d6meyQyX7U8zX4KKbXuiRn607pRUqbWxqdzuaURILbQSp0UYe s2JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:cc:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=CMTkYYya8YiBVDmzsy+sRB6wquhRFFguqSS9kS5b+n4=; b=t3hyAUuqk5miCJtg/me9ADne7piWL2S19t9r5vJubFfpFLb6K9XrtH4m2rzaVQB0nc 1szLF2De50WTyba9cDH6A3q6S2a3SZRjSAkWjzGqqYpNH9/Qvxx54SXLDvuWKBfPz/W4 5aw/v5C2f2c+9PQcDzBLEjJxUpPX02x2j3Q2Xs3/4Yrr5hf7/WXfuQADD1AbeWizqovs 78IEbIrkJDC4IEaXVu6G50saqy6oKwoKWSvKu+u8OCB7bNu4uTqbKHU1pyP6P0u/au5C fmSRdqs41rasEvKMfHMNarknZ2/7xSvaOk4mkbGYSKFsVnhtrnMoOXPQ+ex/P16MK4lR 3OzA== X-Gm-Message-State: ALQs6tDjrhDLK5H2prbequ63gnyzvotQkWbcHKGd208Wk7O3Jrc6Hz2s A6ebkBIS2R00aYNXFWt8uyoLRuQb X-Received: by 10.28.105.92 with SMTP id e89mr4939383wmc.146.1523520619522; Thu, 12 Apr 2018 01:10:19 -0700 (PDT) Received: from [192.168.234.154] (mail2.jambit.com. [213.131.239.194]) by smtp.gmail.com with ESMTPSA id 55sm6187770wrw.52.2018.04.12.01.10.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Apr 2018 01:10:18 -0700 (PDT) Cc: mtk.manpages@gmail.com, John Hubbard , Andrew Morton , Linux-MM , LKML , Linux API Subject: Re: [PATCH] mmap.2: document new MAP_FIXED_NOREPLACE flag To: Jann Horn , Michal Hocko References: <20180411120452.1736-1-mhocko@kernel.org> <20180411163631.GL23400@dhcp22.suse.cz> From: "Michael Kerrisk (man-pages)" Message-ID: <6c2df5a8-b33a-915f-f220-da9a6ad08049@gmail.com> Date: Thu, 12 Apr 2018 10:10:18 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jann, On 04/11/2018 06:40 PM, 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. Okay -- I'm ready to take that piece now. Please send me a patch! Cheers, Michael -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/