mirror of
https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10.git
synced 2026-09-09 00:07:04 +08:00
lsm: use lsm_context in security_inode_getsecctx
JIRA: https://issues.redhat.com/browse/RHEL-171581 Conflicts: context difference due to out-of-order backport of 531503054e8f ("nfsd: fix handling of delegated change attr in CB_GETATTR") commit 76ecf306ae5da84ef8f48c7a2608736e6866440c Author: Casey Schaufler <casey@schaufler-ca.com> Date: Wed Oct 23 14:21:56 2024 -0700 lsm: use lsm_context in security_inode_getsecctx Change the security_inode_getsecctx() interface to fill a lsm_context structure instead of data and length pointers. This provides the information about which LSM created the context so that security_release_secctx() can use the correct hook. Cc: linux-nfs@vger.kernel.org Signed-off-by: Casey Schaufler <casey@schaufler-ca.com> [PM: subject tweak] Signed-off-by: Paul Moore <paul@paul-moore.com> Signed-off-by: Olga Kornievskaia <okorniev@redhat.com>
This commit is contained in:
+6
-6
@@ -4008,17 +4008,17 @@ EXPORT_SYMBOL(security_inode_setsecctx);
|
||||
/**
|
||||
* security_inode_getsecctx() - Get the security label of an inode
|
||||
* @inode: inode
|
||||
* @ctx: secctx
|
||||
* @ctxlen: length of secctx
|
||||
* @cp: security context
|
||||
*
|
||||
* On success, returns 0 and fills out @ctx and @ctxlen with the security
|
||||
* context for the given @inode.
|
||||
* On success, returns 0 and fills out @cp with the security context
|
||||
* for the given @inode.
|
||||
*
|
||||
* Return: Returns 0 on success, error on failure.
|
||||
*/
|
||||
int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
|
||||
int security_inode_getsecctx(struct inode *inode, struct lsm_context *cp)
|
||||
{
|
||||
return call_int_hook(inode_getsecctx, inode, ctx, ctxlen);
|
||||
memset(cp, 0, sizeof(*cp));
|
||||
return call_int_hook(inode_getsecctx, inode, cp);
|
||||
}
|
||||
EXPORT_SYMBOL(security_inode_getsecctx);
|
||||
|
||||
|
||||
@@ -6793,14 +6793,16 @@ static int selinux_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
|
||||
ctx, ctxlen, 0, NULL);
|
||||
}
|
||||
|
||||
static int selinux_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
|
||||
static int selinux_inode_getsecctx(struct inode *inode, struct lsm_context *cp)
|
||||
{
|
||||
int len = 0;
|
||||
int len;
|
||||
len = selinux_inode_getsecurity(&nop_mnt_idmap, inode,
|
||||
XATTR_SELINUX_SUFFIX, ctx, true);
|
||||
XATTR_SELINUX_SUFFIX,
|
||||
(void **)&cp->context, true);
|
||||
if (len < 0)
|
||||
return len;
|
||||
*ctxlen = len;
|
||||
cp->len = len;
|
||||
cp->id = LSM_ID_SELINUX;
|
||||
return 0;
|
||||
}
|
||||
#ifdef CONFIG_KEYS
|
||||
|
||||
@@ -4898,12 +4898,13 @@ static int smack_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
|
||||
ctx, ctxlen, 0, NULL);
|
||||
}
|
||||
|
||||
static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
|
||||
static int smack_inode_getsecctx(struct inode *inode, struct lsm_context *cp)
|
||||
{
|
||||
struct smack_known *skp = smk_of_inode(inode);
|
||||
|
||||
*ctx = skp->smk_known;
|
||||
*ctxlen = strlen(skp->smk_known);
|
||||
cp->context = skp->smk_known;
|
||||
cp->len = strlen(skp->smk_known);
|
||||
cp->id = LSM_ID_SMACK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user