From: Al Viro <viro@zeniv.linux.org.uk>
To: David Howells <dhowells@redhat.com>
Cc: Jeff Layton <jlayton@kernel.org>,
Trond Myklebust <trond.myklebust@hammerspace.com>,
Anna Schumaker <anna@kernel.org>,
Scott Mayhew <smayhew@redhat.com>,
Paul Moore <paul@paul-moore.com>,
Casey Schaufler <casey@schaufler-ca.com>,
linux-nfs@vger.kernel.org, selinux@vger.kernel.org,
linux-security-module@vger.kernel.org,
linux-fsdevel@vger.kernel.org, dwysocha@redhat.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] vfs, security: Fix automount superblock LSM init problem, preventing NFS sb sharing
Date: Thu, 1 Sep 2022 06:04:20 +0100 [thread overview]
Message-ID: <YxA9VJuQpQSgGnhB@ZenIV> (raw)
In-Reply-To: <166133579016.3678898.6283195019480567275.stgit@warthog.procyon.org.uk>
On Wed, Aug 24, 2022 at 11:09:50AM +0100, David Howells wrote:
What's the reason for difference between selinux and smack instances of
context_init? The former allocates only on submount, the latter -
unconditionally...
> +static int selinux_fs_context_init(struct fs_context *fc,
> + struct dentry *reference)
> +{
> + const struct superblock_security_struct *sbsec;
> + const struct inode_security_struct *root_isec;
> + struct selinux_mnt_opts *opts;
> +
> + if (fc->purpose == FS_CONTEXT_FOR_SUBMOUNT) {
> + opts = kzalloc(sizeof(*opts), GFP_KERNEL);
> + if (!opts)
> + return -ENOMEM;
> +
> + root_isec = backing_inode_security(reference->d_sb->s_root);
> + sbsec = selinux_superblock(reference->d_sb);
> + if (sbsec->flags & FSCONTEXT_MNT)
> + opts->fscontext_sid = sbsec->sid;
> + if (sbsec->flags & CONTEXT_MNT)
> + opts->context_sid = sbsec->mntpoint_sid;
> + if (sbsec->flags & DEFCONTEXT_MNT)
> + opts->defcontext_sid = sbsec->def_sid;
> + fc->security = opts;
> + }
> +
> + return 0;
> +}
> +/**
> + * smack_fs_context_init - Initialise security data for a filesystem context
> + * @fc: The filesystem context.
> + * @reference: Reference dentry (automount/reconfigure) or NULL
> + *
> + * Returns 0 on success or -ENOMEM on error.
> + */
> +static int smack_fs_context_init(struct fs_context *fc,
> + struct dentry *reference)
> +{
> + struct superblock_smack *sbsp;
> + struct smack_mnt_opts *ctx;
> + struct inode_smack *isp;
> +
> + ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
> + if (!ctx)
> + return -ENOMEM;
> + fc->security = ctx;
> +
> + if (fc->purpose == FS_CONTEXT_FOR_SUBMOUNT) {
> + sbsp = smack_superblock(reference->d_sb);
> + isp = smack_inode(reference->d_sb->s_root->d_inode);
next prev parent reply other threads:[~2022-09-01 5:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-24 10:09 [PATCH v4] vfs, security: Fix automount superblock LSM init problem, preventing NFS sb sharing David Howells
2022-08-26 8:24 ` Christian Brauner
2022-08-26 17:11 ` Casey Schaufler
2022-08-30 8:49 ` David Howells
2022-08-30 13:47 ` Casey Schaufler
2022-08-31 13:48 ` David Howells
2022-08-31 16:52 ` Casey Schaufler
2022-09-01 5:04 ` Al Viro [this message]
2022-09-01 11:47 ` David Howells
2022-09-08 19:35 ` Anna Schumaker
2022-09-08 20:31 ` David Howells
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YxA9VJuQpQSgGnhB@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=anna@kernel.org \
--cc=casey@schaufler-ca.com \
--cc=dhowells@redhat.com \
--cc=dwysocha@redhat.com \
--cc=jlayton@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=paul@paul-moore.com \
--cc=selinux@vger.kernel.org \
--cc=smayhew@redhat.com \
--cc=trond.myklebust@hammerspace.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox