From: Paolo Abeni <pabeni@redhat.com>
To: Jinjian Song <jinjian.song@fibocom.com>,
chandrashekar.devegowda@intel.com,
chiranjeevi.rapolu@linux.intel.com, haijun.liu@mediatek.com,
m.chetan.kumar@linux.intel.com, ricardo.martinez@linux.intel.com,
loic.poulain@linaro.org, ryazanov.s.a@gmail.com,
johannes@sipsolutions.net, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
linux-doc@vger.kernel.org,
angelogioacchino.delregno@collabora.com,
linux-arm-kernel@lists.infradead.org, matthias.bgg@gmail.com,
corbet@lwn.net, linux-mediatek@lists.infradead.org,
helgaas@kernel.org, danielwinkler@google.com,
andrew+netdev@lunn.ch, horms@kernel.org,
sreehari.kancharla@linux.intel.com,
ilpo.jarvinen@linux.intel.com
Subject: Re: [net v2] net: wwan: t7xx: Fix napi rx poll issue
Date: Thu, 29 May 2025 12:52:32 +0200 [thread overview]
Message-ID: <6ae0ad5a-f560-43c5-a581-e4699634b65e@redhat.com> (raw)
In-Reply-To: <20250528082827.4654-1-jinjian.song@fibocom.com>
On 5/28/25 10:28 AM, Jinjian Song wrote:
> When driver handles the napi rx polling requests, the netdev might
> have been released by the dellink logic triggered by the disconnect
> operation on user plane. However, in the logic of processing skb in
> polling, an invalid netdev is still being used, which causes a panic.
>
> BUG: kernel NULL pointer dereference, address: 00000000000000f1
> Oops: 0000 [#1] PREEMPT SMP NOPTI
> RIP: 0010:dev_gro_receive+0x3a/0x620
> [...]
> Call Trace:
> <IRQ>
> ? __die_body+0x68/0xb0
> ? page_fault_oops+0x379/0x3e0
> ? exc_page_fault+0x4f/0xa0
> ? asm_exc_page_fault+0x22/0x30
> ? __pfx_t7xx_ccmni_recv_skb+0x10/0x10 [mtk_t7xx (HASH:1400 7)]
> ? dev_gro_receive+0x3a/0x620
> napi_gro_receive+0xad/0x170
> t7xx_ccmni_recv_skb+0x48/0x70 [mtk_t7xx (HASH:1400 7)]
> t7xx_dpmaif_napi_rx_poll+0x590/0x800 [mtk_t7xx (HASH:1400 7)]
> net_rx_action+0x103/0x470
> irq_exit_rcu+0x13a/0x310
> sysvec_apic_timer_interrupt+0x56/0x90
> </IRQ>
>
> Fixes: 5545b7b9f294 ("net: wwan: t7xx: Add NAPI support")
> Signed-off-by: Jinjian Song <jinjian.song@fibocom.com>
> ---
> drivers/net/wwan/t7xx/t7xx_netdev.c | 19 ++++++++++---------
> 1 file changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/wwan/t7xx/t7xx_netdev.c b/drivers/net/wwan/t7xx/t7xx_netdev.c
> index 91fa082e9cab..48007384c030 100644
> --- a/drivers/net/wwan/t7xx/t7xx_netdev.c
> +++ b/drivers/net/wwan/t7xx/t7xx_netdev.c
> @@ -172,7 +172,7 @@ static void t7xx_ccmni_start(struct t7xx_ccmni_ctrl *ctlb)
> int i;
>
> for (i = 0; i < ctlb->nic_dev_num; i++) {
> - ccmni = ctlb->ccmni_inst[i];
> + ccmni = READ_ONCE(ctlb->ccmni_inst[i]);
> if (!ccmni)
> continue;
>
> @@ -192,7 +192,7 @@ static void t7xx_ccmni_pre_stop(struct t7xx_ccmni_ctrl *ctlb)
> int i;
>
> for (i = 0; i < ctlb->nic_dev_num; i++) {
> - ccmni = ctlb->ccmni_inst[i];
> + ccmni = READ_ONCE(ctlb->ccmni_inst[i]);
> if (!ccmni)
> continue;
>
> @@ -210,7 +210,7 @@ static void t7xx_ccmni_post_stop(struct t7xx_ccmni_ctrl *ctlb)
> t7xx_ccmni_disable_napi(ctlb);
>
> for (i = 0; i < ctlb->nic_dev_num; i++) {
> - ccmni = ctlb->ccmni_inst[i];
> + ccmni = READ_ONCE(ctlb->ccmni_inst[i]);
> if (!ccmni)
> continue;
>
> @@ -302,7 +302,7 @@ static int t7xx_ccmni_wwan_newlink(void *ctxt, struct net_device *dev, u32 if_id
> ccmni->ctlb = ctlb;
> ccmni->dev = dev;
> atomic_set(&ccmni->usage, 0);
> - ctlb->ccmni_inst[if_id] = ccmni;
> + WRITE_ONCE(ctlb->ccmni_inst[if_id], ccmni);
>
> ret = register_netdevice(dev);
> if (ret)
> @@ -321,9 +321,10 @@ static void t7xx_ccmni_wwan_dellink(void *ctxt, struct net_device *dev, struct l
> if (if_id >= ARRAY_SIZE(ctlb->ccmni_inst))
> return;
>
> - if (WARN_ON(ctlb->ccmni_inst[if_id] != ccmni))
> + if (WARN_ON(READ_ONCE(ctlb->ccmni_inst[if_id]) != ccmni))
READ_ONCE is only needed when the the lock protecting ctlb->ccmni_inst
is not held. It's not needed here, and likely in pre/post stop operations.
/P
prev parent reply other threads:[~2025-05-29 10:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-28 8:28 [net v2] net: wwan: t7xx: Fix napi rx poll issue Jinjian Song
2025-05-29 10:52 ` Paolo Abeni [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=6ae0ad5a-f560-43c5-a581-e4699634b65e@redhat.com \
--to=pabeni@redhat.com \
--cc=andrew+netdev@lunn.ch \
--cc=angelogioacchino.delregno@collabora.com \
--cc=chandrashekar.devegowda@intel.com \
--cc=chiranjeevi.rapolu@linux.intel.com \
--cc=corbet@lwn.net \
--cc=danielwinkler@google.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=haijun.liu@mediatek.com \
--cc=helgaas@kernel.org \
--cc=horms@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jinjian.song@fibocom.com \
--cc=johannes@sipsolutions.net \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=loic.poulain@linaro.org \
--cc=m.chetan.kumar@linux.intel.com \
--cc=matthias.bgg@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=ricardo.martinez@linux.intel.com \
--cc=ryazanov.s.a@gmail.com \
--cc=sreehari.kancharla@linux.intel.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).