Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp5828039imw; Wed, 20 Jul 2022 13:25:18 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sSJAzzwPX8XL6Q4qjrU9bF1udgVgWHVzpJ3oq8rFvL1YFy8Fm+41PbtWH+lLZSgOW1UZKy X-Received: by 2002:a17:90a:49c4:b0:1f2:2448:60e9 with SMTP id l4-20020a17090a49c400b001f2244860e9mr3645892pjm.148.1658348718204; Wed, 20 Jul 2022 13:25:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658348718; cv=none; d=google.com; s=arc-20160816; b=mmQUP46GKxyrgO9TtmfA7yLFdiVTxqI5QZuaPtLBWQKiidkLJEISKazPzxtB6em+x8 +woK8CcQIC2P7PHe9iU9KfH+1uZdCOYLnvyFUNkwdVa7NRLaHlIjw/+CtfF8e4cW64qg dPbGoSaGJKhO9R6mCidbbko4ie8n3MK6TWW0Gv9JECtjdrKZji8gPaGMl/K3R4MPSf3b O6qdMsDb/tow9TjahalPSDYtJY8mN/ZCcgSRxqbsc+oYHlAxo24HRFoAzwo8vAX7WQyH xeHWyWoFdb+WyyOZeJ/s8avcMytHJySHhlrR2aaYonyVboedNPfaw8r/hlHgAvcrWXOL 6AcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=ZbB9VnKGJLInuj72DJYZA8o4PYITUT0S6KGJae4KPqw=; b=TLE3OJ8g6SmhBSG6GQEFNb5KIICXl+TZ5dGYVUTuZOXDmjxku0X/u77XFvrbCs55Vn iwrNJZlxbOshWZVMPZCMcLgoUXdN2itomXhIOlb3TA/1vO6RQ+cORHrclaNuIOjKew/w Oeo5x0XDqaH8uEoM42NMvZJX1aLX4ZNijiztK3Wl8Hp/f3WAQClkz87jYlIwgl3ySZgv weZd+fLU/xElyxdCescM+u8gW0NvglB6istVzQLVmi2resTJv5cEMWlwk+X8DcVe6OaS Ps0TQOrmGruis/t33PR7CbZLrreIsHfRw8tDZlIYlUNGp5KerXnLCWqcJGDFi9AOBArX WKcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=D3g2EvZh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r7-20020a634407000000b0040dbc216491si22920592pga.823.2022.07.20.13.25.01; Wed, 20 Jul 2022 13:25:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=D3g2EvZh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229941AbiGTUKz (ORCPT + 99 others); Wed, 20 Jul 2022 16:10:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229491AbiGTUKu (ORCPT ); Wed, 20 Jul 2022 16:10:50 -0400 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFBE522519 for ; Wed, 20 Jul 2022 13:10:49 -0700 (PDT) Received: by mail-io1-xd2c.google.com with SMTP id v185so15174768ioe.11 for ; Wed, 20 Jul 2022 13:10:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=ZbB9VnKGJLInuj72DJYZA8o4PYITUT0S6KGJae4KPqw=; b=D3g2EvZhuWnUXeQaneJXywswhO2BPfAAtNguy0zp2A5RQItolJnZk+5TXzZbLv22J1 mgwTY9bypAkjnMaz34meIe4XYXvZEnmOoomJmHTnzEgxrk6NXJG1vrRNb9e847rKDeV8 qxxOp4Gc5r/Gs0OLVXncyreX8GBO7cxWV65zKQ4bGnac+El3rxT+tWLiEf0ZHBsJHYlR 6SkBlISbeozFHbHXgBEnh4FCjPST5VEvVPQ7B9cg9z6F+dcDc0MFObTNzM/boZagIwGf pDxWTHY+8z+Zw/nICI4UG50b1mcX2d/9YMN8DrFDX7ZuNLaGsOnKrL/fptVQs6Xbi7xg +Ydg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=ZbB9VnKGJLInuj72DJYZA8o4PYITUT0S6KGJae4KPqw=; b=suweBlkDLYqUEw1J35yQCPYBx5zWvaadCJyt0mJti6WkGDK+lx11fDfbPRevj7D5Mr +7wGRqp0YCmjgnNA0Sf7Hg5Y3oBW2HtYkPgqIf7/1l2aUFtAdRym3eOvpSL36aJy90Jo t30fGQ7h3FsybkOcalV9Srl/Ffs0rKLPkWyC5XA5+8hk2ANrgk1RZPLu+UCCVyrk9YY4 cOzjeqXINHINAPAM6IGRSjux+Gk+Gge3jkRl/A9UDS+P5i+sTY4BVjk+P88PLpeWiz/G RuXcYCvGfSk6e3sBUbe6EdA6jCszF/ooEkRLEusZw86A/YS6U2u96b2+f9dO7RnyfAO3 iNxA== X-Gm-Message-State: AJIora/9qH2mkObnGmD1+3XJOSoaSDjyEll52RyFi/QMxyTuA88955KD hQTL/YzOvA+GA+KWXv/cwii68Ekuqda58G15OEAzPQ== X-Received: by 2002:a02:c812:0:b0:33f:4812:4699 with SMTP id p18-20020a02c812000000b0033f48124699mr19570572jao.314.1658347849186; Wed, 20 Jul 2022 13:10:49 -0700 (PDT) MIME-Version: 1.0 References: <20220719195628.3415852-1-axelrasmussen@google.com> <20220719195628.3415852-3-axelrasmussen@google.com> <3C93275E-B3B8-45CA-808E-0C163DBBB32F@vmware.com> In-Reply-To: <3C93275E-B3B8-45CA-808E-0C163DBBB32F@vmware.com> From: Axel Rasmussen Date: Wed, 20 Jul 2022 13:10:13 -0700 Message-ID: Subject: Re: [PATCH v4 2/5] userfaultfd: add /dev/userfaultfd for fine grained access control To: Nadav Amit Cc: Peter Xu , Alexander Viro , Andrew Morton , Dave Hansen , "Dmitry V . Levin" , Gleb Fotengauer-Malinovskiy , Hugh Dickins , Jan Kara , Jonathan Corbet , Mel Gorman , Mike Kravetz , Mike Rapoport , Shuah Khan , Suren Baghdasaryan , Vlastimil Babka , zhangyi , "linux-doc@vger.kernel.org" , linux-fsdevel , LKML , Linux MM , "linux-kselftest@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 20, 2022 at 10:42 AM Nadav Amit wrote: > > On Jul 19, 2022, at 7:32 PM, Peter Xu wrote: > > > =E2=9A=A0 External Email > > > > On Tue, Jul 19, 2022 at 11:55:21PM +0000, Nadav Amit wrote: > >> Anyhow, I do want to clarify a bit about the =E2=80=9Ccross-process su= pport=E2=80=9D > >> userfaultfd situation. Basically, you can already get cross-process su= pport > >> today, by using calling userfaultfd() on the controlled process and ca= lling > >> pidfd_open() from another process. It does work and I do not remember = any > >> issues that it introduced (in contrast, for instance, to io-uring, tha= t > >> would break if you use userfaultfd+iouring+fork today). > > > > Do you mean to base it on pidof_getfd()? > > autocorrect? :) > > I did refer to pidfd_getfd() as a syscall that can be used today by one > process to control the address space of another process. I did not intend= to > use it for the actual implementation. > > > Just want to mention that this will still need collaboration of the tar= get > > process as userfaultfd needs to be created explicitly there. From that= POV > > it's still more similar to general SCM_RIGHTS trick to pass over the fd= but > > just to pass it in a different way. > > There are also some tricks you can do with ptrace in order not to need th= e > collaboration, but they are admittedly fragile. > > > IMHO the core change about having /proc/pid/userfaultfd is skipping tha= t > > only last step to create the handle. > > Yes. The point that I was trying to make is that there are no open issues > with adding support for remote process control through > /proc/pid/userfaultfd. This is in contrast, for example, for using io-uri= ng > with userfaultfd. For instance, if you try to use io-uring TODAY with > userfaultfd (without the async support that I need to add), and you try t= o > monitor the fork event, things would break (the new userfaultfd file > descriptor after fork would be installed on the io-worker thread). > > This is all to say that it is really simple to add support for one proces= s > monitoring userfaultfd of another process, since I understood that Axel h= ad > concerned that this might be utterly broken=E2=80=A6 Mostly I was worried it would be nontrivial to implement, and it isn't a use case I plan to use so I was hoping to ignore it and defer it to some future patches. ;) But, if it "just works" I'm happy to include it in v5.