From: Andrew Lunn <andrew@lunn.ch>
To: Sean Anderson <sean.anderson@seco.com>
Cc: Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
netdev@vger.kernel.org, "David S . Miller" <davem@davemloft.net>,
Vladimir Oltean <olteanv@gmail.com>,
linux-kernel@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>,
Eric Dumazet <edumazet@google.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Tobias Waldekranz <tobias@waldekranz.com>,
Jakub Kicinski <kuba@kernel.org>
Subject: Re: [PATCH net-next] net: mdio: Add netlink interface
Date: Tue, 7 Mar 2023 18:23:32 +0100 [thread overview]
Message-ID: <ae66193e-db1e-4883-bda1-2be5312630df@lunn.ch> (raw)
In-Reply-To: <f947e5e2-770e-4b12-67ae-8abf5866e250@seco.com>
> Yes, and I should probably have commented on this in the commit message.
> IMO the things you listed are... iffy but unlikely to cause a
> malfunction.
You consider a missed interrupt not a malfunction?
> >> +
> >> + for (insn = xfer->prog, pc = 0;
> >> + pc < xfer->prog_len;
> >> + insn = &xfer->prog[++pc]) {
> >> + if (time_after(jiffies, timeout)) {
> >> + ret = -ETIMEDOUT;
> >> + break;
> >> + }
> >> +
> >> + switch ((enum mdio_nl_op)insn->op) {
> >> + case MDIO_NL_OP_READ:
> >> + phy_id = __arg_ri(insn->arg0, regs);
> >> + prtad = mdio_phy_id_prtad(phy_id);
> >> + devad = mdio_phy_id_devad(phy_id);
> >> + reg = __arg_ri(insn->arg1, regs);
> >> +
> >> + if (mdio_phy_id_is_c45(phy_id))
> >> + ret = __mdiobus_c45_read(xfer->mdio, prtad,
> >> + devad, reg);
> >> + else
> >> + ret = __mdiobus_read(xfer->mdio, phy_id, reg);
> >
> > The application should say if it want to do C22 or C45.
>
> The phy_id comes from the application. So it sets MDIO_PHY_ID_C45 if it wants
> to use C45.
Ah, i misunderstood what mdio_phy_id_is_c45() does.
Anyway, i don't like MDIO_PHY_ID_C45, it has been pretty much removed
everywhere with the refactoring of MDIO drivers to export read and
read_c45 etc. PHY drivers also don't use it, they use c22 or c45
specific methods. So i would prefer an additional attribute. That also
opens up the possibility of adding C45 over C22.
> As Russell noted, this is dangerous in the general case.
And Russell also agreed this whole module is dangerous in general.
Once you accept it is dangerous, its a debug tool only, why not allow
playing with a bit more fire? You could at least poke around the MDIO
bus structures and see if a PHY has been found, and it not, block C45
over C22.
> >> + if (mdio_phy_id_is_c45(phy_id))
> >> + ret = __mdiobus_c45_write(xfer->mdio, prtad,
> >> + devad, reg, val
> >> + else
> >> + ret = __mdiobus_write(xfer->mdio, dev, reg,
> >> + val);
> >> +#else
> >> + ret = -EPERM;
> >
> > EPERM is odd, EOPNOTSUPP would be better. EPERM suggests you can run
> > it as root and it should work.
>
> Well, EPERM is what you get when trying to write a 444 file, which is
> effectively what we're enforcing here.
Does it change to 644 when write is enabled? But netlink does not even
use file access permissions. I would probably trap this earlier, where
you have a extack instance you can return a meaningful error message
string.
Andrew
next prev parent reply other threads:[~2023-03-07 17:28 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-06 20:45 Sean Anderson
2023-03-06 22:48 ` Russell King (Oracle)
2023-03-06 23:39 ` Sean Anderson
2023-03-07 13:47 ` Andrew Lunn
2023-03-07 16:41 ` Sean Anderson
2023-03-07 0:05 ` kernel test robot
2023-03-07 11:23 ` Michael Walle
2023-03-07 13:49 ` Andrew Lunn
2023-03-07 14:05 ` Vladimir Oltean
2023-03-07 14:33 ` Andrew Lunn
2023-03-07 15:00 ` Russell King (Oracle)
2023-03-07 12:26 ` Tobias Waldekranz
2023-03-07 16:30 ` Sean Anderson
2023-03-07 14:22 ` Andrew Lunn
2023-03-07 14:50 ` Russell King (Oracle)
2023-03-07 16:16 ` Sean Anderson
2023-03-07 17:23 ` Andrew Lunn [this message]
2023-03-07 17:42 ` Sean Anderson
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=ae66193e-db1e-4883-bda1-2be5312630df@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=sean.anderson@seco.com \
--cc=tobias@waldekranz.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®