]> Git Repo - linux.git/commitdiff
Merge tag 'audit-pr-20221003' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoor...
authorLinus Torvalds <[email protected]>
Tue, 4 Oct 2022 18:05:43 +0000 (11:05 -0700)
committerLinus Torvalds <[email protected]>
Tue, 4 Oct 2022 18:05:43 +0000 (11:05 -0700)
Pull audit updates from Paul Moore:
 "Six audit patches for v6.1, most are pretty trivial, but a quick list
  of the highlights are below:

   - Only free the audit proctitle information on task exit. This allows
     us to cache the information and improve performance slightly.

   - Use the time_after() macro to do time comparisons instead of doing
     it directly and potentially causing ourselves problems when the
     timer wraps.

   - Convert an audit_context state comparison from a relative enum
     comparison, e.g. (x < y), to a not-equal comparison to ensure that
     we are not caught out at some unknown point in the future by an
     enum shuffle.

   - A handful of small cleanups such as tidying up comments and
     removing unused declarations"

* tag 'audit-pr-20221003' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit:
  audit: remove selinux_audit_rule_update() declaration
  audit: use time_after to compare time
  audit: free audit_proctitle only on task exit
  audit: explicitly check audit_context->context enum value
  audit: audit_context pid unused, context enum comment fix
  audit: fix repeated words in comments

1  2 
kernel/auditsc.c

diff --combined kernel/auditsc.c
index 79a5da1bc5bb694f8a72d01d785ee387378c7194,280b4720c7a0b4bec940a332fd87fb8eda11783d..9f8c05228d6d653b89ddcb9c00965f604588a215
@@@ -965,7 -965,7 +965,7 @@@ static void audit_reset_context(struct 
        if (!ctx)
                return;
  
-       /* if ctx is non-null, reset the "ctx->state" regardless */
+       /* if ctx is non-null, reset the "ctx->context" regardless */
        ctx->context = AUDIT_CTX_UNUSED;
        if (ctx->dummy)
                return;
        kfree(ctx->sockaddr);
        ctx->sockaddr = NULL;
        ctx->sockaddr_len = 0;
-       ctx->pid = ctx->ppid = 0;
+       ctx->ppid = 0;
        ctx->uid = ctx->euid = ctx->suid = ctx->fsuid = KUIDT_INIT(0);
        ctx->gid = ctx->egid = ctx->sgid = ctx->fsgid = KGIDT_INIT(0);
        ctx->personality = 0;
        WARN_ON(!list_empty(&ctx->killed_trees));
        audit_free_module(ctx);
        ctx->fds[0] = -1;
-       audit_proctitle_free(ctx);
        ctx->type = 0; /* reset last for audit_free_*() */
  }
  
@@@ -1077,6 -1076,7 +1076,7 @@@ static inline void audit_free_context(s
  {
        /* resetting is extra work, but it is likely just noise */
        audit_reset_context(context);
+       audit_proctitle_free(context);
        free_tree_refs(context);
        kfree(context->filterkey);
        kfree(context);
@@@ -1833,7 -1833,7 +1833,7 @@@ void __audit_free(struct task_struct *t
  
        /* We are called either by do_exit() or the fork() error handling code;
         * in the former case tsk == current and in the latter tsk is a
-        * random task_struct that doesn't doesn't have any meaningful data we
+        * random task_struct that doesn't have any meaningful data we
         * need to log via audit_log_exit().
         */
        if (tsk == current && !context->dummy) {
@@@ -1940,7 -1940,6 +1940,7 @@@ void __audit_uring_exit(int success, lo
                goto out;
        }
  
 +      audit_return_fixup(ctx, success, code);
        if (ctx->context == AUDIT_CTX_SYSCALL) {
                /*
                 * NOTE: See the note in __audit_uring_entry() about the case
        audit_filter_inodes(current, ctx);
        if (ctx->current_state != AUDIT_STATE_RECORD)
                goto out;
 -      audit_return_fixup(ctx, success, code);
        audit_log_exit();
  
  out:
@@@ -2065,13 -2065,13 +2065,13 @@@ void __audit_syscall_exit(int success, 
        if (!list_empty(&context->killed_trees))
                audit_kill_trees(context);
  
 +      audit_return_fixup(context, success, return_code);
        /* run through both filters to ensure we set the filterkey properly */
        audit_filter_syscall(current, context);
        audit_filter_inodes(current, context);
-       if (context->current_state < AUDIT_STATE_RECORD)
+       if (context->current_state != AUDIT_STATE_RECORD)
                goto out;
  
 -      audit_return_fixup(context, success, return_code);
        audit_log_exit();
  
  out:
This page took 0.056569 seconds and 4 git commands to generate.