From: Paul Moore <paul@paul-moore.com>
To: Ecronic <ecronic@outlook.com>
Cc: linux-audit@redhat.com, linux-kernel@vger.kernel.org, eparis@redhat.com
Subject: Re: [PATCH next] audit: printk before dropping logs in audit_log_end
Date: Mon, 22 Aug 2022 20:06:46 -0400 [thread overview]
Message-ID: <CAHC9VhTHF0vhm=1H6ywiZwW3U-eWQZnK8do5o7yCFQ5ykTrCYA@mail.gmail.com> (raw)
In-Reply-To: <TY0PR03MB627527D223A19E65A5DA14E8A36E9@TY0PR03MB6275.apcprd03.prod.outlook.com>
On Sun, Aug 21, 2022 at 10:22 AM Ecronic <ecronic@outlook.com> wrote:
>
> If the log rate of audit exceeds audit_rate_limit, audit_log_end
> will drop the audit logs. Printk before dropping them may be a
> better choice.
>
> Signed-off-by: Ecronic <ecronic@outlook.com>
> ---
> kernel/audit.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
Hi Ecronic,
I'm not sure this is the right approach; if we're hitting a rate
limit, printing the record to the console is likely the last thing we
want to do. Are you currently hitting a problem with the rate
limiting, or is this simply something you found via code inspection?
> diff --git a/kernel/audit.c b/kernel/audit.c
> index a75978ae38ad..3f5be93447cb 100644
> --- a/kernel/audit.c
> +++ b/kernel/audit.c
> @@ -2415,10 +2415,10 @@ void audit_log_end(struct audit_buffer *ab)
> if (!ab)
> return;
>
> - if (audit_rate_check()) {
> - skb = ab->skb;
> - ab->skb = NULL;
> + skb = ab->skb;
> + ab->skb = NULL;
>
> + if (audit_rate_check()) {
> /* setup the netlink header, see the comments in
> * kauditd_send_multicast_skb() for length quirks */
> nlh = nlmsg_hdr(skb);
> @@ -2427,8 +2427,11 @@ void audit_log_end(struct audit_buffer *ab)
> /* queue the netlink packet and poke the kauditd thread */
> skb_queue_tail(&audit_queue, skb);
> wake_up_interruptible(&kauditd_wait);
> - } else
> + } else {
> + kauditd_printk_skb(skb);
> + kfree_skb(skb);
> audit_log_lost("rate limit exceeded");
> + }
>
> audit_buffer_free(ab);
> }
> --
> 2.30.0
--
paul-moore.com
--
Linux-audit mailing list
Linux-audit@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-audit
next prev parent reply other threads:[~2022-08-23 0:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-21 14:21 [PATCH next] audit: printk before dropping logs in audit_log_end Ecronic
2022-08-23 0:06 ` Paul Moore [this message]
2022-08-23 2:33 ` Gaosheng Cui
2022-08-23 19:27 ` Paul Moore
2022-08-24 3:57 ` Gaosheng Cui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAHC9VhTHF0vhm=1H6ywiZwW3U-eWQZnK8do5o7yCFQ5ykTrCYA@mail.gmail.com' \
--to=paul@paul-moore.com \
--cc=ecronic@outlook.com \
--cc=eparis@redhat.com \
--cc=linux-audit@redhat.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).