linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] audit: only print records that will be dropped via printk()
@ 2022-02-23  9:41 Gaosheng Cui
  2022-02-23 22:00 ` Paul Moore
  0 siblings, 1 reply; 2+ messages in thread
From: Gaosheng Cui @ 2022-02-23  9:41 UTC (permalink / raw)
  To: paul, eparis; +Cc: linux-audit, linux-kernel, wangweiyang2, xiujianfeng

When an admin enables audit at early boot via the "audit=1" kernel
command line, netlink send errors seen will cause the audit subsystem
to drop some records or return records to the queue. And all records
will be printed via printk() in the kauditd_hold_skb(), but actually
only the records that will be dropped need to be printed via printk().

Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
---
 kernel/audit.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/kernel/audit.c b/kernel/audit.c
index 7690c29d4ee4..eb3e44c849be 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -568,10 +568,6 @@ static void kauditd_rehold_skb(struct sk_buff *skb, __always_unused int error)
  */
 static void kauditd_hold_skb(struct sk_buff *skb, int error)
 {
-	/* at this point it is uncertain if we will ever send this to auditd so
-	 * try to send the message via printk before we go any further */
-	kauditd_printk_skb(skb);
-
 	/* can we just silently drop the message? */
 	if (!audit_default)
 		goto drop;
@@ -600,6 +596,11 @@ static void kauditd_hold_skb(struct sk_buff *skb, int error)
 	/* we have no other options - drop the message */
 	audit_log_lost("kauditd hold queue overflow");
 drop:
+	/* at this point it is uncertain if we will ever send this to auditd so
+	 * try to send the message via printk before we go any further
+	 */
+	kauditd_printk_skb(skb);
+
 	kfree_skb(skb);
 }
 
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH -next] audit: only print records that will be dropped via printk()
  2022-02-23  9:41 [PATCH -next] audit: only print records that will be dropped via printk() Gaosheng Cui
@ 2022-02-23 22:00 ` Paul Moore
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Moore @ 2022-02-23 22:00 UTC (permalink / raw)
  To: Gaosheng Cui; +Cc: eparis, linux-audit, linux-kernel, wangweiyang2, xiujianfeng

On Wed, Feb 23, 2022 at 4:41 AM Gaosheng Cui <cuigaosheng1@huawei.com> wrote:
>
> When an admin enables audit at early boot via the "audit=1" kernel
> command line, netlink send errors seen will cause the audit subsystem
> to drop some records or return records to the queue. And all records
> will be printed via printk() in the kauditd_hold_skb(), but actually
> only the records that will be dropped need to be printed via printk().
>
> Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
> ---
>  kernel/audit.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)

When records are moved to the hold queue the system is in a bad state
so printing the record via printk() regardless of if the record is
able to be successfully queued or dropped is important.  If this is
happening frequently on your system, this is likely a sign your system
is misconfigured.

-- 
paul-moore.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-23 22:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-23  9:41 [PATCH -next] audit: only print records that will be dropped via printk() Gaosheng Cui
2022-02-23 22:00 ` Paul Moore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).