mirror of
https://github.com/torvalds/linux.git
synced 2024-11-25 05:32:00 +00:00
lsm: use lsm_prop in security_ipc_getsecid
There may be more than one LSM that provides IPC data for auditing. Change security_ipc_getsecid() to fill in a lsm_prop structure instead of the u32 secid. Change the name to security_ipc_getlsmprop() to reflect the change. Cc: audit@vger.kernel.org Cc: linux-security-module@vger.kernel.org Cc: selinux@vger.kernel.org Signed-off-by: Casey Schaufler <casey@schaufler-ca.com> [PM: subject line tweak] Signed-off-by: Paul Moore <paul@paul-moore.com>
This commit is contained in:
parent
7183abccd8
commit
f4602f163c
@ -256,8 +256,8 @@ LSM_HOOK(void, LSM_RET_VOID, task_to_inode, struct task_struct *p,
|
||||
struct inode *inode)
|
||||
LSM_HOOK(int, 0, userns_create, const struct cred *cred)
|
||||
LSM_HOOK(int, 0, ipc_permission, struct kern_ipc_perm *ipcp, short flag)
|
||||
LSM_HOOK(void, LSM_RET_VOID, ipc_getsecid, struct kern_ipc_perm *ipcp,
|
||||
u32 *secid)
|
||||
LSM_HOOK(void, LSM_RET_VOID, ipc_getlsmprop, struct kern_ipc_perm *ipcp,
|
||||
struct lsm_prop *prop)
|
||||
LSM_HOOK(int, 0, msg_msg_alloc_security, struct msg_msg *msg)
|
||||
LSM_HOOK(void, LSM_RET_VOID, msg_msg_free_security, struct msg_msg *msg)
|
||||
LSM_HOOK(int, 0, msg_queue_alloc_security, struct kern_ipc_perm *perm)
|
||||
|
@ -289,6 +289,17 @@ static inline const char *kernel_load_data_id_str(enum kernel_load_data_id id)
|
||||
return kernel_load_data_str[id];
|
||||
}
|
||||
|
||||
/**
|
||||
* lsmprop_init - initialize a lsm_prop structure
|
||||
* @prop: Pointer to the data to initialize
|
||||
*
|
||||
* Set all secid for all modules to the specified value.
|
||||
*/
|
||||
static inline void lsmprop_init(struct lsm_prop *prop)
|
||||
{
|
||||
memset(prop, 0, sizeof(*prop));
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SECURITY
|
||||
|
||||
/**
|
||||
@ -515,7 +526,7 @@ int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
|
||||
void security_task_to_inode(struct task_struct *p, struct inode *inode);
|
||||
int security_create_user_ns(const struct cred *cred);
|
||||
int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
|
||||
void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid);
|
||||
void security_ipc_getlsmprop(struct kern_ipc_perm *ipcp, struct lsm_prop *prop);
|
||||
int security_msg_msg_alloc(struct msg_msg *msg);
|
||||
void security_msg_msg_free(struct msg_msg *msg);
|
||||
int security_msg_queue_alloc(struct kern_ipc_perm *msq);
|
||||
@ -1377,9 +1388,10 @@ static inline int security_ipc_permission(struct kern_ipc_perm *ipcp,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
|
||||
static inline void security_ipc_getlsmprop(struct kern_ipc_perm *ipcp,
|
||||
struct lsm_prop *prop)
|
||||
{
|
||||
*secid = 0;
|
||||
lsmprop_init(prop);
|
||||
}
|
||||
|
||||
static inline int security_msg_msg_alloc(struct msg_msg *msg)
|
||||
|
@ -2638,8 +2638,7 @@ void __audit_ipc_obj(struct kern_ipc_perm *ipcp)
|
||||
context->ipc.gid = ipcp->gid;
|
||||
context->ipc.mode = ipcp->mode;
|
||||
context->ipc.has_perm = 0;
|
||||
/* scaffolding */
|
||||
security_ipc_getsecid(ipcp, &context->ipc.oprop.scaffold.secid);
|
||||
security_ipc_getlsmprop(ipcp, &context->ipc.oprop);
|
||||
context->type = AUDIT_IPC;
|
||||
}
|
||||
|
||||
|
@ -3730,17 +3730,17 @@ int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag)
|
||||
}
|
||||
|
||||
/**
|
||||
* security_ipc_getsecid() - Get the sysv ipc object's secid
|
||||
* security_ipc_getlsmprop() - Get the sysv ipc object LSM data
|
||||
* @ipcp: ipc permission structure
|
||||
* @secid: secid pointer
|
||||
* @prop: pointer to lsm information
|
||||
*
|
||||
* Get the secid associated with the ipc object. In case of failure, @secid
|
||||
* will be set to zero.
|
||||
* Get the lsm information associated with the ipc object.
|
||||
*/
|
||||
void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
|
||||
|
||||
void security_ipc_getlsmprop(struct kern_ipc_perm *ipcp, struct lsm_prop *prop)
|
||||
{
|
||||
*secid = 0;
|
||||
call_void_hook(ipc_getsecid, ipcp, secid);
|
||||
lsmprop_init(prop);
|
||||
call_void_hook(ipc_getlsmprop, ipcp, prop);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6319,10 +6319,13 @@ static int selinux_ipc_permission(struct kern_ipc_perm *ipcp, short flag)
|
||||
return ipc_has_perm(ipcp, av);
|
||||
}
|
||||
|
||||
static void selinux_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
|
||||
static void selinux_ipc_getlsmprop(struct kern_ipc_perm *ipcp,
|
||||
struct lsm_prop *prop)
|
||||
{
|
||||
struct ipc_security_struct *isec = selinux_ipc(ipcp);
|
||||
*secid = isec->sid;
|
||||
prop->selinux.secid = isec->sid;
|
||||
/* scaffolding */
|
||||
prop->scaffold.secid = isec->sid;
|
||||
}
|
||||
|
||||
static void selinux_d_instantiate(struct dentry *dentry, struct inode *inode)
|
||||
@ -7215,7 +7218,7 @@ static struct security_hook_list selinux_hooks[] __ro_after_init = {
|
||||
LSM_HOOK_INIT(userns_create, selinux_userns_create),
|
||||
|
||||
LSM_HOOK_INIT(ipc_permission, selinux_ipc_permission),
|
||||
LSM_HOOK_INIT(ipc_getsecid, selinux_ipc_getsecid),
|
||||
LSM_HOOK_INIT(ipc_getlsmprop, selinux_ipc_getlsmprop),
|
||||
|
||||
LSM_HOOK_INIT(msg_queue_associate, selinux_msg_queue_associate),
|
||||
LSM_HOOK_INIT(msg_queue_msgctl, selinux_msg_queue_msgctl),
|
||||
|
@ -3435,16 +3435,18 @@ static int smack_ipc_permission(struct kern_ipc_perm *ipp, short flag)
|
||||
}
|
||||
|
||||
/**
|
||||
* smack_ipc_getsecid - Extract smack security id
|
||||
* smack_ipc_getlsmprop - Extract smack security data
|
||||
* @ipp: the object permissions
|
||||
* @secid: where result will be saved
|
||||
* @prop: where result will be saved
|
||||
*/
|
||||
static void smack_ipc_getsecid(struct kern_ipc_perm *ipp, u32 *secid)
|
||||
static void smack_ipc_getlsmprop(struct kern_ipc_perm *ipp, struct lsm_prop *prop)
|
||||
{
|
||||
struct smack_known **blob = smack_ipc(ipp);
|
||||
struct smack_known *iskp = *blob;
|
||||
struct smack_known **iskpp = smack_ipc(ipp);
|
||||
struct smack_known *iskp = *iskpp;
|
||||
|
||||
*secid = iskp->smk_secid;
|
||||
prop->smack.skp = iskp;
|
||||
/* scaffolding */
|
||||
prop->scaffold.secid = iskp->smk_secid;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -5140,7 +5142,7 @@ static struct security_hook_list smack_hooks[] __ro_after_init = {
|
||||
LSM_HOOK_INIT(task_to_inode, smack_task_to_inode),
|
||||
|
||||
LSM_HOOK_INIT(ipc_permission, smack_ipc_permission),
|
||||
LSM_HOOK_INIT(ipc_getsecid, smack_ipc_getsecid),
|
||||
LSM_HOOK_INIT(ipc_getlsmprop, smack_ipc_getlsmprop),
|
||||
|
||||
LSM_HOOK_INIT(msg_msg_alloc_security, smack_msg_msg_alloc_security),
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user