netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Olivier Brunel <jjk@jjacky.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: netdev@vger.kernel.org, daniel@iogearbox.net
Subject: Re: bpfilter causes a leftover kernel process
Date: Wed, 29 Aug 2018 18:21:28 +0200	[thread overview]
Message-ID: <20180829182128.687a3374@jjacky.com> (raw)
In-Reply-To: <20180829053536.en6crhdfs7r2d6vt@ast-mbp.dhcp.thefacebook.com>

On Tue, 28 Aug 2018 22:35:38 -0700
Alexei Starovoitov <alexei.starovoitov@gmail.com> wrote:

> > Yeah, I have a similar thing happening on shutdown, except that
> > we're talking about a kernel thread here, so that process is
> > ignored by the mentionned killing spree as a result, thus leaving
> > that process running.  
> 
> it's not a kernel thread and sounds like there is a bug in your pid 1
> that is worth fixing.
 
Well, it sure does look like one. By which I mean that looking at
its /proc/$PID entry, one can see that it has an empty command line and
kthreadd as parent (ppid 2), which usually are only true for kernel
threads (unless I'm mistaken).

The tool I'm using to send the signals on shutdown does indeed not use
kill(-1,sig) but instead scans /proc and determines whether or not to
signal a process (thus allowing to ignore a few specific processes to
be killed later on).

Kernel threads are obviously to be skipped, and to identify them it
uses the classic method of checking whether or not it has an empty
command line. As I said, this bpfilter helper does and that's why it is
considered a kernel thread & thus not killed.

This is also what other tools do, like ps or top, which is indeed why
they also show it as a kernel thread ("[none]").

So is this way of doing this wrong? And if so, what would be a better
way to identify kernel threads?

Out of curiosity I also had a look at how systemd does things, and it
looks to me like it does the exact same thing[1], also identifying
kernel threads by their empty command line. So I would think that a
similar issue could be observed under systemd as well.

Thanks.


[1]
https://github.com/systemd/systemd/blob/master/src/core/killall.c#L44

  reply	other threads:[~2018-08-29 22:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-26 16:08 bpfilter causes a leftover kernel process Olivier Brunel
2018-08-27 16:31 ` Olivier Brunel
2018-08-28  3:35   ` Alexei Starovoitov
2018-08-28 11:23     ` Olivier Brunel
2018-08-29  5:35       ` Alexei Starovoitov
2018-08-29 16:21         ` Olivier Brunel [this message]
2018-09-05 15:52     ` Olivier Brunel
2018-10-16 16:38       ` Alexei Starovoitov
2018-10-20 17:39         ` [PATCH 0/2] " Olivier Brunel
2018-10-20 17:39           ` [PATCH 1/2] umh: Add command line to user mode helpers Olivier Brunel
2018-10-23  2:37             ` David Miller
2018-10-20 17:39           ` [PATCH 2/2] net: bpfilter: Set user mode helper's command line Olivier Brunel
2018-10-23  2:37             ` David Miller

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=20180829182128.687a3374@jjacky.com \
    --to=jjk@jjacky.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=daniel@iogearbox.net \
    --cc=netdev@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 NNTP newsgroup(s).