All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Heiner Kallweit <hkallweit1@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>
Subject: Re: [PATCH RFT net-next] net: mdio: ensure the type of mdio devices match mdio drivers
Date: Thu, 30 Sep 2021 16:15:36 +0100	[thread overview]
Message-ID: <YVXUmDkkTT3ihKh0@shell.armlinux.org.uk> (raw)
In-Reply-To: <YVXQrTe392mMNAa+@lunn.ch>

On Thu, Sep 30, 2021 at 04:58:53PM +0200, Andrew Lunn wrote:
> On Thu, Sep 30, 2021 at 03:54:44PM +0100, Russell King (Oracle) wrote:
> > On the MDIO bus, we have PHYLIB devices and drivers, and we have non-
> > PHYLIB devices and drivers. PHYLIB devices are MDIO devices that are
> > wrapped with a struct phy_device.
> > 
> > Trying to bind a MDIO device with a PHYLIB driver results in out-of-
> > bounds accesses as we attempt to access struct phy_device members. So,
> > let's prevent this by ensuring that the type of the MDIO device
> > (indicated by the MDIO_DEVICE_FLAG_PHY flag) matches the type of the
> > MDIO driver (indicated by the MDIO_DEVICE_IS_PHY flag.)
> > 
> > Link: https://lore.kernel.org/r/2b1dc053-8c9a-e3e4-b450-eecdfca3fe16@gmail.com
> > Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> > ---
> > Tested locally in SolidRun Clearfog, DSA switch and PHY get probed
> > correctly. Further testing welcomed.
> > 
> >  drivers/net/phy/mdio_bus.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
> > index 53f034fc2ef7..779e49715e91 100644
> > --- a/drivers/net/phy/mdio_bus.c
> > +++ b/drivers/net/phy/mdio_bus.c
> > @@ -939,6 +939,12 @@ EXPORT_SYMBOL_GPL(mdiobus_modify);
> >  static int mdio_bus_match(struct device *dev, struct device_driver *drv)
> >  {
> >  	struct mdio_device *mdio = to_mdio_device(dev);
> > +	struct mdio_driver *mdiodrv = to_mdio_driver(drv);
> 
> DaveM would request these two lines are swapped for reverse Christmas tree.

Yep. I'll get around to that sometime.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

      reply	other threads:[~2021-09-30 15:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-30 14:54 [PATCH RFT net-next] net: mdio: ensure the type of mdio devices match mdio drivers Russell King (Oracle)
2021-09-30 14:58 ` Andrew Lunn
2021-09-30 15:15   ` Russell King (Oracle) [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=YVXUmDkkTT3ihKh0@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    /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.