From: Jakub Kicinski <kuba@kernel.org>
To: bobbyeshleman@gmail.com
Cc: alexanderduyck@fb.com, kernel-team@meta.com,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
pabeni@redhat.com, linux@armlinux.org.uk, hmohsin@meta.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
bobbyeshleman@meta.com
Subject: Re: [PATCH net v2] eth: fbnic: move aui and fec from fbnic_net to fbnic_dev
Date: Thu, 28 May 2026 17:45:07 -0700 [thread overview]
Message-ID: <20260528174507.3ae6fa6b@kernel.org> (raw)
In-Reply-To: <20260529003714.317617-1-kuba@kernel.org>
On Thu, 28 May 2026 17:37:14 -0700 Jakub Kicinski wrote:
> > @@ -15,18 +14,14 @@ static int
> > fbnic_mdio_read_pmd(struct fbnic_dev *fbd, int addr, int regnum)
> > {
> > u8 aui = FBNIC_AUI_UNKNOWN;
> > - struct fbnic_net *fbn;
> > int ret = 0;
> >
> > /* We don't need a second PMD, just one can handle both lanes */
> > if (addr)
> > return 0;
> >
> > - if (fbd->netdev) {
> > - fbn = netdev_priv(fbd->netdev);
> > - if (fbn->aui < FBNIC_AUI_UNKNOWN)
> > - aui = fbn->aui;
> > - }
> > + if (fbd->aui < FBNIC_AUI_UNKNOWN)
> > + aui = fbd->aui;
>
> [Severity: High]
> This isn't a bug introduced by this patch, but does moving aui and fec to
> struct fbnic_dev actually prevent a use-after-free here?
>
> If fbnic_mdiobus_create() registers the MDIO bus using
> devm_mdiobus_register(), devres-managed resources are cleaned up after the
> driver's remove callback returns.
>
> If fbnic_remove() frees the fbd structure, the bus remains fully active
> between the time the remove function finishes and the devres cleanup
> unregisters the MDIO bus.
>
> Can a concurrent sysfs access invoke MDIO read callbacks which pass fbd
> to this function, leading to a dereference of the freed fbd pointer when
> reading fbd->aui?
Sorry for broadening the scope here a little bit but I think we should
fix this (as well). In the same series, but probably separate patch.
Just don't use devm_, it creates about as many bugs as it prevents.
prev parent reply other threads:[~2026-05-29 0:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 17:21 [PATCH net v2] eth: fbnic: move aui and fec from fbnic_net to fbnic_dev Bobby Eshleman
2026-05-29 0:37 ` Jakub Kicinski
2026-05-29 0:45 ` 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=20260528174507.3ae6fa6b@kernel.org \
--to=kuba@kernel.org \
--cc=alexanderduyck@fb.com \
--cc=andrew+netdev@lunn.ch \
--cc=bobbyeshleman@gmail.com \
--cc=bobbyeshleman@meta.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hmohsin@meta.com \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--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