mirror of
https://github.com/torvalds/linux.git
synced 2024-11-21 19:46:16 +00:00
lsm: use lsm_prop in security_inode_getsecid
Change the security_inode_getsecid() interface to fill in a lsm_prop structure instead of a u32 secid. This allows for its callers to gather data from all registered LSMs. Data is provided for IMA and audit. Change the name to security_inode_getlsmprop(). Cc: linux-integrity@vger.kernel.org Cc: selinux@vger.kernel.org Signed-off-by: Casey Schaufler <casey@schaufler-ca.com> [PM: subj line tweak] Signed-off-by: Paul Moore <paul@paul-moore.com>
This commit is contained in:
parent
37f670aacd
commit
07f9d2c113
@ -176,7 +176,8 @@ LSM_HOOK(int, -EOPNOTSUPP, inode_setsecurity, struct inode *inode,
|
||||
const char *name, const void *value, size_t size, int flags)
|
||||
LSM_HOOK(int, 0, inode_listsecurity, struct inode *inode, char *buffer,
|
||||
size_t buffer_size)
|
||||
LSM_HOOK(void, LSM_RET_VOID, inode_getsecid, struct inode *inode, u32 *secid)
|
||||
LSM_HOOK(void, LSM_RET_VOID, inode_getlsmprop, struct inode *inode,
|
||||
struct lsm_prop *prop)
|
||||
LSM_HOOK(int, 0, inode_copy_up, struct dentry *src, struct cred **new)
|
||||
LSM_HOOK(int, -EOPNOTSUPP, inode_copy_up_xattr, struct dentry *src,
|
||||
const char *name)
|
||||
|
@ -452,7 +452,7 @@ int security_inode_getsecurity(struct mnt_idmap *idmap,
|
||||
void **buffer, bool alloc);
|
||||
int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
|
||||
int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
|
||||
void security_inode_getsecid(struct inode *inode, u32 *secid);
|
||||
void security_inode_getlsmprop(struct inode *inode, struct lsm_prop *prop);
|
||||
int security_inode_copy_up(struct dentry *src, struct cred **new);
|
||||
int security_inode_copy_up_xattr(struct dentry *src, const char *name);
|
||||
int security_inode_setintegrity(const struct inode *inode,
|
||||
@ -1076,9 +1076,10 @@ static inline int security_inode_listsecurity(struct inode *inode, char *buffer,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void security_inode_getsecid(struct inode *inode, u32 *secid)
|
||||
static inline void security_inode_getlsmprop(struct inode *inode,
|
||||
struct lsm_prop *prop)
|
||||
{
|
||||
*secid = 0;
|
||||
lsmprop_init(prop);
|
||||
}
|
||||
|
||||
static inline int security_inode_copy_up(struct dentry *src, struct cred **new)
|
||||
|
@ -2276,13 +2276,17 @@ static void audit_copy_inode(struct audit_names *name,
|
||||
const struct dentry *dentry,
|
||||
struct inode *inode, unsigned int flags)
|
||||
{
|
||||
struct lsm_prop prop;
|
||||
|
||||
name->ino = inode->i_ino;
|
||||
name->dev = inode->i_sb->s_dev;
|
||||
name->mode = inode->i_mode;
|
||||
name->uid = inode->i_uid;
|
||||
name->gid = inode->i_gid;
|
||||
name->rdev = inode->i_rdev;
|
||||
security_inode_getsecid(inode, &name->osid);
|
||||
security_inode_getlsmprop(inode, &prop);
|
||||
/* scaffolding */
|
||||
name->osid = prop.scaffold.secid;
|
||||
if (flags & AUDIT_INODE_NOEVAL) {
|
||||
name->fcap_ver = -1;
|
||||
return;
|
||||
|
@ -649,8 +649,7 @@ static bool ima_match_rules(struct ima_rule_entry *rule,
|
||||
case LSM_OBJ_USER:
|
||||
case LSM_OBJ_ROLE:
|
||||
case LSM_OBJ_TYPE:
|
||||
/* scaffolding */
|
||||
security_inode_getsecid(inode, &prop.scaffold.secid);
|
||||
security_inode_getlsmprop(inode, &prop);
|
||||
rc = ima_filter_rule_match(&prop, lsm_rule->lsm[i].type,
|
||||
Audit_equal,
|
||||
lsm_rule->lsm[i].rule);
|
||||
|
@ -2724,16 +2724,15 @@ int security_inode_listsecurity(struct inode *inode,
|
||||
EXPORT_SYMBOL(security_inode_listsecurity);
|
||||
|
||||
/**
|
||||
* security_inode_getsecid() - Get an inode's secid
|
||||
* security_inode_getlsmprop() - Get an inode's LSM data
|
||||
* @inode: inode
|
||||
* @secid: secid to return
|
||||
* @prop: lsm specific information to return
|
||||
*
|
||||
* Get the secid associated with the node. In case of failure, @secid will be
|
||||
* set to zero.
|
||||
* Get the lsm specific information associated with the node.
|
||||
*/
|
||||
void security_inode_getsecid(struct inode *inode, u32 *secid)
|
||||
void security_inode_getlsmprop(struct inode *inode, struct lsm_prop *prop)
|
||||
{
|
||||
call_void_hook(inode_getsecid, inode, secid);
|
||||
call_void_hook(inode_getlsmprop, inode, prop);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3503,15 +3503,18 @@ static int selinux_inode_listsecurity(struct inode *inode, char *buffer, size_t
|
||||
return len;
|
||||
}
|
||||
|
||||
static void selinux_inode_getsecid(struct inode *inode, u32 *secid)
|
||||
static void selinux_inode_getlsmprop(struct inode *inode, struct lsm_prop *prop)
|
||||
{
|
||||
struct inode_security_struct *isec = inode_security_novalidate(inode);
|
||||
*secid = isec->sid;
|
||||
|
||||
prop->selinux.secid = isec->sid;
|
||||
/* scaffolding */
|
||||
prop->scaffold.secid = isec->sid;
|
||||
}
|
||||
|
||||
static int selinux_inode_copy_up(struct dentry *src, struct cred **new)
|
||||
{
|
||||
u32 sid;
|
||||
struct lsm_prop prop;
|
||||
struct task_security_struct *tsec;
|
||||
struct cred *new_creds = *new;
|
||||
|
||||
@ -3523,8 +3526,8 @@ static int selinux_inode_copy_up(struct dentry *src, struct cred **new)
|
||||
|
||||
tsec = selinux_cred(new_creds);
|
||||
/* Get label from overlay inode and set it in create_sid */
|
||||
selinux_inode_getsecid(d_inode(src), &sid);
|
||||
tsec->create_sid = sid;
|
||||
selinux_inode_getlsmprop(d_inode(src), &prop);
|
||||
tsec->create_sid = prop.selinux.secid;
|
||||
*new = new_creds;
|
||||
return 0;
|
||||
}
|
||||
@ -7174,7 +7177,7 @@ static struct security_hook_list selinux_hooks[] __ro_after_init = {
|
||||
LSM_HOOK_INIT(inode_getsecurity, selinux_inode_getsecurity),
|
||||
LSM_HOOK_INIT(inode_setsecurity, selinux_inode_setsecurity),
|
||||
LSM_HOOK_INIT(inode_listsecurity, selinux_inode_listsecurity),
|
||||
LSM_HOOK_INIT(inode_getsecid, selinux_inode_getsecid),
|
||||
LSM_HOOK_INIT(inode_getlsmprop, selinux_inode_getlsmprop),
|
||||
LSM_HOOK_INIT(inode_copy_up, selinux_inode_copy_up),
|
||||
LSM_HOOK_INIT(inode_copy_up_xattr, selinux_inode_copy_up_xattr),
|
||||
LSM_HOOK_INIT(path_notify, selinux_path_notify),
|
||||
|
@ -1649,15 +1649,17 @@ static int smack_inode_listsecurity(struct inode *inode, char *buffer,
|
||||
}
|
||||
|
||||
/**
|
||||
* smack_inode_getsecid - Extract inode's security id
|
||||
* smack_inode_getlsmprop - Extract inode's security id
|
||||
* @inode: inode to extract the info from
|
||||
* @secid: where result will be saved
|
||||
* @prop: where result will be saved
|
||||
*/
|
||||
static void smack_inode_getsecid(struct inode *inode, u32 *secid)
|
||||
static void smack_inode_getlsmprop(struct inode *inode, struct lsm_prop *prop)
|
||||
{
|
||||
struct smack_known *skp = smk_of_inode(inode);
|
||||
|
||||
*secid = skp->smk_secid;
|
||||
prop->smack.skp = skp;
|
||||
/* scaffolding */
|
||||
prop->scaffold.secid = skp->smk_secid;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -5110,7 +5112,7 @@ static struct security_hook_list smack_hooks[] __ro_after_init = {
|
||||
LSM_HOOK_INIT(inode_getsecurity, smack_inode_getsecurity),
|
||||
LSM_HOOK_INIT(inode_setsecurity, smack_inode_setsecurity),
|
||||
LSM_HOOK_INIT(inode_listsecurity, smack_inode_listsecurity),
|
||||
LSM_HOOK_INIT(inode_getsecid, smack_inode_getsecid),
|
||||
LSM_HOOK_INIT(inode_getlsmprop, smack_inode_getlsmprop),
|
||||
|
||||
LSM_HOOK_INIT(file_alloc_security, smack_file_alloc_security),
|
||||
LSM_HOOK_INIT(file_ioctl, smack_file_ioctl),
|
||||
|
Loading…
Reference in New Issue
Block a user