From: Steve Grubb <sgrubb@redhat.com>
To: Rinat Gadelshin <rgadelsh@gmail.com>,
Paul Moore <paul@paul-moore.com>,
linux-audit@redhat.com
Cc: audit@vger.kernel.org, linux-audit@redhat.com,
Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Subject: Re: Can AUDIT_LIST_RULES causes kthreadd-spam?
Date: Wed, 10 May 2023 09:48:26 -0400 [thread overview]
Message-ID: <12214633.O9o76ZdvQC@x2> (raw)
In-Reply-To: <f2c12d41-95bb-6e56-4d68-8a4b50ca59fd@I-love.SAKURA.ne.jp>
On Wednesday, May 10, 2023 9:30:19 AM EDT Tetsuo Handa wrote:
> On 2023/05/10 21:12, Rinat Gadelshin wrote:
> >> Please try to find who is calling audit_send_reply_thread for many
> >> times.
> >
> > I've rebuilt the kernel with 'dump stack()'.
>
> Oops, I thought dump_stack() shows pid and comm name, but
> it is dump_stack_print_info() that shows pid and comm name.
>
> > As far as I can see, it's the exit of `sendto` syscall.
> > It seems that the kernel just creates a new kthreadd for each sendto
> > syscall. But I think that I'm wrong and just missing something.
>
> Yes, sendto() on netlink socket calls netlink_sendmsg().
> For some reason, audit_send_reply() is called for many times.
> audit_send_reply() is called by audit_receive_msg() for the following
> types.
>
> AUDIT_GET
> AUDIT_SIGNAL_INFO
> AUDIT_TTY_GET
> AUDIT_GET_FEATURE
The audit userspace always adds NLM_F_ACK to any netlink communication to
make sure it did not get discarded before it arrived. It has done this since
before I started working on audit code.
-Steve
> Would you re-caputure with
>
> - dump_stack();
> + pr_info("%s %s:%d type=%d\n", __func__, current->comm, current->pid,
> type);
>
> ?
>
> Regardless of the result of re-caputure, it seems there is no switch that
> can prevent audit_send_reply() from calling
> kthread_run(audit_send_reply_thread).
>
> But since kthreadd runs with PID=2 and PPID=0, you might be able to use
> PID=2 and/or PPID=0 in your rules in order to let kernel audit subsystem
> ignore kthreadd. (I can't test because I haven't found how to reproduce
> audit_receive_msg() in my environment...)
>
> # cat /proc/2/status
> Name: kthreadd
> Umask: 0000
> State: S (sleeping)
> Tgid: 2
> Ngid: 0
> Pid: 2
> PPid: 0
>
> --
> Linux-audit mailing list
> Linux-audit@redhat.com
> https://listman.redhat.com/mailman/listinfo/linux-audit
WARNING: multiple messages have this Message-ID (diff)
From: Steve Grubb <sgrubb@redhat.com>
To: Rinat Gadelshin <rgadelsh@gmail.com>,
Paul Moore <paul@paul-moore.com>,
linux-audit@redhat.com
Cc: audit@vger.kernel.org, linux-audit@redhat.com
Subject: Re: Can AUDIT_LIST_RULES causes kthreadd-spam?
Date: Wed, 10 May 2023 09:48:26 -0400 [thread overview]
Message-ID: <12214633.O9o76ZdvQC@x2> (raw)
In-Reply-To: <f2c12d41-95bb-6e56-4d68-8a4b50ca59fd@I-love.SAKURA.ne.jp>
On Wednesday, May 10, 2023 9:30:19 AM EDT Tetsuo Handa wrote:
> On 2023/05/10 21:12, Rinat Gadelshin wrote:
> >> Please try to find who is calling audit_send_reply_thread for many
> >> times.
> >
> > I've rebuilt the kernel with 'dump stack()'.
>
> Oops, I thought dump_stack() shows pid and comm name, but
> it is dump_stack_print_info() that shows pid and comm name.
>
> > As far as I can see, it's the exit of `sendto` syscall.
> > It seems that the kernel just creates a new kthreadd for each sendto
> > syscall. But I think that I'm wrong and just missing something.
>
> Yes, sendto() on netlink socket calls netlink_sendmsg().
> For some reason, audit_send_reply() is called for many times.
> audit_send_reply() is called by audit_receive_msg() for the following
> types.
>
> AUDIT_GET
> AUDIT_SIGNAL_INFO
> AUDIT_TTY_GET
> AUDIT_GET_FEATURE
The audit userspace always adds NLM_F_ACK to any netlink communication to
make sure it did not get discarded before it arrived. It has done this since
before I started working on audit code.
-Steve
> Would you re-caputure with
>
> - dump_stack();
> + pr_info("%s %s:%d type=%d\n", __func__, current->comm, current->pid,
> type);
>
> ?
>
> Regardless of the result of re-caputure, it seems there is no switch that
> can prevent audit_send_reply() from calling
> kthread_run(audit_send_reply_thread).
>
> But since kthreadd runs with PID=2 and PPID=0, you might be able to use
> PID=2 and/or PPID=0 in your rules in order to let kernel audit subsystem
> ignore kthreadd. (I can't test because I haven't found how to reproduce
> audit_receive_msg() in my environment...)
>
> # cat /proc/2/status
> Name: kthreadd
> Umask: 0000
> State: S (sleeping)
> Tgid: 2
> Ngid: 0
> Pid: 2
> PPid: 0
>
> --
> Linux-audit mailing list
> Linux-audit@redhat.com
> https://listman.redhat.com/mailman/listinfo/linux-audit
--
Linux-audit mailing list
Linux-audit@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-audit
next prev parent reply other threads:[~2023-05-10 13:50 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-03 21:14 Can AUDIT_LIST_RULES causes kthreadd-spam? Rinat Gadelshin
2023-05-03 21:27 ` Paul Moore
2023-05-03 21:27 ` Paul Moore
2023-05-03 22:12 ` Rinat Gadelshin
2023-05-03 22:12 ` Rinat Gadelshin
2023-05-04 2:50 ` Tetsuo Handa
2023-05-04 2:50 ` Tetsuo Handa
2023-05-04 18:40 ` Paul Moore
2023-05-04 18:40 ` Paul Moore
2023-05-04 22:53 ` Tetsuo Handa
2023-05-04 22:53 ` Tetsuo Handa
2023-05-05 22:12 ` Rinat Gadelshin
2023-05-05 22:12 ` Rinat Gadelshin
2023-05-06 6:50 ` Tetsuo Handa
2023-05-06 6:50 ` Tetsuo Handa
2023-05-10 12:12 ` Rinat Gadelshin
2023-05-10 12:12 ` Rinat Gadelshin
2023-05-10 13:30 ` Tetsuo Handa
2023-05-10 13:30 ` Tetsuo Handa
2023-05-10 13:48 ` Steve Grubb [this message]
2023-05-10 13:48 ` Steve Grubb
2023-05-24 10:38 ` Rinat Gadelshin
2023-05-24 10:38 ` Rinat Gadelshin
2023-05-24 10:48 ` Tetsuo Handa
2023-05-24 10:48 ` Tetsuo Handa
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=12214633.O9o76ZdvQC@x2 \
--to=sgrubb@redhat.com \
--cc=audit@vger.kernel.org \
--cc=linux-audit@redhat.com \
--cc=paul@paul-moore.com \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=rgadelsh@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.