Received: by 10.223.164.202 with SMTP id h10csp3569182wrb; Mon, 20 Nov 2017 01:11:23 -0800 (PST) X-Google-Smtp-Source: AGs4zMaB6EDcEZAN2qJEsQlBPPskPeULZDqBRLP7rFmMe4lWWiLNgAOxVp0eQ0q6X5fIM5PPDN0r X-Received: by 10.99.185.71 with SMTP id v7mr13028945pgo.24.1511169083349; Mon, 20 Nov 2017 01:11:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511169083; cv=none; d=google.com; s=arc-20160816; b=i3YJrVdV6TWwtG5x9HcWrhe+f/6BRT7E1Xj4ZRKO72s4VL/HJpxMyR/lb8hGz9Z0cq MfL7EVJ2/5As75FAnNtkTmGxKYRwXmVKUqcrAkOAKPuGRyZ8bnt0P2l4wBxEbtnUCvp4 kOOHMJdxBHfdCqOrQv1rMKk6Uqy31g1Xyf/uxZ1TfkqFQoo64Zt9pMXSHDWfj3deKW75 Wf9/BcMbObARX2ovn8qzE4l1veJLDgEdFiHM4b/K4r1ce81Qk6wa4dvqeG3uXdaX6yS1 2z1wnLQM+69DMLeED/1V/Jl354ejbBT8V+8KpFcZQ4etdL5iT+W5B5L92fi/iQYGUdNK 5kGQ== 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:cc:to:subject:arc-authentication-results; bh=F4GXlqK5Xaz5by6STD6YM97G0flLB9+YAqey23La6Dg=; b=WzmBtgsiUow6+a189ylGx29ZOZgCGzPdm5KAAcE7xXdqI7PQ1RoxP5q4KnsYSshKQG XQrEfUd7s9QSUYJRiPc0DBo6DHcZpZ3O7g5X3mbe8ZlSQteJrNL7kcDRCIk3yAJXTIt3 mcFkPvBRTb3QhutXe+9knk6jrPdS0g0WsHfU1ytFBgFFrzeMvl4DfZnj/oDjiBxp4vMZ SHtowUm4LnKVC7nnHiVcD7u66hAn0MLQK7cUuxmqrKR1mciFpRdJwloNScY1leXL0X1n dQ0sIqENekuUO2HjqaaGghPxe99oF6TNQ5EV+h2hWiiDqYsf13dbAtP2AkynlfCr5xxA XomA== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r6si7759238pli.733.2017.11.20.01.11.13; Mon, 20 Nov 2017 01:11:23 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751197AbdKTJKj (ORCPT + 68 others); Mon, 20 Nov 2017 04:10:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33792 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751042AbdKTJKh (ORCPT ); Mon, 20 Nov 2017 04:10:37 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CF64D61B37; Mon, 20 Nov 2017 09:10:36 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-116-106.ams2.redhat.com [10.36.116.106]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CEFC95EDE4; Mon, 20 Nov 2017 09:10:33 +0000 (UTC) Subject: Re: [RFC PATCH 1/2] mm: introduce MAP_FIXED_SAFE To: Michal Hocko Cc: linux-api@vger.kernel.org, Khalid Aziz , Michael Ellerman , Andrew Morton , Russell King - ARM Linux , Andrea Arcangeli , linux-mm@kvack.org, LKML , linux-arch@vger.kernel.org References: <20171116101900.13621-1-mhocko@kernel.org> <20171116101900.13621-2-mhocko@kernel.org> <20171120085524.y4onsl5dpd3qbh7y@dhcp22.suse.cz> From: Florian Weimer Message-ID: <37a6e9ba-e0df-b65f-d5ef-871c25b5cb87@redhat.com> Date: Mon, 20 Nov 2017 10:10:32 +0100 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: <20171120085524.y4onsl5dpd3qbh7y@dhcp22.suse.cz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 20 Nov 2017 09:10:37 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/20/2017 09:55 AM, Michal Hocko wrote: > On Fri 17-11-17 08:30:48, Florian Weimer wrote: >> On 11/16/2017 11:18 AM, Michal Hocko wrote: >>> + if (flags & MAP_FIXED_SAFE) { >>> + struct vm_area_struct *vma = find_vma(mm, addr); >>> + >>> + if (vma && vma->vm_start <= addr) >>> + return -ENOMEM; >>> + } >> >> Could you pick a different error code which cannot also be caused by a an >> unrelated, possibly temporary condition? Maybe EBUSY or EEXIST? > > Hmm, none of those are described in the man page. I am usually very > careful to not add new and potentially unexpected error codes but it is I think this is a bad idea. It leads to bizarre behavior, like open failing with EOVERFLOW with certain namespace configurations (which have nothing to do with file sizes). Most of the manual pages are incomplete regarding error codes, and with seccomp filters and security modules, what error codes you actually get is anyone's guess. > true that a new flag should warrant a new error code. I am not sure > which one is more appropriate though. EBUSY suggests that retrying might > help which is true only if some other party unmaps the range. So EEXIST > would sound more natural. Sure, EEXIST is completely fine. >> This would definitely help with application-based randomization of mappings, >> and there, actual ENOMEM and this error would have to be handled >> differently. > > I see. Could you be more specific about the usecase you have in mind? I > would incorporate it into the patch description. glibc ld.so currently maps DSOs without hints. This means that the kernel will map right next to each other, and the offsets between them a completely predictable. We would like to change that and supply a random address in a window of the address space. If there is a conflict, we do not want the kernel to pick a non-random address. Instead, we would try again with a random address. Thanks, Florian From 1584575314105439068@xxx Mon Nov 20 09:06:19 +0000 2017 X-GM-THRID: 1584222568854832887 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread