Subject: Re: [PATCH v1 net-next 2/2] igb: support SIOCSMIIREG

From: Alexander Duyck <[email-masked]>
Date: Thu, 07 May 2015 10:52:06 -0700

On 04/17/2015 01:24 PM, Jonathan Toppins wrote:
> From: Alan Liebthal <[email-masked]>
>
> Support setting the MII register via SIOCSMIIREG.
>
> Signed-off-by: Alan Liebthal <[email-masked]>
> Signed-off-by: Jonathan Toppins <[email-masked]>
> ---
>   drivers/net/ethernet/intel/igb/igb_main.c |    5 +++++
>   1 file changed, 5 insertions(+)
>
> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
> index 720b785..1071a71 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -7141,6 +7141,11 @@ static int igb_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
>   			return -EIO;
>   		break;
>   	case SIOCSMIIREG:
> +		adapter->hw.phy.addr = data->phy_id;
> +		if (igb_write_phy_reg(&adapter->hw, data->reg_num & 0x1F,
> +				      data->val_in))
> +			return -EIO;
> +		break;
>   	default:
>   		return -EOPNOTSUPP;
>   	}

How and why is this being used?  From what I can tell it looks like it 
is an easy way to break any of the existing interfaces if it is misused 
since all you would need to do is specify a phy address that doesn't 
match the existing PHY in the system and then you would likely lose 
link, or possibly mess up the configuration on the system requiring.

I suspect this is a back door for some piece of user space code that is 
being given far more permission than it should be.

- Alex