From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2F39C07E9B for ; Mon, 12 Jul 2021 01:30:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7E6646108C for ; Mon, 12 Jul 2021 01:30:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7E6646108C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 27EAC6B0088; Sun, 11 Jul 2021 21:30:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 22F5C6B008A; Sun, 11 Jul 2021 21:30:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0CF486B008C; Sun, 11 Jul 2021 21:30:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0194.hostedemail.com [216.40.44.194]) by kanga.kvack.org (Postfix) with ESMTP id DA0726B0088 for ; Sun, 11 Jul 2021 21:30:45 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E33FB8248047 for ; Mon, 12 Jul 2021 01:30:44 +0000 (UTC) X-FDA: 78352206408.28.69A18CE Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf11.hostedemail.com (Postfix) with ESMTP id 10690F000206 for ; Mon, 12 Jul 2021 01:30:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=2KQDqhz4TIYF3Ugv03ZS6ZNGsJcwPUEkeYX3JFGuTNQ=; b=a/MMF+QDk2zyAwnUwBh/rXbQRz ruiFOlP9FMnBilOCx+IlHNgDEmIn6+Cq7OzPEb9+lEQRjEmyEZFyO8SPA1xs3NF0mtlucNKr+Ww0N 9/RewVPnkmLd+seCJg/Tb4x+3z0sEtkW2hd9mXmK1/1W1mK32WWrmg0qOHIcDIt7mg8ucnXWeUsLy WhQrGjVWIlOn5PmsPXqDxO/qjhNosyUL/Y0vUzlk57HQ61Jh0utrm+88BXbdh9kIahmGlPiocnBTg cFZPQjB8BAYKTEfBWOUgtA6QMnjVF+oSYnjuJTzt8vm77eMjCh6lHwG5M8OlnIDdv36TpMuL8eMgW gRjATmJw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2km2-00Giyz-Px; Mon, 12 Jul 2021 01:30:25 +0000 Date: Mon, 12 Jul 2021 02:30:18 +0100 From: Matthew Wilcox To: "Longpeng (Mike, Cloud Infrastructure Service Product Dept.)" Cc: Steven Sistare , Anthony Yznaga , linux-kernel@vger.kernel.org, linux-mm@kvack.org, "Gonglei (Arei)" Subject: Re: [RFC PATCH 0/5] madvise MADV_DOEXEC Message-ID: References: <1595869887-23307-1-git-send-email-anthony.yznaga@oracle.com> <43471cbb-67c6-f189-ef12-0f8302e81b06@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 10690F000206 X-Stat-Signature: ydjrw8n76x9gtr8u1mdemhh6nxk7d53h Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="a/MMF+QD"; spf=none (imf11.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-HE-Tag: 1626053443-242587 X-Bogosity: Ham, tests=bogofilter, spamicity=0.001034, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Jul 12, 2021 at 09:05:45AM +0800, Longpeng (Mike, Cloud Infrastructure Service Product Dept.) wrote: > Let me describe my use case more clearly (just ignore if you're not interested > in it): > > 1. Prog A mmap() 4GB memory (anon or file-mapping), suppose the allocated VA > range is [0x40000000,0x140000000) > > 2. Prog A specifies [0x48000000,0x50000000) and [0x80000000,0x100000000) will be > shared by its child. > > 3. Prog A fork() Prog B and then Prog B exec() a new ELF binary. > > 4. Prog B notice the shared ranges (e.g. by input parameters or ...) and remap > them to a continuous VA range. This is dangerous. There must be an active step for Prog B to accept Prog A's ranges into its address space. Otherwise Prog A could almost completely fill Prog B's address space and so control where Prog B places its mappings. It could also provoke a latent bug in Prog B if it doesn't handle address space exhaustion gracefully. I had a proposal to handle this. Would it meet your requirements? https://lore.kernel.org/lkml/20200730152250.GG23808@casper.infradead.org/