]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
audit: free audit_proctitle only on task exit
authorRichard Guy Briggs <rgb@redhat.com>
Thu, 25 Aug 2022 19:32:39 +0000 (15:32 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Oct 2022 07:57:06 +0000 (09:57 +0200)
[ Upstream commit c3f3ea8af44d0c5fba79fe8b198087342d0c7e04 ]

Since audit_proctitle is generated at syscall exit time, its value is
used immediately and cached for the next syscall.  Since this is the
case, then only clear it at task exit time.  Otherwise, there is no
point in caching the value OR bearing the overhead of regenerating it.

Fixes: 12c5e81d3fd0 ("audit: prepare audit_context for use in calling contexts beyond syscalls")
Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/auditsc.c

index 65d816cda5df7efdd6734c6784fa9276328d94cf..73121c0185ceaf6b622e0fdd2719256ee5508d22 100644 (file)
@@ -1016,7 +1016,6 @@ static void audit_reset_context(struct audit_context *ctx)
        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_*() */
 }
 
@@ -1102,6 +1101,7 @@ static inline void audit_free_context(struct audit_context *context)
 {
        /* 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);