Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2781902ybp; Sat, 12 Oct 2019 17:46:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZhjyi1ZF0RKOhtNucx/sEGmJXsVIAdD3LU1trQtrIhBjhF7Www2ngG1KDVRXVWgqzrODN X-Received: by 2002:a17:906:8286:: with SMTP id h6mr21428892ejx.258.1570927619206; Sat, 12 Oct 2019 17:46:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570927619; cv=none; d=google.com; s=arc-20160816; b=RzWzNBuLetIHU97ShYByVhF759v/CUSQMHUR5eNFykZ6Cfjavp1RaSn06k9hiQwgHq ff9eqN1VN0pmmbnEPjT0XYfS3MfAg3Vi2G2QM5PR2zpSVK1+Xw+abn6lcHkyF+Uqiz5r MDQfJz/x4l4u5uWSJ0NpG6LQuNd5YsTnfrJ7d1K9CDJ77lopnQCUxaijs+P7p/Y1nHhB qcM846YsI4qwm2A3acaWdnAf3bXHRhM6YhJ/bzK2rT4SNFxNJiH1244i9rGSdaUFELDS wzChDus/T+p6CVCeL4O27+EM0rnDuGSTUbMS3nqcga/W9RPwfi8Q0Ku/0u/bDzRFNehj RgQQ== 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=TiJrR2TQPjKoIIydEnmzCx4A0AoZ25y12r3LluJwP7A=; b=MPIU9VePeARd1TlALNk8BsBa41begGyn1hCvZXI+bDB+sX1d2lGEUbaTJEkSTyl4Gm j5mwwp/j0Dz449jTOnTAIrzjfWuwP79NipdjRIu68nNJlGnGneY4WEAbiy1mZNdFWACl QuqtViY5EomtmkKTyF+/GwuuYbUUE/bp6n8pi/azGH9FIZAYlKEDDYcpE3Zp4Yeggsk6 ztEl74cQNdCP8OsPIa07SWTvIy9nqKYtjdNDaGsWIeQRIG7XC++iV4eb4CbnGM8wYk0B +20IZWrhWPmfe7IBUVn4wAtQv+4V4p1Gyf8T+2lIQ5FlC+JYdPeno9A5im61o5huTV8I cjKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TFNSfK2n; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n4si7574705ejj.132.2019.10.12.17.46.33; Sat, 12 Oct 2019 17:46:59 -0700 (PDT) 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=@kernel.org header.s=default header.b=TFNSfK2n; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728237AbfJMAqb (ORCPT + 99 others); Sat, 12 Oct 2019 20:46:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:34344 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728053AbfJMAqa (ORCPT ); Sat, 12 Oct 2019 20:46:30 -0400 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D394821A4A for ; Sun, 13 Oct 2019 00:46:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570927590; bh=Af3xuDOmu2mRlmVHh8KyOwgmi8BjnhCayyjozArl5rc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=TFNSfK2nnknqf6YFpBWiswhdWqZghVAzwLOkXuFG627W92nSo0N5VKik94xJUR6d2 9CD+Fgek4xkfURdNb1GlJI283z/EqpXfWatZGaljVv9wHnfuHFqUI+Hzq5kH5d1oIw cU+h8TENoLgwakgyqMhU5M5q3iSWg2kJktcfg+Js= Received: by mail-wr1-f46.google.com with SMTP id n14so15618767wrw.9 for ; Sat, 12 Oct 2019 17:46:29 -0700 (PDT) X-Gm-Message-State: APjAAAXGspvKg1kRHh1SxMLNWAt6zjoo9wKNPbAEdci67hdo0qrM1zRn tB4hrJZnjivGCvP4Rj0t5FDanDz/se9USRgNA2ykng== X-Received: by 2002:a05:6000:1288:: with SMTP id f8mr4610565wrx.111.1570927588270; Sat, 12 Oct 2019 17:46:28 -0700 (PDT) MIME-Version: 1.0 References: <20191012191602.45649-1-dancol@google.com> <20191012191602.45649-5-dancol@google.com> In-Reply-To: From: Andy Lutomirski Date: Sat, 12 Oct 2019 17:46:16 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 4/7] Teach SELinux about a new userfaultfd class To: Daniel Colascione Cc: Andy Lutomirski , Linux API , LKML , Lokesh Gidra , Nick Kralevich , Nosh Minwalla , Tim Murray 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, Oct 12, 2019 at 5:12 PM Daniel Colascione wrote: > > On Sat, Oct 12, 2019 at 4:09 PM Andy Lutomirski wrote: > > > > On Sat, Oct 12, 2019 at 12:16 PM Daniel Colascione wrote: > > > > > > Use the secure anonymous inode LSM hook we just added to let SELinux > > > policy place restrictions on userfaultfd use. The create operation > > > applies to processes creating new instances of these file objects; > > > transfer between processes is covered by restrictions on read, write, > > > and ioctl access already checked inside selinux_file_receive. > > > > This is great, and I suspect we'll want it for things like SGX, too. > > But the current design seems like it will make it essentially > > impossible for SELinux to reference an anon_inode class whose > > file_operations are in a module, and moving file_operations out of a > > module would be nasty. > > > > Could this instead be keyed off a new struct anon_inode_class, an > > enum, or even just a string? > > The new LSM hook already receives the string that callers pass to the > anon_inode APIs; modules can look at that instead of the fops if they > want. The reason to pass both the name and the fops through the hook > is to allow LSMs to match using fops comparison (which seems less > prone to breakage) when possible and rely on string matching when it > isn't. I suppose that whoever makes the first module that wants to use this mechanism can have the fun task of reworking it. There's nothing user-visible here that would make it hard to change in the future.