From: Sean Anderson <sean.anderson@seco.com>
To: Andrew Lunn <andrew@lunn.ch>
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 12:42:50 -0500 [thread overview]
Message-ID: <f58d54ae-c144-2e1b-dc0e-23c7b3d9b489@seco.com> (raw)
In-Reply-To: <ae66193e-db1e-4883-bda1-2be5312630df@lunn.ch>
On 3/7/23 12:23, Andrew Lunn wrote:
>> 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?
Hm, yeah that would probably do it.
>> >> +
>> >> + 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.
Well, this is really just because there is an existing way to specify c22
and c45 addresses in a u16. We could definitely add a "please do C45 over
C22" flag. That said, I think that sort of thing is handled better by
allowing writes in the general case.
>> 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.
I can look into that.
>> >> + 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?
Yes. But it is more like 400 and 600.
> But netlink does not even use file access permissions.
Is EPERM reserved only for files?
> I would probably trap this earlier, where you have a extack instance
> you can return a meaningful error message string.
That sounds good.
--Sean
prev parent reply other threads:[~2023-03-07 17:49 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
2023-03-07 17:42 ` Sean Anderson [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=f58d54ae-c144-2e1b-dc0e-23c7b3d9b489@seco.com \
--to=sean.anderson@seco.com \
--cc=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=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®