<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div dir="auto">Thanks for your reply.</div><div dir="auto"><br></div><div dir="auto">This is a personal idea of mine,in the process of using audit,I find that if the audit rules are configured too much,or the server hard-disk performance is too poor,hitting a rate limit will be easy to occur,then some logs would be dropped directly.</div><div dir="auto">I think we should print the record to the console,just likely the last thing we want to do,better play the role of audit,and improve kernel security.</div><div dir="auto"><br></div><div dir="auto">I hope that will be helpful,thanks.</div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Paul Moore <paul@paul-moore.com>于2022年8月23日 周二08:06写道:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">On Sun, Aug 21, 2022 at 10:22 AM Ecronic <ecronic@outlook.com> wrote:
<br>>
<br>> If the log rate of audit exceeds audit_rate_limit, audit_log_end
<br>> will drop the audit logs. Printk before dropping them may be a
<br>> better choice.
<br>>
<br>> Signed-off-by: Ecronic <ecronic@outlook.com>
<br>> ---
<br>>  kernel/audit.c | 11 +++++++----
<br>>  1 file changed, 7 insertions(+), 4 deletions(-)
<br>
<br>Hi Ecronic,
<br>
<br>I'm not sure this is the right approach; if we're hitting a rate
<br>limit, printing the record to the console is likely the last thing we
<br>want to do.  Are you currently hitting a problem with the rate
<br>limiting, or is this simply something you found via code inspection?
<br>
<br>> diff --git a/kernel/audit.c b/kernel/audit.c
<br>> index a75978ae38ad..3f5be93447cb 100644
<br>> --- a/kernel/audit.c
<br>> +++ b/kernel/audit.c
<br>> @@ -2415,10 +2415,10 @@ void audit_log_end(struct audit_buffer *ab)
<br>>         if (!ab)
<br>>                 return;
<br>>
<br>> -       if (audit_rate_check()) {
<br>> -               skb = ab->skb;
<br>> -               ab->skb = NULL;
<br>> +       skb = ab->skb;
<br>> +       ab->skb = NULL;
<br>>
<br>> +       if (audit_rate_check()) {
<br>>                 /* setup the netlink header, see the comments in
<br>>                  * kauditd_send_multicast_skb() for length quirks */
<br>>                 nlh = nlmsg_hdr(skb);
<br>> @@ -2427,8 +2427,11 @@ void audit_log_end(struct audit_buffer *ab)
<br>>                 /* queue the netlink packet and poke the kauditd thread */
<br>>                 skb_queue_tail(&audit_queue, skb);
<br>>                 wake_up_interruptible(&kauditd_wait);
<br>> -       } else
<br>> +       } else {
<br>> +               kauditd_printk_skb(skb);
<br>> +               kfree_skb(skb);
<br>>                 audit_log_lost("rate limit exceeded");
<br>> +       }
<br>>
<br>>         audit_buffer_free(ab);
<br>>  }
<br>> --
<br>> 2.30.0
<br>
<br>-- 
<br>paul-moore.com
<br></blockquote></div></div>