mirror of
https://git.proxmox.com/git/mirror_ubuntu-kernels.git
synced 2025-11-03 04:17:09 +00:00
UBUNTU: SAUCE: apparmor4.0.0 [5/53]: Stacking: Audit: multiple subject lsm values for netlabel
BugLink: http://bugs.launchpad.net/bugs/2028253 Refactor audit_log_task_context(), creating a new audit_log_subject_context(). This is used in netlabel auditing to provide multiple subject security contexts as necessary. Signed-off-by: Casey Schaufler <casey@schaufler-ca.com> Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
parent
151724aa3a
commit
dde6003299
@ -37,6 +37,7 @@ struct audit_watch;
|
||||
struct audit_tree;
|
||||
struct sk_buff;
|
||||
struct kern_ipc_perm;
|
||||
struct lsm_prop;
|
||||
|
||||
struct audit_krule {
|
||||
u32 pflags;
|
||||
@ -185,6 +186,8 @@ extern void audit_log_path_denied(int type,
|
||||
const char *operation);
|
||||
extern void audit_log_lost(const char *message);
|
||||
|
||||
extern int audit_log_subject_context(struct audit_buffer *ab,
|
||||
struct lsm_prop *blob);
|
||||
extern int audit_log_task_context(struct audit_buffer *ab);
|
||||
extern void audit_log_task_info(struct audit_buffer *ab);
|
||||
|
||||
@ -245,6 +248,11 @@ static inline void audit_log_key(struct audit_buffer *ab, char *key)
|
||||
{ }
|
||||
static inline void audit_log_path_denied(int type, const char *operation)
|
||||
{ }
|
||||
static inline int audit_log_subject_context(struct audit_buffer *ab,
|
||||
struct lsm_prop *prop)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static inline int audit_log_task_context(struct audit_buffer *ab)
|
||||
{
|
||||
return 0;
|
||||
|
||||
@ -2238,20 +2238,18 @@ static void audit_buffer_aux_end(struct audit_buffer *ab)
|
||||
ab->skb = skb_peek(&ab->skb_list);
|
||||
}
|
||||
|
||||
int audit_log_task_context(struct audit_buffer *ab)
|
||||
int audit_log_subject_context(struct audit_buffer *ab, struct lsm_prop *prop)
|
||||
{
|
||||
struct lsm_prop prop;
|
||||
struct lsm_context ctx;
|
||||
bool space = false;
|
||||
int error;
|
||||
int i;
|
||||
|
||||
security_current_getlsmprop_subj(&prop);
|
||||
if (!lsmprop_is_set(&prop))
|
||||
if (!lsmprop_is_set(prop))
|
||||
return 0;
|
||||
|
||||
if (lsm_prop_cnt < 2) {
|
||||
error = security_lsmprop_to_secctx(&prop, &ctx, LSM_ID_UNDEF);
|
||||
error = security_lsmprop_to_secctx(prop, &ctx, LSM_ID_UNDEF);
|
||||
if (error < 0) {
|
||||
if (error != -EINVAL)
|
||||
goto error_path;
|
||||
@ -2270,7 +2268,7 @@ int audit_log_task_context(struct audit_buffer *ab)
|
||||
for (i = 0; i < lsm_active_cnt; i++) {
|
||||
if (!lsm_idlist[i]->lsmprop)
|
||||
continue;
|
||||
error = security_lsmprop_to_secctx(&prop, &ctx,
|
||||
error = security_lsmprop_to_secctx(prop, &ctx,
|
||||
lsm_idlist[i]->id);
|
||||
if (error < 0) {
|
||||
if (error == -EOPNOTSUPP)
|
||||
@ -2290,9 +2288,18 @@ int audit_log_task_context(struct audit_buffer *ab)
|
||||
return 0;
|
||||
|
||||
error_path:
|
||||
audit_panic("error in audit_log_task_context");
|
||||
audit_panic("error in audit_log_subject_context");
|
||||
return error;
|
||||
}
|
||||
EXPORT_SYMBOL(audit_log_subject_context);
|
||||
|
||||
int audit_log_task_context(struct audit_buffer *ab)
|
||||
{
|
||||
struct lsm_prop prop;
|
||||
|
||||
security_current_getlsmprop_subj(&prop);
|
||||
return audit_log_subject_context(ab, &prop);
|
||||
}
|
||||
EXPORT_SYMBOL(audit_log_task_context);
|
||||
|
||||
void audit_log_d_path_exe(struct audit_buffer *ab,
|
||||
|
||||
@ -84,7 +84,6 @@ struct audit_buffer *netlbl_audit_start_common(int type,
|
||||
struct netlbl_audit *audit_info)
|
||||
{
|
||||
struct audit_buffer *audit_buf;
|
||||
struct lsm_context ctx;
|
||||
|
||||
if (audit_enabled == AUDIT_OFF)
|
||||
return NULL;
|
||||
@ -96,13 +95,7 @@ struct audit_buffer *netlbl_audit_start_common(int type,
|
||||
audit_log_format(audit_buf, "netlabel: auid=%u ses=%u",
|
||||
from_kuid(&init_user_ns, audit_info->loginuid),
|
||||
audit_info->sessionid);
|
||||
|
||||
if (lsmprop_is_set(&audit_info->prop) &&
|
||||
security_lsmprop_to_secctx(&audit_info->prop, &ctx,
|
||||
LSM_ID_UNDEF) > 0) {
|
||||
audit_log_format(audit_buf, " subj=%s", ctx.context);
|
||||
security_release_secctx(&ctx);
|
||||
}
|
||||
audit_log_subject_context(audit_buf, &audit_info->prop);
|
||||
|
||||
return audit_buf;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user