From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA80AECAAD5 for ; Tue, 30 Aug 2022 20:10:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2BF816B0073; Tue, 30 Aug 2022 16:10:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2482F6B0074; Tue, 30 Aug 2022 16:10:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0C3B48D0001; Tue, 30 Aug 2022 16:10:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id E86356B0073 for ; Tue, 30 Aug 2022 16:10:51 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id BADFC80344 for ; Tue, 30 Aug 2022 20:10:51 +0000 (UTC) X-FDA: 79857352302.25.07FEA2D Received: from mail-oa1-f46.google.com (mail-oa1-f46.google.com [209.85.160.46]) by imf25.hostedemail.com (Postfix) with ESMTP id 2B03DA0010 for ; Tue, 30 Aug 2022 20:10:50 +0000 (UTC) Received: by mail-oa1-f46.google.com with SMTP id 586e51a60fabf-11ba6e79dd1so19409691fac.12 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=uIF4BoU7hfFKrWyH61yEp4jZj74e1cLMDX/WSKMztqEuuoabKrlpR/9NhX9X2V25l1 CCUdVpms1FM1awarcmGrRNSw3RPw80bp3b7795V7UBPbdJNa2mXFbSKNBmeZJhYhEI/A WHFXMpjpmS8GI6leO+ekUtSNjm20tZnheKyAa1c4JKiUIcjSpm8kuu16nY07Ep6hrbNx YXz5mM89PH8nsLlINdY9gagC+oKRB7wbwNdvUTgj3WQnbds4CzHWRFNyfYJUo+t92csU fBQP4FDbHEE2xqZlI0AQETYZp3pgxoU5kea1ldS8qXjtHbqQVWghmukSZN/U8ZK1JGaY 3QDQ== X-Gm-Message-State: ACgBeo2wKpaGUPyurly+T47RJBKKNdOMWQHl5ytt9LDdom3uuORRNSUg 0Y3Z7W27utrEuk5DvKY/fPVHZOdkR6fwWtTxiO3A X-Google-Smtp-Source: AA6agR7feW5/dLGJw4vAhaYoiUlA13S/ZyDm4jHFn05WI9FtjAPitCZNc7BF6TEeUYC8sgScaZjEpWOJ3swzuHG2cYU= 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" ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=paul-moore-com.20210112.gappssmtp.com header.s=20210112 header.b=xxEodV7a; spf=none (imf25.hostedemail.com: domain of paul@paul-moore.com has no SPF policy when checking 209.85.160.46) smtp.mailfrom=paul@paul-moore.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661890251; a=rsa-sha256; cv=none; b=gxkh+dBYikPnIjUr4QINj/nlNj+fuMLPy2uRhCoptFn6lBLmOaxe3QdmcS7bQiF2863jGi m3hn8R9DSdU76yX8tu77Z11Cyt3RnBjlAcRckBT6zGkGRLFRU+N8EcPC60WACx+CwmYs18 TJn+XYG9qP5KgTKe3IxU/nfopuzhoYw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661890251; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=qJlLpOkELPi/QHoI5MOqP2NXG1iWQCH2fEv8e9Ssxoo=; b=ZSzqb4Gsk7Wldv13bggLY9xC/qbl1IfI/JV76yZTBCxI7jM+C3S/O3uCoN51G1GKDwUgH6 XdUImE61MBntCqCJLPzTCqUDki03Q+YP/uJWJ1BX6hhQev032oyh44G7ApOjMZtM1gpNxJ JXdqn9MH85ruLqXa+8ebUY1UReJlOO8= Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=paul-moore-com.20210112.gappssmtp.com header.s=20210112 header.b=xxEodV7a; spf=none (imf25.hostedemail.com: domain of paul@paul-moore.com has no SPF policy when checking 209.85.160.46) smtp.mailfrom=paul@paul-moore.com; dmarc=none X-Stat-Signature: 1qb3cjeyx451xtc4idcgfcpip73tti4j X-Rspamd-Queue-Id: 2B03DA0010 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1661890250-813152 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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