Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1465252imu; Fri, 9 Nov 2018 17:37:16 -0800 (PST) X-Google-Smtp-Source: AJdET5ewAjG7cm+7/YOwjyFmzio9rS5yrJ8pegchgcxBUrP7i060aPT3giMVtzeOxQKuw/uZo6Eh X-Received: by 2002:a63:d441:: with SMTP id i1-v6mr9464460pgj.31.1541813836376; Fri, 09 Nov 2018 17:37:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541813836; cv=none; d=google.com; s=arc-20160816; b=j9SH5BI94x2kRopL6h/8vgJe+SroPqT7p3Hxqjy9mfeFR5lkPhUZSvOphZ1DqeJdmC ETHjuZFZ4klDs/i70/w4etI+VtLnYbbbw5GH7b+/ivPSyuhA0gifYqAIamSw8cvDxvk2 q5J1oyr/pxPRjgwPtOIs2VI7jZTNqirgz+Uz7/v6A4W72QFOzfLDND8SAgwQGasBDnil dtQCCNGJbtbHdYwB/9r+oHengPdshdLmexWfjcForV2OB5eA1cqDlnYmXsQYUn6g0el2 tmNhMgnxKkgqFnukPK4h0QIjv3Z2f+eOaRU/gmCTu8r4fyPu1Tohb9RNzFFYVRchKsod Wo1A== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5rVRLwmeXXqGwuTVKtGHavaKEmH1dR+39dZJf49P+RA=; b=w6ShA3p4I/qIjqp7caY8WV5cl2PYECmXNqe/2HnBlmzidNNixY8k+U5zHrvwR7w6W1 EnE56XKXJxv5uC1LX6Xvb/N+xwj1JD1OxBhusJc+4i3rk2gn5AThsTQIwUJpraMANqBg HEKjg2MeHQe6fAgOqyzQ+0CCN16DEB8gs6UynU6JI+mDHVavKagy+/I4hAe9k9YCiX7S 2iJHNEOdLlG77W1FOYuzkDH428zBYtMnAOHnI67QYIiepoapWNF6qt+GiyPEvMml0jbZ KiXwGgR0y/u7PTE3clZn/15aXWVocp0QHqXkRfqToZDqtXHv1r535B42xIyP8vM/4syn 2bDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=whnQSpuR; 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 t16-v6si9449554plr.352.2018.11.09.17.36.47; Fri, 09 Nov 2018 17:37:16 -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; dkim=pass header.i=@joelfernandes.org header.s=google header.b=whnQSpuR; 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 S1728468AbeKJLT1 (ORCPT + 99 others); Sat, 10 Nov 2018 06:19:27 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:33779 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728310AbeKJLT1 (ORCPT ); Sat, 10 Nov 2018 06:19:27 -0500 Received: by mail-pg1-f196.google.com with SMTP id q5-v6so1596688pgv.0 for ; Fri, 09 Nov 2018 17:36:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=5rVRLwmeXXqGwuTVKtGHavaKEmH1dR+39dZJf49P+RA=; b=whnQSpuRoDGpVcPscQFQUrRVXT36d3O2EB2Jpr+ouBGjfNlsmkDjIdOgNXjX5Qnsl6 2TWy/1npjunwC7EWizaUuDob5LG6EPTuYJ/3Ua2YfMtxOulrC906rXOnS9f2/hLrJ88v p7/KFnwcrZgjeNEsHQ5tudtVWn0eDjsQ5LYuA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=5rVRLwmeXXqGwuTVKtGHavaKEmH1dR+39dZJf49P+RA=; b=WmXRWggKtXYl/eqO2A3hwTF6IetRjTe9tGiVuVWM+GUC4D7d4thlhoqlWOTp4zT0sj fbdlDYYzu70ekXfeqhDLQNDcRjhGsBDBgI2qGSz1ps09TY6pyxIokhAbd9C1DbWKb3+s pUAKmBmILWpFGg7r/vl3bNFCw2oYTX6zlz8ZcUcec1o+ZJqJN++hYDTfaFcIluFhfcfT FAXJaFe9YJsvHmvaEwv8ppyvUAK7fZvrku8sVYuMiuuPa00M1IvlapectP933bIYnlqj vD/wzKqkGaMW+hCFqdHLMo92xoxMITQRCoQDWZH77SUCT7yT5SN8g+tOyditdoYTRfEk xCAw== X-Gm-Message-State: AGRZ1gIG5EVQp4e85Tnf07acH2ObmczBnevgjAKPVUw8FHBVDvUhBF5n oh4wrmhW+8wwk7vlmUaYGCk5BatCAOk= X-Received: by 2002:a63:d949:: with SMTP id e9mr9611511pgj.24.1541813774059; Fri, 09 Nov 2018 17:36:14 -0800 (PST) Received: from localhost ([2620:0:1000:1601:3aef:314f:b9ea:889f]) by smtp.gmail.com with ESMTPSA id w80-v6sm14841724pfk.11.2018.11.09.17.36.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 09 Nov 2018 17:36:12 -0800 (PST) Date: Fri, 9 Nov 2018 17:36:11 -0800 From: Joel Fernandes To: Andy Lutomirski Cc: Daniel Colascione , Jann Horn , kernel list , John Reck , John Stultz , Todd Kjos , Greg Kroah-Hartman , Christoph Hellwig , Al Viro , Andrew Morton , Bruce Fields , Jeff Layton , Khalid Aziz , Lei.Yang@windriver.com, linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org, Linux-MM , marcandre.lureau@redhat.com, Mike Kravetz , Minchan Kim , Shuah Khan , valdis.kletnieks@vt.edu, Hugh Dickins , Linux API Subject: Re: [PATCH v3 resend 1/2] mm: Add an F_SEAL_FUTURE_WRITE seal to memfd Message-ID: <20181110013611.GA199560@google.com> References: <20181108041537.39694-1-joel@joelfernandes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 09, 2018 at 03:14:02PM -0800, Andy Lutomirski wrote: > >>>> That aside: I wonder whether a better API would be something that > >>>> allows you to create a new readonly file descriptor, instead of > >>>> fiddling with the writability of an existing fd. > >>> > >>> That doesn't work, unfortunately. The ashmem API we're replacing with > >>> memfd requires file descriptor continuity. I also looked into opening > >>> a new FD and dup2(2)ing atop the old one, but this approach doesn't > >>> work in the case that the old FD has already leaked to some other > >>> context (e.g., another dup, SCM_RIGHTS). See > >>> https://developer.android.com/ndk/reference/group/memory. We can't > >>> break ASharedMemory_setProt. > >> > >> > >> Hmm. If we fix the general reopen bug, a way to drop write access from > >> an existing struct file would do what Android needs, right? I don’t > >> know if there are general VFS issues with that. > > I don't think there is a way to fix this in /proc/pid/fd. At the proc level, the /proc/pid/fd/N files are just soft symlinks that follow through to the actual file. The open is actually done on that inode/file. I think changing it the way being discussed here means changing the way symlinks work in Linux. I think the right way to fix this is at the memfd inode level. I am working on a follow up patch on top of this patch, and will send that out in a few days (along with the man page updates). thanks! - Joel