Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2570321pxv; Sun, 11 Jul 2021 18:31:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqemjRdYvusR14fnZoAulX8Exto9sQfmIituxVkpbdngFnIni2fTxYu9HR+61sjQy/PyUI X-Received: by 2002:a02:90d0:: with SMTP id c16mr30742990jag.106.1626053483382; Sun, 11 Jul 2021 18:31:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626053483; cv=none; d=google.com; s=arc-20160816; b=QB/Iy+Mn95jBdejxpspRA5BYo7U+J8d99Ok5V3IstsgGs3+fSTQABGc1LUga86pchm Arybqn/FZGxqGeFNIQnuF3JiRNkhQP0s3lDnQtgkoYB8ZwWa1jMk+RdJCjqnDSg60Xhu Kw1o47RzjLRuwMQ3vlleT/H+lYKOCDXOgmbqMCP4LAhaCxYI7N/Xke/L+LmuQb4XW9Sm WQebmZfU+mIViLz6sj+t8TJHf+l5ZbZ4JFDPZNk5uEbTgM48zgFMq8kunOft9vybuHhp 9e/iveEfiA6Jvmirdg9SwILEPc8UOhh1ydRN9+6Lm2ccrXXQEu/sR0gdTxyquRmlgroM X4aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=2KQDqhz4TIYF3Ugv03ZS6ZNGsJcwPUEkeYX3JFGuTNQ=; b=ZqAEyURBHh+zJHUgmPP9piRWSdl1IPAmprEUL0QFlWEgpd2U3QIDUTld6bnuDGbepR OcMsxdgGr4Po9bJq8Dj54iv7B0JFb9f8gmMClejrLWzCtTc02uOfBgu1IxNGIIfCoT/J 2uk/Yjj/iZnx3HlEd3328fiIID8EY/wrDaa/yqXSgAxKy8jnieGCKuyR8phDkShtPT3g SKAkaH6R1tbZTU7NK5vZVLmRoyf1sgCznuMG3Xj7mqr1jqIeLXLBiObrx8wabbCx8Haa tudA/uFiLWq0HZrdiNlFww1hOWyqkv8v+97sMyR42w/Ok9cTEfr/49P4vRcD5qVucXgT yJuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="a/MMF+QD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t11si16409820jal.23.2021.07.11.18.31.11; Sun, 11 Jul 2021 18:31:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="a/MMF+QD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229818AbhGLBd3 (ORCPT + 99 others); Sun, 11 Jul 2021 21:33:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229660AbhGLBd3 (ORCPT ); Sun, 11 Jul 2021 21:33:29 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DC59C0613DD for ; Sun, 11 Jul 2021 18:30:41 -0700 (PDT) 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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/