netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Eric Dumazet <edumazet@google.com>
Cc: "David S . Miller" <davem@davemloft.net>,
	Paolo Abeni <pabeni@redhat.com>, netdev <netdev@vger.kernel.org>,
	Eric Dumazet <eric.dumazet@gmail.com>,
	syzbot <syzkaller@googlegroups.com>,
	Petar Penkov <ppenkov@aviatrix.com>
Subject: Re: [PATCH net] net: tun: do not call napi_disable() twice
Date: Wed, 29 Jun 2022 09:27:05 -0700	[thread overview]
Message-ID: <20220629092705.3c18985b@kernel.org> (raw)
In-Reply-To: <CANn89iJxAL5v0FtkaRXjDH--PeTB7MoqV1Y16YQoOgDUCNXjmw@mail.gmail.com>

On Wed, 29 Jun 2022 18:19:58 +0200 Eric Dumazet wrote:
> On Wed, Jun 29, 2022 at 6:17 PM Jakub Kicinski <kuba@kernel.org> wrote:
> >
> > On Wed, 29 Jun 2022 09:37:52 +0000 Eric Dumazet wrote:  
> > > syzbot reported a hang in tun_napi_disable() while RTNL is held.
> > >
> > > Because tun.c logic is complicated, I chose to:
> > >
> > > 1) rename tun->napi_enabled to tun->napi_configured
> > >
> > > 2) Add a new boolean, tracking if tun->napi is enabled or not.  
> >
> > Not a huge surprise TBH :S
> >
> > Is there a repro?  
> 
> Yes, here it is:
> 
> // autogenerated by syzkaller (https://github.com/google/syzkaller)

Thanks! let me test this:

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index e2eb35887394..8776a9e1a8f5 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -661,7 +661,6 @@ static void __tun_detach(struct tun_file *tfile, bool clean)
                        sock_put(&tfile->sk);
                } else {
                        tun_disable_queue(tun, tfile);
-                       tun_napi_disable(tfile);
                }
 
                synchronize_net();
@@ -719,6 +718,7 @@ static void tun_detach_all(struct net_device *dev)
                --tun->numqueues;
        }
        list_for_each_entry(tfile, &tun->disabled, next) {
+               tun_napi_disable(tfile);
                tfile->socket.sk->sk_shutdown = RCV_SHUTDOWN;
                tfile->socket.sk->sk_data_ready(tfile->socket.sk);
                RCU_INIT_POINTER(tfile->tun, NULL);

      reply	other threads:[~2022-06-29 16:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-29  9:37 [PATCH net] net: tun: do not call napi_disable() twice Eric Dumazet
2022-06-29 16:17 ` Jakub Kicinski
2022-06-29 16:19   ` Eric Dumazet
2022-06-29 16:27     ` Jakub Kicinski [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=20220629092705.3c18985b@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ppenkov@aviatrix.com \
    --cc=syzkaller@googlegroups.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).