mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kory Maincent <kory.maincent@bootlin.com>
To: Wei Fang <wei.fang@nxp.com>
Cc: Vladimir Oltean <vladimir.oltean@nxp.com>,
	Claudiu Manoil <claudiu.manoil@nxp.com>,
	Clark Wang <xiaoning.wang@nxp.com>, "Y.B. Lu" <yangbo.lu@nxp.com>,
	"richardcochran@gmail.com" <richardcochran@gmail.com>,
	"andrew+netdev@lunn.ch" <andrew+netdev@lunn.ch>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"edumazet@google.com" <edumazet@google.com>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	Frank Li <frank.li@nxp.com>,
	"imx@lists.linux.dev" <imx@lists.linux.dev>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next] net: enetc: use generic interfaces to get phc_index for ENETC v1
Date: Tue, 23 Sep 2025 01:33:48 +0200	[thread overview]
Message-ID: <20250923013348.62f44bba@kmaincent-XPS-13-7390> (raw)
In-Reply-To: <PAXPR04MB8510ABEC85E704D1289A0E098811A@PAXPR04MB8510.eurprd04.prod.outlook.com>

On Fri, 19 Sep 2025 08:48:57 +0000
Wei Fang <wei.fang@nxp.com> wrote:

> > > It looks like we have a problem and can't call pci_get_slot(), which
> > > sleeps on down_read(&pci_bus_sem), from ethtool_ops :: get_ts_info(),
> > > which can't sleep, as of commit 4c61d809cf60 ("net: ethtool: Fix
> > > suspicious rcu_dereference usage").
> > >
> > > Köry, do you have any comments or suggestions? Patch is here:
> > >  
> > https://lore.kern/
> > el.org%2Fnetdev%2F20250918074454.1742328-1-wei.fang%40nxp.com%2F&d
> > ata=05%7C02%7Cwei.fang%40nxp.com%7Cca70608eb6c9487d98e108ddf7571
> > de6%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63893867571474
> > 2481%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjA
> > uMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7
> > C%7C&sdata=h6rMPPxArsYdoPOz95UZRU88Oz9IJ3sD6lRjqC5SHMU%3D&reser
> > ved=0
> >
> > This is annoying indeed. I don't know how this enetc drivers works but why
> > ts_info needs this pci_get_slot() call? It seems this call seems to not be
> > used in ndo_hwtstamp_get/set while ts_info which does not need any hardware
> > communication report only a list of capabilities.
> >  
> 
> The ENETC (MAC controller) and the PTP timer are separate devices, they
> are both PCIe devices, the PTP timer provides the PHC for ENETC to use, so
> enetc_get_ts_info() needs to get the phc_index of the PTP timer, so
> pci_get_slot() is called to get the pci_dev pointer of the PTP timer. I can
> use pci_get_domain_bus_and_slot() to instead to fix this issue.
> 
> I do not know whether it is a good idea to place the get_ts_info() callback
> within an atomic lock context. I also noticed that idpf driver also has the
> same potential issue (idpf_get_ts_info()).

We can change the device providing the PTP (currently between MAC or PHY),
that's why we need to acquire the rcu lock to avoid any pointer change during
the get_ts_info callback which could cause an use after free issue.

Regards,
-- 
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com

  reply	other threads:[~2025-09-22 23:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-18  7:44 Wei Fang
2025-09-18 12:48 ` Vladimir Oltean
2025-09-19  2:02   ` Wei Fang
2025-09-19  8:32   ` Kory Maincent
2025-09-19  8:48     ` Wei Fang
2025-09-22 23:33       ` Kory Maincent [this message]
2025-09-19  2:14 ` kernel test robot

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=20250923013348.62f44bba@kmaincent-XPS-13-7390 \
    --to=kory.maincent@bootlin.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=frank.li@nxp.com \
    --cc=imx@lists.linux.dev \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=vladimir.oltean@nxp.com \
    --cc=wei.fang@nxp.com \
    --cc=xiaoning.wang@nxp.com \
    --cc=yangbo.lu@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®