* [PATCH net] broadcom: b44: prevent uninitialized value usage
@ 2025-12-04 5:22 Alexey Simakov
2025-12-04 13:34 ` Andrew Lunn
2025-12-04 13:39 ` Jonas Gorski
0 siblings, 2 replies; 4+ messages in thread
From: Alexey Simakov @ 2025-12-04 5:22 UTC (permalink / raw)
To: Michael Chan
Cc: Alexey Simakov, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Michael Buesch, John W. Linville,
netdev, linux-kernel, lvc-project
On execution path with raised B44_FLAG_EXTERNAL_PHY, b44_readphy()
leaves bmcr value uninitialized and it is used later in the code.
Add check of this flag at the beginning of the b44_nway_reset() and
exit early of the function if an external PHY is used, that would
also correspond to other b44_readphy() call sites.
Found by Linux Verification Center (linuxtesting.org) with Svace.
Fixes: 753f492093da ("[B44]: port to native ssb support")
Signed-off-by: Alexey Simakov <bigalex934@gmail.com>
---
drivers/net/ethernet/broadcom/b44.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c
index 0353359c3fe9..cbfd65881326 100644
--- a/drivers/net/ethernet/broadcom/b44.c
+++ b/drivers/net/ethernet/broadcom/b44.c
@@ -1789,6 +1789,9 @@ static int b44_nway_reset(struct net_device *dev)
u32 bmcr;
int r;
+ if (bp->flags & B44_FLAG_EXTERNAL_PHY)
+ return 0;
+
spin_lock_irq(&bp->lock);
b44_readphy(bp, MII_BMCR, &bmcr);
b44_readphy(bp, MII_BMCR, &bmcr);
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] broadcom: b44: prevent uninitialized value usage
2025-12-04 5:22 [PATCH net] broadcom: b44: prevent uninitialized value usage Alexey Simakov
@ 2025-12-04 13:34 ` Andrew Lunn
2025-12-04 13:39 ` Jonas Gorski
1 sibling, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2025-12-04 13:34 UTC (permalink / raw)
To: Alexey Simakov
Cc: Michael Chan, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Michael Buesch, John W. Linville,
netdev, linux-kernel, lvc-project
On Thu, Dec 04, 2025 at 08:22:43AM +0300, Alexey Simakov wrote:
> On execution path with raised B44_FLAG_EXTERNAL_PHY, b44_readphy()
> leaves bmcr value uninitialized and it is used later in the code.
>
> Add check of this flag at the beginning of the b44_nway_reset() and
> exit early of the function if an external PHY is used, that would
> also correspond to other b44_readphy() call sites.
>
> Found by Linux Verification Center (linuxtesting.org) with Svace.
>
> Fixes: 753f492093da ("[B44]: port to native ssb support")
> Signed-off-by: Alexey Simakov <bigalex934@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] broadcom: b44: prevent uninitialized value usage
2025-12-04 5:22 [PATCH net] broadcom: b44: prevent uninitialized value usage Alexey Simakov
2025-12-04 13:34 ` Andrew Lunn
@ 2025-12-04 13:39 ` Jonas Gorski
2025-12-04 13:42 ` Andrew Lunn
1 sibling, 1 reply; 4+ messages in thread
From: Jonas Gorski @ 2025-12-04 13:39 UTC (permalink / raw)
To: Alexey Simakov, Michael Chan
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Michael Buesch, John W. Linville, netdev,
linux-kernel, lvc-project
Hi,
On 12/4/25 06:22, Alexey Simakov wrote:
> On execution path with raised B44_FLAG_EXTERNAL_PHY, b44_readphy()
> leaves bmcr value uninitialized and it is used later in the code.
>
> Add check of this flag at the beginning of the b44_nway_reset() and
> exit early of the function if an external PHY is used, that would
> also correspond to other b44_readphy() call sites.
>
> Found by Linux Verification Center (linuxtesting.org) with Svace.
>
> Fixes: 753f492093da ("[B44]: port to native ssb support")
> Signed-off-by: Alexey Simakov <bigalex934@gmail.com>
> ---
> drivers/net/ethernet/broadcom/b44.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c
> index 0353359c3fe9..cbfd65881326 100644
> --- a/drivers/net/ethernet/broadcom/b44.c
> +++ b/drivers/net/ethernet/broadcom/b44.c
> @@ -1789,6 +1789,9 @@ static int b44_nway_reset(struct net_device *dev)
> u32 bmcr;
> int r;
>
> + if (bp->flags & B44_FLAG_EXTERNAL_PHY)
> + return 0;
Wouldn't the right fix here to call phy_ethtool_nway_reset(dev->phydev); instead
of just returning 0? That way it properly restarts auto-negotiation even in this
case.
> +
> spin_lock_irq(&bp->lock);
> b44_readphy(bp, MII_BMCR, &bmcr);
> b44_readphy(bp, MII_BMCR, &bmcr);
Best regards,
Jonas
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] broadcom: b44: prevent uninitialized value usage
2025-12-04 13:39 ` Jonas Gorski
@ 2025-12-04 13:42 ` Andrew Lunn
0 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2025-12-04 13:42 UTC (permalink / raw)
To: Jonas Gorski
Cc: Alexey Simakov, Michael Chan, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Michael Buesch,
John W. Linville, netdev, linux-kernel, lvc-project
> > +++ b/drivers/net/ethernet/broadcom/b44.c
> > @@ -1789,6 +1789,9 @@ static int b44_nway_reset(struct net_device *dev)
> > u32 bmcr;
> > int r;
> >
> > + if (bp->flags & B44_FLAG_EXTERNAL_PHY)
> > + return 0;
>
> Wouldn't the right fix here to call phy_ethtool_nway_reset(dev->phydev); instead
> of just returning 0? That way it properly restarts auto-negotiation even in this
> case.
Actually, yes. ksettings_set() etc do exactly that. Let me change my
Reviewed by into a Change Request.
Thanks
Andrew
---
pw-bot: cr
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-12-04 13:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-04 5:22 [PATCH net] broadcom: b44: prevent uninitialized value usage Alexey Simakov
2025-12-04 13:34 ` Andrew Lunn
2025-12-04 13:39 ` Jonas Gorski
2025-12-04 13:42 ` Andrew Lunn
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).