Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp249529imu; Tue, 15 Jan 2019 21:08:30 -0800 (PST) X-Google-Smtp-Source: ALg8bN4BXBrO3Msmgv9c6NYs4VP3ur5xwbn1RIgKECjp5Ac64LSJiTjdby2P1xX2c1zG/lK8Pmi3 X-Received: by 2002:a63:4342:: with SMTP id q63mr7151696pga.63.1547615310364; Tue, 15 Jan 2019 21:08:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547615310; cv=none; d=google.com; s=arc-20160816; b=MFqmMMX9o6Yt80euWYmYCzGFNsyPZDkwhlWzr4Ty7poU/5t4HjpqxW0jlMd4fcCga8 J4fWCbXTn8aPbIpCj9tByQPhd60C8+TTnHGz5qvTLDeWJhS8zSpGshiBxtHgBb3lnM0C mdvzmEa3K+wi7yBoaW1o+FGphwegIwCvKQ/659rnwB0RL+agYsQatBqiLXw2aJ46sZDM pU9/eqdmRQaNVcymgdMQznWjFUMcIUqZXdg8bB0/rNHT9wapxNcV5ZzxG2wE/lU85Ns3 i/FYX8D72E3RAGKgbEvxjYVzVe2L5RMAWlrxxqJd0LC0qAr6b1nYXSDwKwNqifljy7cn o1eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=4z/2bbTbzxPpRc/4UtRoAqudsKLmh1F634okQES3cXg=; b=k4l20PR8moL8SqH4D+uSj108RkBfjUVGVaEfw3SxoBIWBWjqGzRbhpcHwhxloDIrzC JuONucSFDlRO/NsdO+Q8kGYLbMvnOjesltk6iRYAWK6Z5BXYAMdjlISdSxbLZQapS2u9 INyQIyNCtSvpKg9mlB+KbIbP9rATv9v5mVuSFWVIml5dN3Q0ZLa9Uykga2LwrHVm9YF5 hvUsfmMWCii3sRm5XDlxZXNEX9QyCs6nGSvymDNGhKHehbc00Up6IveyIIcP5pckqfbu 4HJjkD6ioh/y+43V9NCNIWeZN+FeEMPrvU5uzSk11G4XuOElitJ0ZmZ7kRDNupk3ugjq n+ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=i7H3gHUc; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v20si5135412pgk.103.2019.01.15.21.08.14; Tue, 15 Jan 2019 21:08:30 -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=@linaro.org header.s=google header.b=i7H3gHUc; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388397AbfAORhG (ORCPT + 99 others); Tue, 15 Jan 2019 12:37:06 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:33769 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730540AbfAORhG (ORCPT ); Tue, 15 Jan 2019 12:37:06 -0500 Received: by mail-wm1-f65.google.com with SMTP id r24so1577355wmh.0 for ; Tue, 15 Jan 2019 09:37:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4z/2bbTbzxPpRc/4UtRoAqudsKLmh1F634okQES3cXg=; b=i7H3gHUcX5vO+PFS1Ydfkg911iGffGB5u+Z/OzplF4DjXJzGjxJh/lLxVa/TkgwIaL N6nuCe0BwaCmFVI2Z87GiBk24BVLv/FVF2V4BLuWC7XW/6K+N1ai2BMvylbGneD+V0Oz SS7/aUcN/ca0+ENf6jzRCRZxoGrzOi82qnca4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4z/2bbTbzxPpRc/4UtRoAqudsKLmh1F634okQES3cXg=; b=iOkrGNyg1FyyV4JY02Alxxj3exBOnChY497ynkRZ0rXaSbLXBE7Vzm+Xo9b0QI+tjt RzecCe1kyttn0cZ00hoST3/2GwmUbi8Q7Mh37EraSB7q10EVuT2Yo4N914h/mYbh2V6p 0VI8pMN0sMIEreY8CMo/FpiQyE7hkSy9rMfRmuTaubRDHjwOKWX35vbmnM8qwdJmmAhY /FuYLXNMRfzamc8BQGfSsdRy1dB0x3jwcAJr9qGP2gjTsmKVw+1c4n75UTDhnMxTsJCy jUwHdEqTS6w45zR8WAcEH1xiJgLwTJ09k1NYKuN+pIQl6NSYgX2vm+fnaxuWn2RByPjy P3NA== X-Gm-Message-State: AJcUukce2vbnAjjRvGFBeyS8zgoKRtsyUTcF4+UyhsuKk0xUhaA+G0O0 0iaA4/JSlrqUPszVXHJBqrnTbmZOF72k4fpotbuDZf4nB00= X-Received: by 2002:a1c:6657:: with SMTP id a84mr3985082wmc.23.1547573824109; Tue, 15 Jan 2019 09:37:04 -0800 (PST) MIME-Version: 1.0 References: <20190112203816.85534-1-joel@joelfernandes.org> <20190112203816.85534-2-joel@joelfernandes.org> In-Reply-To: <20190112203816.85534-2-joel@joelfernandes.org> From: John Stultz Date: Tue, 15 Jan 2019 09:36:52 -0800 Message-ID: Subject: Re: [PATCH v4 1/2] mm/memfd: Add an F_SEAL_FUTURE_WRITE seal to memfd To: Joel Fernandes Cc: lkml , Andy Lutomirski , Al Viro , Andrew Morton , Daniel Colascione , Hugh Dickins , Jann Horn , "J. Bruce Fields" , Jeff Layton , Linux API , linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm , =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= , Matthew Wilcox , Mike Kravetz , Minchan Kim , Shuah Khan Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jan 12, 2019 at 12:38 PM Joel Fernandes wrote: > > From: "Joel Fernandes (Google)" > > Android uses ashmem for sharing memory regions. We are looking forward to > migrating all usecases of ashmem to memfd so that we can possibly remove > the ashmem driver in the future from staging while also benefiting from > using memfd and contributing to it. Note staging drivers are also not ABI > and generally can be removed at anytime. > > One of the main usecases Android has is the ability to create a region and > mmap it as writeable, then add protection against making any "future" > writes while keeping the existing already mmap'ed writeable-region active. > This allows us to implement a usecase where receivers of the shared > memory buffer can get a read-only view, while the sender continues to > write to the buffer. See CursorWindow documentation in Android for more > details: > https://developer.android.com/reference/android/database/CursorWindow > > This usecase cannot be implemented with the existing F_SEAL_WRITE seal. > To support the usecase, this patch adds a new F_SEAL_FUTURE_WRITE seal > which prevents any future mmap and write syscalls from succeeding while > keeping the existing mmap active. > > A better way to do F_SEAL_FUTURE_WRITE seal was discussed [1] last week > where we don't need to modify core VFS structures to get the same > behavior of the seal. This solves several side-effects pointed by Andy. > self-tests are provided in later patch to verify the expected semantics. > > [1] https://lore.kernel.org/lkml/20181111173650.GA256781@google.com/ > > [Thanks a lot to Andy for suggestions to improve code] > Cc: Andy Lutomirski > Signed-off-by: Joel Fernandes (Google) > --- > fs/hugetlbfs/inode.c | 2 +- > include/uapi/linux/fcntl.h | 1 + > mm/memfd.c | 3 ++- > mm/shmem.c | 25 ++++++++++++++++++++++--- > 4 files changed, 26 insertions(+), 5 deletions(-) Acked-by: John Stultz