From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Vladimir Oltean <vladimir.oltean@nxp.com>
Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>, "Andrew Lunn" <andrew@lunn.ch>,
"Florian Fainelli" <f.fainelli@gmail.com>,
"Maxim Georgiev" <glipus@gmail.com>,
"Horatiu Vultur" <horatiu.vultur@microchip.com>,
"Köry Maincent" <kory.maincent@bootlin.com>,
"Maxime Chevallier" <maxime.chevallier@bootlin.com>,
"Richard Cochran" <richardcochran@gmail.com>,
"Vadim Fedorenko" <vadim.fedorenko@linux.dev>,
"Gerhard Engleder" <gerhard@engleder-embedded.com>,
"Hangbin Liu" <liuhangbin@gmail.com>,
"Heiner Kallweit" <hkallweit1@gmail.com>,
"Jacob Keller" <jacob.e.keller@intel.com>,
"Jay Vosburgh" <j.vosburgh@gmail.com>,
"Andy Gospodarek" <andy@greyhouse.net>,
"Wei Fang" <wei.fang@nxp.com>,
"Shenwei Wang" <shenwei.wang@nxp.com>,
"Clark Wang" <xiaoning.wang@nxp.com>,
"NXP Linux Team" <linux-imx@nxp.com>,
UNGLinuxDriver@microchip.com,
"Lars Povlsen" <lars.povlsen@microchip.com>,
"Steen Hegelund" <Steen.Hegelund@microchip.com>,
"Daniel Machon" <daniel.machon@microchip.com>,
"Simon Horman" <simon.horman@corigine.com>,
"Casper Andersson" <casper.casan@gmail.com>,
"Sergey Organov" <sorganov@gmail.com>,
"Michal Kubecek" <mkubecek@suse.cz>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v8 net-next 10/12] net: transfer rtnl_lock() requirement from ethtool_set_ethtool_phy_ops() to caller
Date: Tue, 18 Jul 2023 15:31:03 +0100 [thread overview]
Message-ID: <ZLaiJ4G6TaJYGJyU@shell.armlinux.org.uk> (raw)
In-Reply-To: <20230717152709.574773-11-vladimir.oltean@nxp.com>
On Mon, Jul 17, 2023 at 06:27:07PM +0300, Vladimir Oltean wrote:
> phy_init() and phy_exit() will have to do more stuff under rtnl_lock()
> in a future change. Since rtnl_unlock() -> netdev_run_todo() does a lot
> of stuff under the hood, it's a pity to lock and unlock the rtnetlink
> mutex twice in a row.
>
> Change the calling convention such that the only caller of
> ethtool_set_ethtool_phy_ops(), phy_device.c, provides a context where
> the rtnl_mutex is already acquired.
>
> Note that phy_exit() wasn't performing the opposite teardown of
> phy_init(). Reverse mdio_bus_init() with ethtool_set_ethtool_phy_ops(),
> so that this is now the case.
To me, this looks buggy.
> @@ -3451,11 +3452,14 @@ static int __init phy_init(void)
> {
> int rc;
>
> + rtnl_lock();
> + ethtool_set_ethtool_phy_ops(&phy_ethtool_phy_ops);
> + rtnl_unlock();
> +
> rc = mdio_bus_init();
> if (rc)
> return rc;
If mdio_bus_init() fails, and phylib is built as a module, then we
leave ethtool_phy_ops pointing into module space that has potentially
been freed or re-used for another module. This error path needs to
properly clean up.
The same is also true for the other failure paths in phy_init() which
already do not cater for their failures leaving a dangling pointer in
ethtool_phy_ops. This should probably be fixed first in a separate
patch for the net tree.
Thanks.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Vladimir Oltean <vladimir.oltean@nxp.com>
Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>, "Andrew Lunn" <andrew@lunn.ch>,
"Florian Fainelli" <f.fainelli@gmail.com>,
"Maxim Georgiev" <glipus@gmail.com>,
"Horatiu Vultur" <horatiu.vultur@microchip.com>,
"Köry Maincent" <kory.maincent@bootlin.com>,
"Maxime Chevallier" <maxime.chevallier@bootlin.com>,
"Richard Cochran" <richardcochran@gmail.com>,
"Vadim Fedorenko" <vadim.fedorenko@linux.dev>,
"Gerhard Engleder" <gerhard@engleder-embedded.com>,
"Hangbin Liu" <liuhangbin@gmail.com>,
"Heiner Kallweit" <hkallweit1@gmail.com>,
"Jacob Keller" <jacob.e.keller@intel.com>,
"Jay Vosburgh" <j.vosburgh@gmail.com>,
"Andy Gospodarek" <andy@greyhouse.net>,
"Wei Fang" <wei.fang@nxp.com>,
"Shenwei Wang" <shenwei.wang@nxp.com>,
"Clark Wang" <xiaoning.wang@nxp.com>,
"NXP Linux Team" <linux-imx@nxp.com>,
UNGLinuxDriver@microchip.com,
"Lars Povlsen" <lars.povlsen@microchip.com>,
"Steen Hegelund" <Steen.Hegelund@microchip.com>,
"Daniel Machon" <daniel.machon@microchip.com>,
"Simon Horman" <simon.horman@corigine.com>,
"Casper Andersson" <casper.casan@gmail.com>,
"Sergey Organov" <sorganov@gmail.com>,
"Michal Kubecek" <mkubecek@suse.cz>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v8 net-next 10/12] net: transfer rtnl_lock() requirement from ethtool_set_ethtool_phy_ops() to caller
Date: Tue, 18 Jul 2023 15:31:03 +0100 [thread overview]
Message-ID: <ZLaiJ4G6TaJYGJyU@shell.armlinux.org.uk> (raw)
In-Reply-To: <20230717152709.574773-11-vladimir.oltean@nxp.com>
On Mon, Jul 17, 2023 at 06:27:07PM +0300, Vladimir Oltean wrote:
> phy_init() and phy_exit() will have to do more stuff under rtnl_lock()
> in a future change. Since rtnl_unlock() -> netdev_run_todo() does a lot
> of stuff under the hood, it's a pity to lock and unlock the rtnetlink
> mutex twice in a row.
>
> Change the calling convention such that the only caller of
> ethtool_set_ethtool_phy_ops(), phy_device.c, provides a context where
> the rtnl_mutex is already acquired.
>
> Note that phy_exit() wasn't performing the opposite teardown of
> phy_init(). Reverse mdio_bus_init() with ethtool_set_ethtool_phy_ops(),
> so that this is now the case.
To me, this looks buggy.
> @@ -3451,11 +3452,14 @@ static int __init phy_init(void)
> {
> int rc;
>
> + rtnl_lock();
> + ethtool_set_ethtool_phy_ops(&phy_ethtool_phy_ops);
> + rtnl_unlock();
> +
> rc = mdio_bus_init();
> if (rc)
> return rc;
If mdio_bus_init() fails, and phylib is built as a module, then we
leave ethtool_phy_ops pointing into module space that has potentially
been freed or re-used for another module. This error path needs to
properly clean up.
The same is also true for the other failure paths in phy_init() which
already do not cater for their failures leaving a dangling pointer in
ethtool_phy_ops. This should probably be fixed first in a separate
patch for the net tree.
Thanks.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2023-07-19 6:11 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-17 15:26 [PATCH v8 net-next 00/12] Introduce ndo_hwtstamp_get() and ndo_hwtstamp_set() Vladimir Oltean
2023-07-17 15:26 ` Vladimir Oltean
2023-07-17 15:26 ` [PATCH v8 net-next 01/12] net: add NDOs for configuring hardware timestamping Vladimir Oltean
2023-07-17 15:26 ` Vladimir Oltean
2023-07-17 15:26 ` [PATCH v8 net-next 02/12] net: add hwtstamping helpers for stackable net devices Vladimir Oltean
2023-07-17 15:26 ` Vladimir Oltean
2023-07-17 15:27 ` [PATCH v8 net-next 03/12] net: vlan: convert to ndo_hwtstamp_get() / ndo_hwtstamp_set() Vladimir Oltean
2023-07-17 15:27 ` Vladimir Oltean
2023-07-17 15:27 ` [PATCH v8 net-next 04/12] net: macvlan: " Vladimir Oltean
2023-07-17 15:27 ` Vladimir Oltean
2023-07-17 15:27 ` [PATCH v8 net-next 05/12] net: bonding: " Vladimir Oltean
2023-07-17 15:27 ` Vladimir Oltean
2023-07-17 15:27 ` [PATCH v8 net-next 06/12] net: fec: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set() Vladimir Oltean
2023-07-17 15:27 ` Vladimir Oltean
2023-07-18 14:20 ` Russell King (Oracle)
2023-07-18 14:20 ` Russell King (Oracle)
2023-08-01 13:12 ` Vladimir Oltean
2023-08-01 13:12 ` Vladimir Oltean
2023-07-17 15:27 ` [PATCH v8 net-next 07/12] net: fec: delete fec_ptp_disable_hwts() Vladimir Oltean
2023-07-17 15:27 ` Vladimir Oltean
2023-07-17 15:27 ` [PATCH v8 net-next 08/12] net: sparx5: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set() Vladimir Oltean
2023-07-17 15:27 ` Vladimir Oltean
2023-07-18 14:06 ` Steen Hegelund
2023-07-18 14:06 ` Steen Hegelund
2023-07-17 15:27 ` [PATCH v8 net-next 09/12] net: lan966x: " Vladimir Oltean
2023-07-17 15:27 ` Vladimir Oltean
2023-07-17 15:27 ` [PATCH v8 net-next 10/12] net: transfer rtnl_lock() requirement from ethtool_set_ethtool_phy_ops() to caller Vladimir Oltean
2023-07-17 15:27 ` Vladimir Oltean
2023-07-18 14:31 ` Russell King (Oracle) [this message]
2023-07-18 14:31 ` Russell King (Oracle)
2023-07-17 15:27 ` [PATCH v8 net-next 11/12] net: phy: provide phylib stubs for hardware timestamping operations Vladimir Oltean
2023-07-17 15:27 ` Vladimir Oltean
2023-07-18 8:36 ` Vladimir Oltean
2023-07-18 8:36 ` Vladimir Oltean
2023-07-18 15:49 ` kernel test robot
2023-07-18 15:49 ` kernel test robot
2023-07-18 16:00 ` kernel test robot
2023-07-17 15:27 ` [PATCH v8 net-next 12/12] net: remove phy_has_hwtstamp() -> phy_mii_ioctl() decision from converted drivers Vladimir Oltean
2023-07-17 15:27 ` Vladimir Oltean
2023-07-18 14:38 ` Russell King (Oracle)
2023-07-18 14:38 ` Russell King (Oracle)
2023-07-18 14:46 ` Vladimir Oltean
2023-07-18 14:46 ` Vladimir Oltean
2023-07-18 8:39 ` [PATCH v8 net-next 00/12] Introduce ndo_hwtstamp_get() and ndo_hwtstamp_set() Vladimir Oltean
2023-07-18 8:39 ` Vladimir Oltean
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=ZLaiJ4G6TaJYGJyU@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=Steen.Hegelund@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=andy@greyhouse.net \
--cc=casper.casan@gmail.com \
--cc=daniel.machon@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=gerhard@engleder-embedded.com \
--cc=glipus@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=horatiu.vultur@microchip.com \
--cc=j.vosburgh@gmail.com \
--cc=jacob.e.keller@intel.com \
--cc=kory.maincent@bootlin.com \
--cc=kuba@kernel.org \
--cc=lars.povlsen@microchip.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=liuhangbin@gmail.com \
--cc=maxime.chevallier@bootlin.com \
--cc=mkubecek@suse.cz \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=shenwei.wang@nxp.com \
--cc=simon.horman@corigine.com \
--cc=sorganov@gmail.com \
--cc=vadim.fedorenko@linux.dev \
--cc=vladimir.oltean@nxp.com \
--cc=wei.fang@nxp.com \
--cc=xiaoning.wang@nxp.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 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.