From: Jacob Keller <jacob.e.keller@intel.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: <jackie.jone@alliedtelesis.co.nz>, <davem@davemloft.net>,
<jesse.brandeburg@intel.com>, <anthony.l.nguyen@intel.com>,
<kuba@kernel.org>, <intel-wired-lan@lists.osuosl.org>,
<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<chris.packham@alliedtelesis.co.nz>
Subject: Re: [PATCH] igb: Add MII write support
Date: Thu, 6 Jun 2024 09:56:08 -0700 [thread overview]
Message-ID: <c12ffb8e-0606-442b-810a-69bf65624bf9@intel.com> (raw)
In-Reply-To: <1dbb8291-9004-4ec2-a01b-9dd5b2a8be39@lunn.ch>
On 6/6/2024 8:41 AM, Andrew Lunn wrote:
> On Wed, Jun 05, 2024 at 01:51:24PM -0700, Jacob Keller wrote:
>>
>>
>> On 6/3/2024 8:10 PM, jackie.jone@alliedtelesis.co.nz wrote:
>>> From: Jackie Jone <jackie.jone@alliedtelesis.co.nz>
>>>
>>> To facilitate running PHY parametric tests, add support for the SIOCSMIIREG
>>> ioctl. This allows a userspace application to write to the PHY registers
>>> to enable the test modes.
>>>
>>> Signed-off-by: Jackie Jone <jackie.jone@alliedtelesis.co.nz>
>>> ---
>>> drivers/net/ethernet/intel/igb/igb_main.c | 4 ++++
>>> 1 file changed, 4 insertions(+)
>>>
>>> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
>>> index 03a4da6a1447..7fbfcf01fbf9 100644
>>> --- a/drivers/net/ethernet/intel/igb/igb_main.c
>>> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
>>> @@ -8977,6 +8977,10 @@ static int igb_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
>>> return -EIO;
>>> break;
>>> case SIOCSMIIREG:
>>> + if (igb_write_phy_reg(&adapter->hw, data->reg_num & 0x1F,
>>> + data->val_in))
>>> + return -EIO;
>>> + break;
>>
>> A handful of drivers seem to expose this. What are the consequences of
>> exposing this ioctl? What can user space do with it?
>
> User space can break the PHY configuration, cause the link to fail,
> all behind the MAC drivers back. The generic version of this call
> tries to see what registers are being written, and update state:
>
> https://elixir.bootlin.com/linux/latest/source/drivers/net/phy/phy.c#L325
>
> But you can still break it.
>
Yea, its extremely easy to break things if you don't know what you're
doing here. So its more a question of "are we ok exposing yet another
way root can brick things?"
>> It looks like a few drivers also check something like CAP_NET_ADMIN to
>> avoid allowing write access to all users. Is that enforced somewhere else?
>
> Only root is allowed to use it. So it is a classic 'You have the
> option to shoot yourself in the foot'.
>
I don't have an objection to enabling this myself, but I do want to be
cognizant of the way it is viewed in the wider community.
> For the use case being talked about here, there has been a few emails
> one the list about implementing the IEEE 802.3 test modes. But nobody
> has actually got around to doing it. Not that it would help in this
> case, Intel don't use the Linux PHY drivers, which is where i would
> expect to see such code implemented first. Maybe if the "Great Intel
> Ethernet driver refactoring" makes progress, it could swap to using
> the Linux PHY drivers.
>
> Andrew
I remember this coming up several times in the past. I've always tried
to push for it, but so far unsuccessfully.
next prev parent reply other threads:[~2024-06-06 16:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-04 3:10 jackie.jone
2024-06-05 20:51 ` Jacob Keller
2024-06-05 21:10 ` Chris Packham
2024-06-05 21:16 ` Jacob Keller
2024-06-05 21:30 ` Chris Packham
2024-06-06 4:30 ` [Intel-wired-lan] " Loktionov, Aleksandr
2024-06-06 15:41 ` Andrew Lunn
2024-06-06 16:56 ` Jacob Keller [this message]
2024-06-06 18:31 ` Andrew Lunn
2024-06-06 18:39 ` Jacob Keller
2024-06-11 11:08 ` [Intel-wired-lan] " Pucha, HimasekharX Reddy
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=c12ffb8e-0606-442b-810a-69bf65624bf9@intel.com \
--to=jacob.e.keller@intel.com \
--cc=andrew@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=chris.packham@alliedtelesis.co.nz \
--cc=davem@davemloft.net \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jackie.jone@alliedtelesis.co.nz \
--cc=jesse.brandeburg@intel.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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®