Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp4619258rwe; Tue, 30 Aug 2022 13:39:11 -0700 (PDT) X-Google-Smtp-Source: AA6agR610AcbA0RAe5lAhSymLmOwTKLouEfgBO2guevFV7BBhTcZSjbgvdnvUnCbwFwEBEIAfKsC X-Received: by 2002:a05:6a02:115:b0:41c:4d5f:876 with SMTP id bg21-20020a056a02011500b0041c4d5f0876mr19864294pgb.419.1661891950733; Tue, 30 Aug 2022 13:39:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661891950; cv=none; d=google.com; s=arc-20160816; b=vTCKojz+7cGXKKB8pi1p2XJIiCsiGUHNvDtdrCWKyljf0dAlTZgrnOc4QksZI04sKB dvcaUYTPC93hn4TF4+a/q+dzd61A/hUMKL0KaO1MXRscZ/zV2ulzZf3GiQgMojkcH7B1 asTRr6lMGIo8Rv0TW28ZkPyFObErDfzWDSdflc+6kXBvV5VDud86rSiyD5s9hNgZlW/t D3jnxElBuzhwVdNggTxmZY175hq8LYxklOV+gE424cRVjNVaaFHSs1no95/MiD4+jFpT 537L+vMwlowy0dVWQY6wS7wF2VYVHiwrBMApGvJ0XcKkGeq17J7RlD3tUT7PJ+GWyP5J FzIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=qJlLpOkELPi/QHoI5MOqP2NXG1iWQCH2fEv8e9Ssxoo=; b=tjRD5a8rHJLourYa6IzdBKX4i7waaoHl1ziJqwHFNrMbxbbWSXo1n3iKaA1DzDlQeA 4I6wmqdaxza3Neg/d5nE7ka8I531cM9ULvto/OJiNCs08Mxg+mrAgF+aTD8ksw5eRnrp Zq3lA8ZMeXVZXED/FCoyu4Ahi/gxTyH+QD1c8D98XJRU5njGkWXzQS4zByzD0n5lYVrZ 5+CUkFuqqH2KbfYmt8RUr5+v+65PLBdh7/zbYHRDjBWvaJj4b8ybTyaX9t9AdcKKBoS1 JLv24DyPpGvh8yur9ps5iV3nf6zv+9+b3mOm3B/BzoJXWMZWbH3nEgFphEg/sSfB35I8 4RIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20210112.gappssmtp.com header.s=20210112 header.b=xxEodV7a; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z4-20020aa78884000000b005363fa9e126si187444pfe.358.2022.08.30.13.38.55; Tue, 30 Aug 2022 13:39:10 -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=@paul-moore-com.20210112.gappssmtp.com header.s=20210112 header.b=xxEodV7a; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230257AbiH3UK4 (ORCPT + 99 others); Tue, 30 Aug 2022 16:10:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229583AbiH3UKw (ORCPT ); Tue, 30 Aug 2022 16:10:52 -0400 Received: from mail-oa1-x2c.google.com (mail-oa1-x2c.google.com [IPv6:2001:4860:4864:20::2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05F614504D for ; Tue, 30 Aug 2022 13:10:51 -0700 (PDT) Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-11eb8b133fbso15037858fac.0 for ; Tue, 30 Aug 2022 13:10:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=qJlLpOkELPi/QHoI5MOqP2NXG1iWQCH2fEv8e9Ssxoo=; b=xxEodV7a1e7/J/CC+G/b+UaD2Ii0/Rn30BjWnLmnHXaqxBbJn27dTX5+BSX6y2T0VC 600IGhnHSDehtxBC5L8x9dLnBArvX53kytinB+b/jGnGVCVUS6T2E6Tc5ilPu6cFI71+ 502VF3G+Bep6f5sAH+kr0v2hYHzzsysrsYYKAfmYJEK+0VAyw/bUPTe6WuaNI6F8Nue4 BVO8z6ThCYrr8+HaYvlCZ2FMVbZTODrKqx22p0S3vziQ0cbciSBGRpVvwLRB/mT45d8d la+wIdrLeEcfxsMJNYYJlHi+yiXYFQqhpgwl7P4jtf7+CdlAuwpy+NQqrluhn0DiqfLi EFww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=qJlLpOkELPi/QHoI5MOqP2NXG1iWQCH2fEv8e9Ssxoo=; b=GTNXme8IVRweI6wSwbsNftM9zxLZg38MUQOGYMDgBUx1NTy8XUIiaMlp3WB1S9P6gB Y5f74zNpkRUjx9belmFCN2IdyYc8vBNFKNyDklXgniia8yC8M6ZQ7r4YgAAWtOwzkrEo PGVseBBDUjSBMQc4V1klKky4QVDgprkbwup9JhQBzwTqeKdjQC5WQzPpY2KVgMW3SIZ3 keKL3WhzFUBoRoARFpiPh0nZkrg1HBlxLlRfIF/pSTUMuM/BkfnXY7I0Ccdz3ygeyyi0 tXfzIb1XN/di/0u7b9thqd3WA/Ri5IkU5hBIvAoeU8B0CBYG3QD0tet/fL6S9Qs+VqST Xscg== X-Gm-Message-State: ACgBeo1DlUC5MvE1Xf32BG8IKITmuqauPu5jQW4T5UCPBKb6YKUijmWQ jlu0CVgzJUR3AgLvW/40u43fYFuJFIH1gDwuNzdc X-Received: by 2002:a05:6870:a78d:b0:11c:437b:ec70 with SMTP id x13-20020a056870a78d00b0011c437bec70mr11313980oao.136.1661890250283; Tue, 30 Aug 2022 13:10:50 -0700 (PDT) MIME-Version: 1.0 References: <20220708093451.472870-1-omosnace@redhat.com> <20220826084354.a2jrrvni6mf7zzyw@wittgenstein> In-Reply-To: <20220826084354.a2jrrvni6mf7zzyw@wittgenstein> From: Paul Moore Date: Tue, 30 Aug 2022 16:10:39 -0400 Message-ID: Subject: Re: [RFC PATCH RESEND] userfaultfd: open userfaultfds with O_RDONLY To: Christian Brauner Cc: Ondrej Mosnacek , Alexander Viro , linux-fsdevel@vger.kernel.org, Andrew Morton , Andrea Arcangeli , Peter Xu , David Hildenbrand , Lokesh Gidra , linux-mm@kvack.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org, linux-kernel@vger.kernel.org, "Robert O'Callahan" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 Fri, Aug 26, 2022 at 4:44 AM Christian Brauner wrote: > On Fri, Aug 19, 2022 at 02:50:57PM -0400, Paul Moore wrote: > > On Tue, Aug 16, 2022 at 6:12 PM Paul Moore wrote: > > > On Fri, Jul 8, 2022 at 5:35 AM Ondrej Mosnacek wrote: > > > > > > > > Since userfaultfd doesn't implement a write operation, it is more > > > > appropriate to open it read-only. > > > > > > > > When userfaultfds are opened read-write like it is now, and such fd is > > > > passed from one process to another, SELinux will check both read and > > > > write permissions for the target process, even though it can't actually > > > > do any write operation on the fd later. > > > > > > > > Inspired by the following bug report, which has hit the SELinux scenario > > > > described above: > > > > https://bugzilla.redhat.com/show_bug.cgi?id=1974559 > > > > > > > > Reported-by: Robert O'Callahan > > > > Fixes: 86039bd3b4e6 ("userfaultfd: add new syscall to provide memory externalization") > > > > Signed-off-by: Ondrej Mosnacek > > > > --- > > > > > > > > Resending as the last submission was ignored for over a year... > > > > > > > > https://lore.kernel.org/lkml/20210624152515.1844133-1-omosnace@redhat.com/T/ > > > > > > > > I marked this as RFC, because I'm not sure if this has any unwanted side > > > > effects. I only ran this patch through selinux-testsuite, which has a > > > > simple userfaultfd subtest, and a reproducer from the Bugzilla report. > > > > > > > > Please tell me whether this makes sense and/or if it passes any > > > > userfaultfd tests you guys might have. > > > > > > > > fs/userfaultfd.c | 4 ++-- > > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > VFS folks, any objection to this patch? It seems reasonable to me and > > > I'd really prefer this to go in via the vfs tree, but I'm not above > > > merging this via the lsm/next tree to get someone in vfs land to pay > > > attention to this ... > > > > Okay, final warning, if I don't see any objections to this when I make > > my patch sweep next week I'm going to go ahead and merge this via the > > LSM tree. > > Makes sense, > Acked-by: Christian Brauner (Microsoft) Merged into lsm/next, thanks all. -- paul-moore.com