netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: pabeni@redhat.com
Cc: netdev@vger.kernel.org, mcroce@redhat.com
Subject: Re: [PATCH net v2] pktgen: do not sleep with the thread lock held.
Date: Thu, 06 Jun 2019 11:32:27 -0700 (PDT)	[thread overview]
Message-ID: <20190606.113227.492005574306351502.davem@davemloft.net> (raw)
In-Reply-To: <011e3de13ea55a66d55024b5555cefd9dd8ec4c3.1559828069.git.pabeni@redhat.com>

From: Paolo Abeni <pabeni@redhat.com>
Date: Thu,  6 Jun 2019 15:45:03 +0200

> Currently, the process issuing a "start" command on the pktgen procfs
> interface, acquires the pktgen thread lock and never release it, until
> all pktgen threads are completed. The above can blocks indefinitely any
> other pktgen command and any (even unrelated) netdevice removal - as
> the pktgen netdev notifier acquires the same lock.
> 
> The issue is demonstrated by the following script, reported by Matteo:
> 
> ip -b - <<'EOF'
> 	link add type dummy
> 	link add type veth
> 	link set dummy0 up
> EOF
> modprobe pktgen
> echo reset >/proc/net/pktgen/pgctrl
> {
> 	echo rem_device_all
> 	echo add_device dummy0
> } >/proc/net/pktgen/kpktgend_0
> echo count 0 >/proc/net/pktgen/dummy0
> echo start >/proc/net/pktgen/pgctrl &
> sleep 1
> rmmod veth
> 
> Fix the above releasing the thread lock around the sleep call.
> 
> Additionally we must prevent racing with forcefull rmmod - as the
> thread lock no more protects from them. Instead, acquire a self-reference
> before waiting for any thread. As a side effect, running
> 
> rmmod pktgen
> 
> while some thread is running now fails with "module in use" error,
> before this patch such command hanged indefinitely.
> 
> Note: the issue predates the commit reported in the fixes tag, but
> this fix can't be applied before the mentioned commit.
> 
> v1 -> v2:
>  - no need to check for thread existence after flipping the lock,
>    pktgen threads are freed only at net exit time
>  -
> 
> Fixes: 6146e6a43b35 ("[PKTGEN]: Removes thread_{un,}lock() macros.")
> Reported-and-tested-by: Matteo Croce <mcroce@redhat.com>
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>

This looks a lot simpler.

Applied and queued up for -stable, thanks.

      reply	other threads:[~2019-06-06 18:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-06 13:45 [PATCH net v2] pktgen: do not sleep with the thread lock held Paolo Abeni
2019-06-06 18:32 ` David Miller [this message]

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=20190606.113227.492005574306351502.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=mcroce@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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 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).