UBUNTU: SAUCE: apparmor4.0.0 [21/90]: LSM stacking v39: LSM: security_lsmblob_to_secctx module selection
BugLink: http://bugs.launchpad.net/bugs/2028253 Add a parameter lsmid to security_lsmblob_to_secctx() to identify which of the security modules that may be active should provide the security context. If the value of lsmid is LSM_ID_UNDEF the first LSM providing a hook is used. security_secid_to_secctx() is unchanged, and will always report the first LSM providing a hook. Signed-off-by: Casey Schaufler <casey@schaufler-ca.com> (cherry picked from commit ed41de7417b55f261370bc5090095ed4d3f53d7a https://git.launchpad.net/~apparmor-dev/ubuntu-kernel-next) Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
This commit is contained in:
committed by
Paolo Pisati
parent
ce1ee7a40e
commit
81359c5d18
@@ -565,7 +565,8 @@ int security_setprocattr(int lsmid, const char *name, void *value, size_t size);
|
||||
int security_netlink_send(struct sock *sk, struct sk_buff *skb);
|
||||
int security_ismaclabel(const char *name);
|
||||
int security_secid_to_secctx(u32 secid, struct lsmcontext *cp);
|
||||
int security_lsmblob_to_secctx(struct lsmblob *blob, struct lsmcontext *cp);
|
||||
int security_lsmblob_to_secctx(struct lsmblob *blob, struct lsmcontext *cp,
|
||||
int lsmid);
|
||||
int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);
|
||||
void security_release_secctx(struct lsmcontext *cp);
|
||||
void security_inode_invalidate_secctx(struct inode *inode);
|
||||
@@ -1501,7 +1502,7 @@ static inline int security_secid_to_secctx(u32 secid, struct lsmcontext *cp)
|
||||
}
|
||||
|
||||
static inline int security_lsmblob_to_secctx(struct lsmblob *blob,
|
||||
struct lsmcontext *cp)
|
||||
struct lsmcontext *cp, int lsmid)
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1475,7 +1475,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
|
||||
|
||||
if (lsmblob_is_set(&audit_sig_lsm)) {
|
||||
err = security_lsmblob_to_secctx(&audit_sig_lsm,
|
||||
&lsmctx);
|
||||
&lsmctx, LSM_ID_UNDEF);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
@@ -2191,7 +2191,7 @@ int audit_log_task_context(struct audit_buffer *ab)
|
||||
if (!lsmblob_is_set(&blob))
|
||||
return 0;
|
||||
|
||||
error = security_lsmblob_to_secctx(&blob, &ctx);
|
||||
error = security_lsmblob_to_secctx(&blob, &ctx, LSM_ID_UNDEF);
|
||||
if (error < 0) {
|
||||
if (error != -EINVAL)
|
||||
goto error_path;
|
||||
|
||||
+5
-3
@@ -1109,7 +1109,7 @@ static int audit_log_pid_context(struct audit_context *context, pid_t pid,
|
||||
from_kuid(&init_user_ns, auid),
|
||||
from_kuid(&init_user_ns, uid), sessionid);
|
||||
if (lsmblob_is_set(blob)) {
|
||||
if (security_lsmblob_to_secctx(blob, &ctx) < 0) {
|
||||
if (security_lsmblob_to_secctx(blob, &ctx, LSM_ID_UNDEF) < 0) {
|
||||
audit_log_format(ab, " obj=(none)");
|
||||
rc = 1;
|
||||
} else {
|
||||
@@ -1394,7 +1394,8 @@ static void show_special(struct audit_context *context, int *call_panic)
|
||||
context->ipc.mode);
|
||||
if (lsmblob_is_set(&context->ipc.oblob)) {
|
||||
if (security_lsmblob_to_secctx(&context->ipc.oblob,
|
||||
&lsmctx) < 0) {
|
||||
&lsmctx,
|
||||
LSM_ID_UNDEF) < 0) {
|
||||
*call_panic = 1;
|
||||
} else {
|
||||
audit_log_format(ab, " obj=%s", lsmctx.context);
|
||||
@@ -1559,7 +1560,8 @@ static void audit_log_name(struct audit_context *context, struct audit_names *n,
|
||||
if (lsmblob_is_set(&n->oblob)) {
|
||||
struct lsmcontext ctx;
|
||||
|
||||
if (security_lsmblob_to_secctx(&n->oblob, &ctx) < 0) {
|
||||
if (security_lsmblob_to_secctx(&n->oblob, &ctx,
|
||||
LSM_ID_UNDEF) < 0) {
|
||||
if (call_panic)
|
||||
*call_panic = 2;
|
||||
} else {
|
||||
|
||||
@@ -98,7 +98,8 @@ struct audit_buffer *netlbl_audit_start_common(int type,
|
||||
audit_info->sessionid);
|
||||
|
||||
if (lsmblob_is_set(&audit_info->blob) &&
|
||||
security_lsmblob_to_secctx(&audit_info->blob, &ctx) >= 0) {
|
||||
security_lsmblob_to_secctx(&audit_info->blob, &ctx,
|
||||
LSM_ID_UNDEF) >= 0) {
|
||||
audit_log_format(audit_buf, " subj=%s", ctx.context);
|
||||
security_release_secctx(&ctx);
|
||||
}
|
||||
|
||||
+6
-5
@@ -4222,6 +4222,7 @@ EXPORT_SYMBOL(security_secid_to_secctx);
|
||||
* security_lsmblob_to_secctx() - Convert a lsmblob to a secctx
|
||||
* @blob: lsm specific information
|
||||
* @cp: the LSM context
|
||||
* @lsmid: which security module to report
|
||||
*
|
||||
* Convert a @blob entry to security context. If @cp is NULL the
|
||||
* length of the result will be returned, but no data will be returned.
|
||||
@@ -4231,15 +4232,15 @@ EXPORT_SYMBOL(security_secid_to_secctx);
|
||||
*
|
||||
* Return: Return length of data on success, error on failure.
|
||||
*/
|
||||
int security_lsmblob_to_secctx(struct lsmblob *blob, struct lsmcontext *cp)
|
||||
int security_lsmblob_to_secctx(struct lsmblob *blob, struct lsmcontext *cp,
|
||||
int lsmid)
|
||||
{
|
||||
struct security_hook_list *hp;
|
||||
int rc;
|
||||
|
||||
hlist_for_each_entry(hp, &security_hook_heads.lsmblob_to_secctx, list) {
|
||||
rc = hp->hook.lsmblob_to_secctx(blob, cp);
|
||||
if (rc != LSM_RET_DEFAULT(lsmblob_to_secctx))
|
||||
return rc;
|
||||
if (lsmid != hp->lsmid->id && lsmid != LSM_ID_UNDEF)
|
||||
continue;
|
||||
return hp->hook.lsmblob_to_secctx(blob, cp);
|
||||
}
|
||||
|
||||
return LSM_RET_DEFAULT(lsmblob_to_secctx);
|
||||
|
||||
Reference in New Issue
Block a user