mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	Maxime Chevallier <maxime.chevallier@bootlin.com>,
	TRINH THAI Florent <florent.trinh-thai@cs-soprasteria.com>,
	CASAUBON Jean Michel <jean-michel.casaubon@cs-soprasteria.com>
Subject: Re: [PATCH net] net: sysfs: Fix deadlock situation in sysfs accesses
Date: Tue, 17 Dec 2024 17:59:54 +0100	[thread overview]
Message-ID: <c63033ff-ff47-4008-b7d3-f07d016496fa@lunn.ch> (raw)
In-Reply-To: <c1d52a7d-b6b2-4150-99c7-a67b2a127a18@csgroup.eu>

On Tue, Dec 17, 2024 at 05:18:40PM +0100, Christophe Leroy wrote:
> 
> 
> Le 17/12/2024 à 16:30, Andrew Lunn a écrit :
> > On Tue, Dec 17, 2024 at 08:18:25AM +0100, Christophe Leroy wrote:
> > > The following problem is encountered on kernel built with
> > > CONFIG_PREEMPT. An snmp daemon running with normal priority is
> > > regularly calling ioctl(SIOCGMIIPHY).
> > 
> > Why is an SNMP daemon using that IOCTL? What MAC driver is this? Is it
> > using phylib? For phylib, that IOCTL is supposed to be for debug only,
> > and is a bit of a foot gun. So i would not recommend it.
> > 
> 
> That's the well-known Net-SNMP package.
> 
> See for instance https://github.com/net-snmp/net-snmp/blob/master/agent/mibgroup/if-mib/data_access/interface_linux.c#L954

That is pretty broken:

It assumes the PHY is using C22. Many PHYs now a days are C45.

It assumes the PHY only supports up to 1G, were as many PHYs now a
days are > 1G.

It assumes the PHY is not an automotive PHY which has its registers in
a different place.

Reading the BMSR can change the BMSR, so phylib is going to get
confused and miss linkup/linkdown events.

There is no locking going on, so the PHY might be on a different page,
e.g. to read the temperature sensors, blink the LEDs, etc. The SNMP
daemon has no way to detect this, so it will be applying BMSR, BMCR,
etc meaning to registers which are in fact not BMSR, BMCR, etc.

This code needs throwing away and replacing with netlink sockets,
which is a lot more abstract API, PHY independent, speed independent,
media independent etc. That would also solve your deadlock.

	Andrew

      reply	other threads:[~2024-12-17 17:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-17  7:18 Christophe Leroy
2024-12-17  8:16 ` Eric Dumazet
2024-12-17  8:59   ` Christophe Leroy
2024-12-17  9:20     ` Eric Dumazet
2024-12-17  9:41       ` Christophe Leroy
2024-12-17  9:52         ` Eric Dumazet
2024-12-17 11:56           ` Christophe Leroy
2024-12-17 12:04             ` Eric Dumazet
2024-12-17 15:30 ` Andrew Lunn
2024-12-17 16:18   ` Christophe Leroy
2024-12-17 16:59     ` Andrew Lunn [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=c63033ff-ff47-4008-b7d3-f07d016496fa@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=christophe.leroy@csgroup.eu \
    --cc=davem@davemloft.net \
    --cc=ebiederm@xmission.com \
    --cc=edumazet@google.com \
    --cc=florent.trinh-thai@cs-soprasteria.com \
    --cc=horms@kernel.org \
    --cc=jean-michel.casaubon@cs-soprasteria.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.chevallier@bootlin.com \
    --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

all inboxes | Powered by JetHome®