CEPH-Devel archive mirror
 help / color / mirror / Atom feed
From: Casey Schaufler <casey@schaufler-ca.com>
To: Xiubo Li <xiubli@redhat.com>,
	paul@paul-moore.com, linux-security-module@vger.kernel.org
Cc: jmorris@namei.org, serge@hallyn.com, keescook@chromium.org,
	john.johansen@canonical.com, penguin-kernel@i-love.sakura.ne.jp,
	stephen.smalley.work@gmail.com, linux-kernel@vger.kernel.org,
	mic@digikod.net, ceph-devel@vger.kernel.org,
	linux-nfs@vger.kernel.org,
	Casey Schaufler <casey@schaufler-ca.com>
Subject: Re: [PATCH v39 20/42] LSM: Use lsmcontext in security_dentry_init_security
Date: Mon, 18 Dec 2023 08:55:03 -0800	[thread overview]
Message-ID: <8d6889bb-e874-4388-a36c-22df720a00aa@schaufler-ca.com> (raw)
In-Reply-To: <ab373a38-7800-4056-9ac4-31fef643c6b1@redhat.com>

On 12/17/2023 6:50 PM, Xiubo Li wrote:
>
> On 12/16/23 06:16, Casey Schaufler wrote:
>> Replace the (secctx,seclen) pointer pair with a single
>> lsmcontext pointer to allow return of the LSM identifier
>> along with the context and context length. This allows
>> security_release_secctx() to know how to release the
>> context. Callers have been modified to use or save the
>> returned data from the new structure.
>>
>> Special care is taken in the NFS code, which uses the
>> same data structure for its own copied labels as it does
>> for the data which comes from security_dentry_init_security().
>> In the case of copied labels the data has to be freed, not
>> released.
>>
>> Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
>> Cc: ceph-devel@vger.kernel.org
>> Cc: linux-nfs@vger.kernel.org
>> ---
>>   fs/ceph/super.h               |  3 +--
>>   fs/ceph/xattr.c               | 19 ++++++-------------
>>   fs/fuse/dir.c                 | 35 ++++++++++++++++++-----------------
>>   fs/nfs/dir.c                  |  2 +-
>>   fs/nfs/inode.c                | 17 ++++++++++-------
>>   fs/nfs/internal.h             |  8 +++++---
>>   fs/nfs/nfs4proc.c             | 22 +++++++++-------------
>>   fs/nfs/nfs4xdr.c              | 22 ++++++++++++----------
>>   include/linux/lsm_hook_defs.h |  2 +-
>>   include/linux/nfs4.h          |  8 ++++----
>>   include/linux/nfs_fs.h        |  2 +-
>>   include/linux/security.h      |  7 +++----
>>   security/security.c           |  9 ++++-----
>>   security/selinux/hooks.c      |  9 +++++----
>>   14 files changed, 80 insertions(+), 85 deletions(-)
>>
>> diff --git a/fs/ceph/super.h b/fs/ceph/super.h
>> index fe0f64a0acb2..d503cc7478b7 100644
>> --- a/fs/ceph/super.h
>> +++ b/fs/ceph/super.h
>> @@ -1133,8 +1133,7 @@ struct ceph_acl_sec_ctx {
>>       void *acl;
>>   #endif
>>   #ifdef CONFIG_CEPH_FS_SECURITY_LABEL
>> -    void *sec_ctx;
>> -    u32 sec_ctxlen;
>> +    struct lsmcontext lsmctx;
>>   #endif
>>   #ifdef CONFIG_FS_ENCRYPTION
>>       struct ceph_fscrypt_auth *fscrypt_auth;
>> diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
>> index 113956d386c0..4c767a20ac4c 100644
>> --- a/fs/ceph/xattr.c
>> +++ b/fs/ceph/xattr.c
>> @@ -1383,8 +1383,7 @@ int ceph_security_init_secctx(struct dentry
>> *dentry, umode_t mode,
>>       int err;
>>         err = security_dentry_init_security(dentry, mode,
>> &dentry->d_name,
>> -                        &name, &as_ctx->sec_ctx,
>> -                        &as_ctx->sec_ctxlen);
>> +                        &name, &as_ctx->lsmctx);
>>       if (err < 0) {
>>           WARN_ON_ONCE(err != -EOPNOTSUPP);
>>           err = 0; /* do nothing */
>> @@ -1409,7 +1408,7 @@ int ceph_security_init_secctx(struct dentry
>> *dentry, umode_t mode,
>>        */
>>       name_len = strlen(name);
>>       err = ceph_pagelist_reserve(pagelist,
>> -                    4 * 2 + name_len + as_ctx->sec_ctxlen);
>> +                    4 * 2 + name_len + as_ctx->lsmctx.len);
>>       if (err)
>>           goto out;
>>   @@ -1429,11 +1428,9 @@ int ceph_security_init_secctx(struct dentry
>> *dentry, umode_t mode,
>>           as_ctx->pagelist = pagelist;
>>       }
>>   -    ceph_pagelist_encode_32(pagelist, name_len);
>> -    ceph_pagelist_append(pagelist, name, name_len);
>> -
>
> Why remove these ?

Looks like I have a merge error. Thank you for reviewing.
I will repair this.

>
>> -    ceph_pagelist_encode_32(pagelist, as_ctx->sec_ctxlen);
>> -    ceph_pagelist_append(pagelist, as_ctx->sec_ctx,
>> as_ctx->sec_ctxlen);
>> +    ceph_pagelist_encode_32(pagelist, as_ctx->lsmctx.len);
>> +    ceph_pagelist_append(pagelist, as_ctx->lsmctx.context,
>> +                 as_ctx->lsmctx.len);
>>     
> [...]
>
> Thanks,
>
> - Xiubo
>

      reply	other threads:[~2023-12-18 16:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20231215221636.105680-1-casey@schaufler-ca.com>
2023-12-15 22:16 ` [PATCH v39 20/42] LSM: Use lsmcontext in security_dentry_init_security Casey Schaufler
2023-12-18  2:50   ` Xiubo Li
2023-12-18 16:55     ` Casey Schaufler [this message]

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=8d6889bb-e874-4388-a36c-22df720a00aa@schaufler-ca.com \
    --to=casey@schaufler-ca.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=jmorris@namei.org \
    --cc=john.johansen@canonical.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=mic@digikod.net \
    --cc=paul@paul-moore.com \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=serge@hallyn.com \
    --cc=stephen.smalley.work@gmail.com \
    --cc=xiubli@redhat.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 read-only IMAP folder(s) and NNTP newsgroup(s).