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 X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 515CAC4320A for ; Thu, 12 Aug 2021 13:09:50 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6EA7B61058 for ; Thu, 12 Aug 2021 13:09:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6EA7B61058 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-230-0O2Rh4cvML-mzZP9aKuq3Q-1; Thu, 12 Aug 2021 09:09:47 -0400 X-MC-Unique: 0O2Rh4cvML-mzZP9aKuq3Q-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3EF39871812; Thu, 12 Aug 2021 13:09:20 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 42265620DE; Thu, 12 Aug 2021 13:09:19 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E670E4BB7B; Thu, 12 Aug 2021 13:09:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17CAA04r011497 for ; Thu, 12 Aug 2021 06:10:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id EF789107514; Thu, 12 Aug 2021 10:09:59 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EAC0A107673 for ; Thu, 12 Aug 2021 10:09:57 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5B438101A529 for ; Thu, 12 Aug 2021 10:09:57 +0000 (UTC) Received: from smtp-190c.mail.infomaniak.ch (smtp-190c.mail.infomaniak.ch [185.125.25.12]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-381-hwjkXc04M-eFOZ6HerbN_g-1; Thu, 12 Aug 2021 06:09:55 -0400 X-MC-Unique: hwjkXc04M-eFOZ6HerbN_g-1 Received: from smtp-3-0001.mail.infomaniak.ch (unknown [10.4.36.108]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4GlhL80mW0zMptvC; Thu, 12 Aug 2021 11:32:32 +0200 (CEST) Received: from ns3096276.ip-94-23-54.eu (unknown [23.97.221.149]) by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4GlhL711hkzlmrry; Thu, 12 Aug 2021 11:32:31 +0200 (CEST) Subject: Re: [RFC PATCH v2 5/9] fs: add anon_inode_getfile_secure() similar to anon_inode_getfd_secure() To: Paul Moore , linux-security-module@vger.kernel.org, selinux@vger.kernel.org, linux-audit@redhat.com, io-uring@vger.kernel.org, linux-fsdevel@vger.kernel.org, Kumar Kartikeya Dwivedi , Jens Axboe , Pavel Begunkov References: <162871480969.63873.9434591871437326374.stgit@olly> <162871492283.63873.8743976556992924333.stgit@olly> From: =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= Message-ID: <1d19ca85-c6f9-7aa5-162a-f9728e0a8ccd@digikod.net> Date: Thu, 12 Aug 2021 11:32:15 +0200 User-Agent: MIME-Version: 1.0 In-Reply-To: <162871492283.63873.8743976556992924333.stgit@olly> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: linux-audit@redhat.com X-Mailman-Approved-At: Thu, 12 Aug 2021 09:06:52 -0400 X-BeenThere: linux-audit@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Linux Audit Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-audit-bounces@redhat.com Errors-To: linux-audit-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=linux-audit-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On 11/08/2021 22:48, Paul Moore wrote: > Extending the secure anonymous inode support to other subsystems > requires that we have a secure anon_inode_getfile() variant in > addition to the existing secure anon_inode_getfd() variant. > > Thankfully we can reuse the existing __anon_inode_getfile() function > and just wrap it with the proper arguments. > > Signed-off-by: Paul Moore > > --- > v2: > - no change > v1: > - initial draft > --- > fs/anon_inodes.c | 29 +++++++++++++++++++++++++++++ > include/linux/anon_inodes.h | 4 ++++ > 2 files changed, 33 insertions(+) > > diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c > index a280156138ed..e0c3e33c4177 100644 > --- a/fs/anon_inodes.c > +++ b/fs/anon_inodes.c > @@ -148,6 +148,35 @@ struct file *anon_inode_getfile(const char *name, > } > EXPORT_SYMBOL_GPL(anon_inode_getfile); > > +/** > + * anon_inode_getfile_secure - Like anon_inode_getfile(), but creates a new > + * !S_PRIVATE anon inode rather than reuse the > + * singleton anon inode and calls the > + * inode_init_security_anon() LSM hook. This > + * allows for both the inode to have its own > + * security context and for the LSM to enforce > + * policy on the inode's creation. > + * > + * @name: [in] name of the "class" of the new file > + * @fops: [in] file operations for the new file > + * @priv: [in] private data for the new file (will be file's private_data) > + * @flags: [in] flags > + * @context_inode: > + * [in] the logical relationship with the new inode (optional) > + * > + * The LSM may use @context_inode in inode_init_security_anon(), but a > + * reference to it is not held. Returns the newly created file* or an error > + * pointer. See the anon_inode_getfile() documentation for more information. > + */ > +struct file *anon_inode_getfile_secure(const char *name, > + const struct file_operations *fops, > + void *priv, int flags, > + const struct inode *context_inode) > +{ > + return __anon_inode_getfile(name, fops, priv, flags, > + context_inode, true); This is not directly related to this patch but why using the "secure" boolean in __anon_inode_getfile() and __anon_inode_getfd() instead of checking that context_inode is not NULL? This would simplify the code, remove this anon_inode_getfile_secure() wrapper and avoid potential inconsistencies. > +} > + > static int __anon_inode_getfd(const char *name, > const struct file_operations *fops, > void *priv, int flags, > diff --git a/include/linux/anon_inodes.h b/include/linux/anon_inodes.h > index 71881a2b6f78..5deaddbd7927 100644 > --- a/include/linux/anon_inodes.h > +++ b/include/linux/anon_inodes.h > @@ -15,6 +15,10 @@ struct inode; > struct file *anon_inode_getfile(const char *name, > const struct file_operations *fops, > void *priv, int flags); > +struct file *anon_inode_getfile_secure(const char *name, > + const struct file_operations *fops, > + void *priv, int flags, > + const struct inode *context_inode); > int anon_inode_getfd(const char *name, const struct file_operations *fops, > void *priv, int flags); > int anon_inode_getfd_secure(const char *name, > -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit