From: Roberto Sassu <roberto.sassu@huaweicloud.com>
To: Paul Moore <paul@paul-moore.com>
Cc: zohar@linux.ibm.com, dmitry.kasatkin@gmail.com,
jmorris@namei.org, serge@hallyn.com,
stephen.smalley.work@gmail.com, eparis@parisplace.org,
casey@schaufler-ca.com, reiserfs-devel@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-integrity@vger.kernel.org,
linux-security-module@vger.kernel.org, selinux@vger.kernel.org,
bpf@vger.kernel.org, kpsingh@kernel.org, keescook@chromium.org,
nicolas.bouchinet@clip-os.org,
Roberto Sassu <roberto.sassu@huawei.com>,
stable@vger.kernel.org
Subject: Re: [PATCH v9 1/4] reiserfs: Add security prefix to xattr name in reiserfs_security_write()
Date: Fri, 31 Mar 2023 09:02:52 +0200 [thread overview]
Message-ID: <27ee02c2f6a01bf5ffd5cb2b29148721cd27c892.camel@huaweicloud.com> (raw)
In-Reply-To: <CAHC9VhRg7twUWXLH0xTaWc2MeSFExkGr9tJztYopzD0JEM-npw@mail.gmail.com>
On Thu, 2023-03-30 at 17:15 -0400, Paul Moore wrote:
> On Wed, Mar 29, 2023 at 9:05 AM Roberto Sassu
> <roberto.sassu@huaweicloud.com> wrote:
> > From: Roberto Sassu <roberto.sassu@huawei.com>
> >
> > Reiserfs sets a security xattr at inode creation time in two stages: first,
> > it calls reiserfs_security_init() to obtain the xattr from active LSMs;
> > then, it calls reiserfs_security_write() to actually write that xattr.
> >
> > Unfortunately, it seems there is a wrong expectation that LSMs provide the
> > full xattr name in the form 'security.<suffix>'. However, LSMs always
> > provided just the suffix, causing reiserfs to not write the xattr at all
> > (if the suffix is shorter than the prefix), or to write an xattr with the
> > wrong name.
> >
> > Add a temporary buffer in reiserfs_security_write(), and write to it the
> > full xattr name, before passing it to reiserfs_xattr_set_handle().
> >
> > Since the 'security.' prefix is always prepended, remove the name length
> > check.
> >
> > Cc: stable@vger.kernel.org # v2.6.x
> > Fixes: 57fe60df6241 ("reiserfs: add atomic addition of selinux attributes during inode creation")
> > Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
> > ---
> > fs/reiserfs/xattr_security.c | 8 +++++---
> > 1 file changed, 5 insertions(+), 3 deletions(-)
> >
> > diff --git a/fs/reiserfs/xattr_security.c b/fs/reiserfs/xattr_security.c
> > index 6bffdf9a4fd..b0c354ab113 100644
> > --- a/fs/reiserfs/xattr_security.c
> > +++ b/fs/reiserfs/xattr_security.c
> > @@ -95,11 +95,13 @@ int reiserfs_security_write(struct reiserfs_transaction_handle *th,
> > struct inode *inode,
> > struct reiserfs_security_handle *sec)
> > {
> > + char xattr_name[XATTR_NAME_MAX + 1];
> > int error;
> > - if (strlen(sec->name) < sizeof(XATTR_SECURITY_PREFIX))
> > - return -EINVAL;
>
> If one really wanted to be paranoid they could verify that
> 'XATTR_SECURITY_PREFIX_LEN + strlen(sec->name) <= XATTR_NAME_MAX' and
> return EINVAL, but that really shouldn't be an issue and if the
> concatenation does result in a xattr name that is too big, the
> snprintf() will safely truncate/managle it.
Ok, I could do it.
Thanks
Roberto
> Regardless, this patch is fine with me, but it would be nice if at
> least of the reiserfs/VFS folks could provide an ACK/Reviewed-by tag,
> although I think we can still move forward on this without one of
> those.
>
> > - error = reiserfs_xattr_set_handle(th, inode, sec->name, sec->value,
> > + snprintf(xattr_name, sizeof(xattr_name), "%s%s", XATTR_SECURITY_PREFIX,
> > + sec->name);
> > +
> > + error = reiserfs_xattr_set_handle(th, inode, xattr_name, sec->value,
> > sec->length, XATTR_CREATE);
> > if (error == -ENODATA || error == -EOPNOTSUPP)
> > error = 0;
> > --
> > 2.25.1
next prev parent reply other threads:[~2023-03-31 7:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-29 13:04 [PATCH v9 0/4] evm: Do HMAC of multiple per LSM xattrs for new inodes Roberto Sassu
2023-03-29 13:04 ` [PATCH v9 1/4] reiserfs: Add security prefix to xattr name in reiserfs_security_write() Roberto Sassu
2023-03-30 21:15 ` Paul Moore
2023-03-31 7:02 ` Roberto Sassu [this message]
2023-03-29 13:04 ` [PATCH v9 2/4] security: Allow all LSMs to provide xattrs for inode_init_security hook Roberto Sassu
2023-03-30 22:50 ` Paul Moore
2023-03-30 23:05 ` Casey Schaufler
2023-03-31 7:17 ` Roberto Sassu
2023-03-29 13:04 ` [PATCH v9 3/4] evm: Align evm_inode_init_security() definition with LSM infrastructure Roberto Sassu
2023-03-30 22:55 ` Paul Moore
2023-03-31 7:32 ` Roberto Sassu
2023-03-31 12:18 ` Roberto Sassu
2023-04-03 10:37 ` Mimi Zohar
2023-03-29 13:04 ` [PATCH v9 4/4] evm: Support multiple LSMs providing an xattr Roberto Sassu
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=27ee02c2f6a01bf5ffd5cb2b29148721cd27c892.camel@huaweicloud.com \
--to=roberto.sassu@huaweicloud.com \
--cc=bpf@vger.kernel.org \
--cc=casey@schaufler-ca.com \
--cc=dmitry.kasatkin@gmail.com \
--cc=eparis@parisplace.org \
--cc=jmorris@namei.org \
--cc=keescook@chromium.org \
--cc=kpsingh@kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=nicolas.bouchinet@clip-os.org \
--cc=paul@paul-moore.com \
--cc=reiserfs-devel@vger.kernel.org \
--cc=roberto.sassu@huawei.com \
--cc=selinux@vger.kernel.org \
--cc=serge@hallyn.com \
--cc=stable@vger.kernel.org \
--cc=stephen.smalley.work@gmail.com \
--cc=zohar@linux.ibm.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;
as well as URLs for NNTP newsgroup(s).