Received: by 2002:a05:6512:e85:0:0:0:0 with SMTP id bi5csp3102707lfb; Tue, 28 Jun 2022 06:34:47 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tXT9NJqcPEnyRsc2LcWMqnArnEmN2N6zAISpVoZ2lJDN2urtn7HpIf5XM/DUlPwsLqbTh6 X-Received: by 2002:a05:6402:5c9:b0:420:aac6:257b with SMTP id n9-20020a05640205c900b00420aac6257bmr23192908edx.128.1656423287583; Tue, 28 Jun 2022 06:34:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656423287; cv=none; d=google.com; s=arc-20160816; b=bATN6Xsov6bNqIr4azTagovAAugtCtZybFm1pBlEKpCCPa+FOiOCkQpwvcfHBFP6oo PlpmXcDHIlTGMob6czSvT5Amv4bW6ADsK9QKLFuk3NEC4YzUrKe3QrEWpQHykrim5kMl UF4v0Z5d3cG2r3sNGO0dAlr2wmYkCZwSbOVh2vgIL/mh4HtmueVfjP4fkTUDG4cZrN5i 1obQxvuCVqUEWEXmcwKenCrvCuc9Bj0DKplv1oIxBlVZy5MtXpjOnLXNW2MM6r9v0+xd EOidNdN8nl+yT/YOXFq8Bii2ucEFqBDdWR7iEZyG6RxKkcMcW77l2eh5MzBdoVOx9MVg RFLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=yDK1y6l77gTIknzSmN5wrHmLNLWbCzU2gwSdLoy46Mk=; b=ZKLAvp4AM4/r/j1TMHQBFmbpo/CAL3DceDQbTr3aK8UBxfD8zFEp+2ADF78zbks41l KopeQfWiNKkUKODOac1Gu/NLspH6mTZYvR5lhM3jajTfbP9oTha11ViA79vlnEC7dDnH wU8cFjGYRNvKjuFgkyAmPryvM34GIgR5XeyDt59uW3iHQ3EIDOojvcSnI6wptlBTf8TA S+cPvgEsLyO4EjjcFchPzP+Ko9/2uOvo0klUcV27Vs5zmTQNcpnAd9uLvM0kRnP23HtX hvF+Uz5Myzyv+xLn7reVYD6ZMnBfJGJydHiyRu6gZdyh8DAC+GcjdbW/bPfpgooFTWox 2Htw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LyA4r1T6; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r7-20020a05640251c700b004377a1786c2si11331235edd.581.2022.06.28.06.34.16; Tue, 28 Jun 2022 06:34:47 -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=@kernel.org header.s=k20201202 header.b=LyA4r1T6; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343937AbiF1N2I (ORCPT + 99 others); Tue, 28 Jun 2022 09:28:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346439AbiF1N13 (ORCPT ); Tue, 28 Jun 2022 09:27:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9769433354; Tue, 28 Jun 2022 06:26:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 33C43617C5; Tue, 28 Jun 2022 13:26:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D94BAC3411D; Tue, 28 Jun 2022 13:25:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656422759; bh=zWipI4/HuL6mWJ9CnZHWaGr7nNngJkU/KjLz7LVeqGc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LyA4r1T6XCkyVvzyhKhyQMp7L5HID1ud7C12uE5pFDCd96vOprVyNXKl5FyR600E5 eswmsaZ1tY1GFkcMyaGqPnoXa6Rn7o1iU/4pnlRAdUZ2GwwBliWT00an7Yfy1tO0qb TlE1Dy5EVSW6hmqCGiMg5+hldWvAlmMUI1E8xcBYt5XpQpTu2x3osanq1HzPrzl7gy YlaJDQTOV5qASJUR2ySS9rEL/TuWKeof3HP4eqCQMayUDLwxwy26PEgNPId7Dquqm1 lkr9NFgj7OdCWAb7uIOiqxvoLiqBz6sirG1ckL1m971PqsAe3eS+JUZp3fVRfwb6sR ZyCQ0PBQmMf3g== Date: Tue, 28 Jun 2022 15:25:52 +0200 From: Christian Brauner To: Greg Kroah-Hartman Cc: Mimi Zohar , James Bottomley , Nayna Jain , linuxppc-dev@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-efi@vger.kernel.org, linux-security-module , linux-kernel@vger.kernel.org, Michael Ellerman , Dov Murik , George Wilson , gjoyce@ibm.com, Matthew Garrett , Dave Hansen , Benjamin Herrenschmidt , Paul Mackerras Subject: Re: [RFC PATCH v2 2/3] fs: define a firmware security filesystem named fwsecurityfs Message-ID: <20220628132552.ryjlz2dou52sghhr@wittgenstein> References: <20220622215648.96723-1-nayna@linux.ibm.com> <20220622215648.96723-3-nayna@linux.ibm.com> <41ca51e8db9907d9060cc38adb59a66dcae4c59b.camel@HansenPartnership.com> <54af4a92356090d88639531413ea8cb46837bd18.camel@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,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 Mon, Jun 27, 2022 at 09:37:28AM +0200, Greg Kroah-Hartman wrote: > On Sun, Jun 26, 2022 at 11:48:06AM -0400, Mimi Zohar wrote: > > On Thu, 2022-06-23 at 09:23 -0400, James Bottomley wrote: > > > On Thu, 2022-06-23 at 10:54 +0200, Greg Kroah-Hartman wrote: > > > [...] > > > > > diff --git a/fs/fwsecurityfs/inode.c b/fs/fwsecurityfs/inode.c > > > > > new file mode 100644 > > > > > index 000000000000..5d06dc0de059 > > > > > --- /dev/null > > > > > +++ b/fs/fwsecurityfs/inode.c > > > > > @@ -0,0 +1,159 @@ > > > > > +// SPDX-License-Identifier: GPL-2.0-only > > > > > +/* > > > > > + * Copyright (C) 2022 IBM Corporation > > > > > + * Author: Nayna Jain > > > > > + */ > > > > > + > > > > > +#include > > > > > +#include > > > > > +#include > > > > > +#include > > > > > +#include > > > > > +#include > > > > > +#include > > > > > +#include > > > > > +#include > > > > > +#include > > > > > +#include > > > > > +#include > > > > > +#include > > > > > + > > > > > +#include "internal.h" > > > > > + > > > > > +int fwsecurityfs_remove_file(struct dentry *dentry) > > > > > +{ > > > > > + drop_nlink(d_inode(dentry)); > > > > > + dput(dentry); > > > > > + return 0; > > > > > +}; > > > > > +EXPORT_SYMBOL_GPL(fwsecurityfs_remove_file); > > > > > + > > > > > +int fwsecurityfs_create_file(const char *name, umode_t mode, > > > > > + u16 filesize, struct dentry > > > > > *parent, > > > > > + struct dentry *dentry, > > > > > + const struct file_operations > > > > > *fops) > > > > > +{ > > > > > + struct inode *inode; > > > > > + int error; > > > > > + struct inode *dir; > > > > > + > > > > > + if (!parent) > > > > > + return -EINVAL; > > > > > + > > > > > + dir = d_inode(parent); > > > > > + pr_debug("securityfs: creating file '%s'\n", name); > > > > > > > > Did you forget to call simple_pin_fs() here or anywhere else? > > > > > > > > And this can be just one function with the directory creation file, > > > > just check the mode and you will be fine. Look at securityfs as an > > > > example of how to make this simpler. > > > > > > Actually, before you go down this route can you consider the namespace > > > ramifications. In fact we're just having to rework securityfs to pull > > > out all the simple_pin_... calls because simple_pin_... is completely > > > inimical to namespaces. I described this at length in the securityfs namespacing thread at various points. simple_pin_*() should be avoided if possible. Ideally the filesystem will just be cleaned up on umount. There might be a reason to make it survive umounts if you have state that stays around and somehow is intimately tied to that filesystem. > > > > > > The first thing to consider is if you simply use securityfs you'll > > > inherit all the simple_pin_... removal work and be namespace ready. It > > > could be that creating a new filesystem that can't be namespaced is the > > > right thing to do here, but at least ask the question: would we ever > > > want any of these files to be presented selectively inside containers? > > > If the answer is "yes" then simple_pin_... is the wrong interface. > > > > Greg, the securityfs changes James is referring to are part of the IMA > > namespacing patch set: > > https://lore.kernel.org/linux-integrity/20220420140633.753772-1-stefanb@linux.ibm.com/ > > > > I'd really appreciate your reviewing the first two patches: > > [PATCH v12 01/26] securityfs: rework dentry creation > > [PATCH v12 02/26] securityfs: Extend securityfs with namespacing > > support > > Looks like others have already reviewed them, they seem sane to me if > they past testing. Thanks for taking a look.