netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Souradeep Chakrabarti <schakrabarti@linux.microsoft.com>
Cc: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org,
	decui@microsoft.com, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, longli@microsoft.com,
	yury.norov@gmail.com, leon@kernel.org, cai.huoqing@linux.dev,
	ssengar@linux.microsoft.com, vkuznets@redhat.com,
	tglx@linutronix.de, linux-hyperv@vger.kernel.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-rdma@vger.kernel.org, schakrabarti@microsoft.com,
	stable@vger.kernel.org
Subject: Re: [PATCH V2 net] hv_netvsc: Fix race condition between netvsc_probe and netvsc_remove
Date: Thu, 1 Feb 2024 16:49:45 +0100	[thread overview]
Message-ID: <20240201154945.GH530335@kernel.org> (raw)
In-Reply-To: <1706686551-28510-1-git-send-email-schakrabarti@linux.microsoft.com>

On Tue, Jan 30, 2024 at 11:35:51PM -0800, Souradeep Chakrabarti wrote:
> In commit ac5047671758 ("hv_netvsc: Disable NAPI before closing the
> VMBus channel"), napi_disable was getting called for all channels,
> including all subchannels without confirming if they are enabled or not.
> 
> This caused hv_netvsc getting hung at napi_disable, when netvsc_probe()
> has finished running but nvdev->subchan_work has not started yet.
> netvsc_subchan_work() -> rndis_set_subchannel() has not created the
> sub-channels and because of that netvsc_sc_open() is not running.
> netvsc_remove() calls cancel_work_sync(&nvdev->subchan_work), for which
> netvsc_subchan_work did not run.
> 
> netif_napi_add() sets the bit NAPI_STATE_SCHED because it ensures NAPI
> cannot be scheduled. Then netvsc_sc_open() -> napi_enable will clear the
> NAPIF_STATE_SCHED bit, so it can be scheduled. napi_disable() does the
> opposite.
> 
> Now during netvsc_device_remove(), when napi_disable is called for those
> subchannels, napi_disable gets stuck on infinite msleep.
> 
> This fix addresses this problem by ensuring that napi_disable() is not
> getting called for non-enabled NAPI struct.
> But netif_napi_del() is still necessary for these non-enabled NAPI struct
> for cleanup purpose.
> 
> Call trace:
> [  654.559417] task:modprobe        state:D stack:    0 pid: 2321 ppid:  1091 flags:0x00004002
> [  654.568030] Call Trace:
> [  654.571221]  <TASK>
> [  654.573790]  __schedule+0x2d6/0x960
> [  654.577733]  schedule+0x69/0xf0
> [  654.581214]  schedule_timeout+0x87/0x140
> [  654.585463]  ? __bpf_trace_tick_stop+0x20/0x20
> [  654.590291]  msleep+0x2d/0x40
> [  654.593625]  napi_disable+0x2b/0x80
> [  654.597437]  netvsc_device_remove+0x8a/0x1f0 [hv_netvsc]
> [  654.603935]  rndis_filter_device_remove+0x194/0x1c0 [hv_netvsc]
> [  654.611101]  ? do_wait_intr+0xb0/0xb0
> [  654.615753]  netvsc_remove+0x7c/0x120 [hv_netvsc]
> [  654.621675]  vmbus_remove+0x27/0x40 [hv_vmbus]
> 
> Cc: stable@vger.kernel.org
> Fixes: ac5047671758 ("hv_netvsc: Disable NAPI before closing the VMBus channel")
> Signed-off-by: Souradeep Chakrabarti <schakrabarti@linux.microsoft.com>
> Reviewed-by: Dexuan Cui <decui@microsoft.com>
> Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>

Reviewed-by: Simon Horman <horms@kernel.org>

  reply	other threads:[~2024-02-01 15:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-31  7:35 [PATCH V2 net] hv_netvsc: Fix race condition between netvsc_probe and netvsc_remove Souradeep Chakrabarti
2024-02-01 15:49 ` Simon Horman [this message]
2024-02-01 16:40 ` patchwork-bot+netdevbpf

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=20240201154945.GH530335@kernel.org \
    --to=horms@kernel.org \
    --cc=cai.huoqing@linux.dev \
    --cc=davem@davemloft.net \
    --cc=decui@microsoft.com \
    --cc=edumazet@google.com \
    --cc=haiyangz@microsoft.com \
    --cc=kuba@kernel.org \
    --cc=kys@microsoft.com \
    --cc=leon@kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=longli@microsoft.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=schakrabarti@linux.microsoft.com \
    --cc=schakrabarti@microsoft.com \
    --cc=ssengar@linux.microsoft.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=vkuznets@redhat.com \
    --cc=wei.liu@kernel.org \
    --cc=yury.norov@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 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).