Skip to content

Commit

Permalink
audit: add containerid support for user records
Browse files Browse the repository at this point in the history
Add audit container identifier auxiliary record to user event standalone
records.

Signed-off-by: Richard Guy Briggs <[email protected]>
Acked-by: Neil Horman <[email protected]>
Reviewed-by: Ondrej Mosnacek <[email protected]>
  • Loading branch information
rgbriggs authored and intel-lab-lkp committed Jun 27, 2020
1 parent c35c66f commit 25e5d49
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions kernel/audit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1212,12 +1212,6 @@ static void audit_log_common_recv_msg(struct audit_context *context,
audit_log_task_context(*ab);
}

static inline void audit_log_user_recv_msg(struct audit_buffer **ab,
u16 msg_type)
{
audit_log_common_recv_msg(NULL, ab, msg_type);
}

int is_audit_feature_set(int i)
{
return af.features & AUDIT_FEATURE_TO_MASK(i);
Expand Down Expand Up @@ -1486,14 +1480,17 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
err = audit_filter(msg_type, AUDIT_FILTER_USER);
if (err == 1) { /* match or error */
char *str = data;
struct audit_context *context;
struct audit_contobj *cont;

err = 0;
if (msg_type == AUDIT_USER_TTY) {
err = tty_audit_push();
if (err)
break;
}
audit_log_user_recv_msg(&ab, msg_type);
context = audit_alloc_local(GFP_KERNEL);
audit_log_common_recv_msg(context, &ab, msg_type);
if (msg_type != AUDIT_USER_TTY) {
/* ensure NULL termination */
str[data_len - 1] = '\0';
Expand All @@ -1507,6 +1504,14 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
audit_log_n_untrustedstring(ab, str, data_len);
}
audit_log_end(ab);
rcu_read_lock();
cont = _audit_contobj_get(current);
rcu_read_unlock();
audit_log_container_id(context, cont);
rcu_read_lock();
_audit_contobj_put(cont);
rcu_read_unlock();
audit_free_context(context);
}
break;
case AUDIT_ADD_RULE:
Expand Down

0 comments on commit 25e5d49

Please sign in to comment.