All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Jiawen Wu <jiawenwu@trustnetic.com>
Cc: netdev@vger.kernel.org,
	"'Mengyuan Lou'" <mengyuanlou@net-swift.com>,
	"'Andrew Lunn'" <andrew+netdev@lunn.ch>,
	"'David S. Miller'" <davem@davemloft.net>,
	"'Eric Dumazet'" <edumazet@google.com>,
	"'Jakub Kicinski'" <kuba@kernel.org>,
	"'Paolo Abeni'" <pabeni@redhat.com>,
	"'Aleksandr Loktionov'" <aleksandr.loktionov@intel.com>,
	"'Rongguang Wei'" <weirongguang@kylinos.cn>,
	"'Uwe Kleine-König (The Capable Hub)'"
	<u.kleine-koenig@baylibre.com>,
	"'Larysa Zaremba'" <larysa.zaremba@intel.com>,
	"'Breno Leitao'" <leitao@debian.org>
Subject: Re: [PATCH net v3] net: ngbe: fix NULL pointer dereference in non-MSI-X interrupt enabling
Date: Tue, 11 Aug 2026 08:41:02 +0100	[thread overview]
Message-ID: <20260811074102.GV51943@horms.kernel.org> (raw)
In-Reply-To: <086b01dd2937$d65cf7e0$8316e7a0$@trustnetic.com>

On Tue, Aug 11, 2026 at 10:19:28AM +0800, Jiawen Wu wrote:
> On Mon, Aug 10, 2026 11:39 PM, Simon Horman wrote:
> > On Fri, Aug 07, 2026 at 02:22:14PM +0800, Jiawen Wu wrote:
> > > In non-MSI-X mode (such as legacy INTx or single MSI), wx->msix_entry is
> > > not allocated or initialized. Calling NGBE_INTR_MISC(wx) dereferences
> > > wx->msix_entry->entry, leading to a NULL pointer dereference crash.
> > >
> > > This issue was introduced by fixing the IRQ vector when the number of
> > > VFs is 7. Fix the issue by explicitly checking `pdev->msix_enabled` to
> > > determine the correct vector index.
> > >
> > > Additionally, as a side fix, set the interrupt mask to BIT(0) for the
> > > non-MSI-X fallback. In MSI/INTx mode, the MISC and queue interrupts
> > > share vector 0, and the WX_PX_MISC_IVAR register is only valid in the
> > > MSI-X case. Thus, BIT(0) is the correct mask for the miscellaneous cause
> > > when MSI-X is disabled.
> > >
> > > Fixes: 4174c0c331a2 ("net: ngbe: specify IRQ vector when the number of VFs is 7")
> > > Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
> > > Reviewed-by: Breno Leitao <leitao@debian.org>
> > 
> > Hi Jiawen,
> > 
> > I know the topic of BIT(0) came up in v2 - the AI-generated review
> > forwarded by Jakub. And I appreciate you clarifying things in the commit
> > message. But the AI generated review on netdev-qi [1] raises concerns which
> > I'd appreciate you looking over.
> > 
> > [1] https://netdev-ai.bots.linux.dev/sashiko/#/patchset/B2693E9A8BFAD110%2B20260807062214.410838-1-jiawenwu%40trustnetic.com
> > 
> > Although the review rehashes the concerns raised for v2, which you have
> > addressed.  There are three related areas of concern which I can't resolve in
> > my mind.
> > 
> >   1) The question of unmasking IRQ 0,
> >      and the implication of possible interrupt storms.
> > 
> >   2) Compatibility of the BIT(0) change in this patch with the implementation
> >      of wx_configure_vectors()
> > 
> >   3) Is there a need for any similar changes to txgbe.
> 
> 1) The hardware truth regarding WX_PX_MISC_IVAR and BIT(0):
> Sashiko assumes that in non-MSI-X mode, the MISC interrupt cause is mapped to
> BIT(1) because wx_configure_vectors() unconditionally writes to the
> WX_PX_MISC_IVAR register. 
> 
> In reality, on Wangxun hardware, the WX_PX_MISC_IVAR register is *completely
> ignored by the hardware* when MSI-X is not enabled. In legacy INTx or single
> MSI mode, the hardware forcibly merges all interrupt causes (both Queue and
> MISC) into a single bit: BIT(0) of the interrupt cause register. The
> configuration in wx_configure_vectors() for non-MSI-X mode is essentially dead
> code that has no hardware effect. Therefore, BIT(0) is the only correct mask to
> clear.
> 
> 2) Why it won't cause an interrupt storm:
> wx_intr_enable() clears the mask register to *allow* the next interrupt to be
> asserted, it does not force-trigger an interrupt.
> 
> Since Queue and MISC are physically bound to BIT(0) in this mode, if we do not
> unmask BIT(0) here, or mistakenly unmask BIT(1) (which the hardware never uses
> in this mode), the MISC interrupt will remain masked indefinitely. This would
> lead to lost MISC interrupts. The NAPI polling will still correctly handle the
> Rx/Tx cleanups without looping endlessly.
> 
> 3) Regarding txgbe consistency:
> txgbe suffers from the exact same conceptual bug in its non-MSI-X fallback path.
> I will be submitting a separate patch to fix txgbe as well.

Hi Jiawen,

Thanks for your detailed response. I agree that all is in order here.

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


  reply	other threads:[~2026-08-11  7:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-07  6:22 [PATCH net v3] net: ngbe: fix NULL pointer dereference in non-MSI-X interrupt enabling Jiawen Wu
2026-08-10 15:39 ` Simon Horman
2026-08-11  2:19   ` Jiawen Wu
2026-08-11  7:41     ` Simon Horman [this message]
2026-08-11 11: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=20260811074102.GV51943@horms.kernel.org \
    --to=horms@kernel.org \
    --cc=aleksandr.loktionov@intel.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jiawenwu@trustnetic.com \
    --cc=kuba@kernel.org \
    --cc=larysa.zaremba@intel.com \
    --cc=leitao@debian.org \
    --cc=mengyuanlou@net-swift.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=u.kleine-koenig@baylibre.com \
    --cc=weirongguang@kylinos.cn \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.