* [PATCH net-next] tg3: copy only needed fields from userspace-provided EEE data
@ 2024-02-18 14:49 Heiner Kallweit
2024-02-18 17:04 ` Andrew Lunn
2024-02-21 11:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 4+ messages in thread
From: Heiner Kallweit @ 2024-02-18 14:49 UTC (permalink / raw)
To: Pavan Chebbi, Michael Chan, Jakub Kicinski, David Miller,
Paolo Abeni, Eric Dumazet, Andrew Lunn, Russell King - ARM Linux
Cc: netdev@vger.kernel.org
The current code overwrites fields in tp->eee with unchecked data from
edata, e.g. the bitmap with supported modes. ethtool properly returns
the received data from get_eee() call, but we have no guarantee that
other users of the ioctl set_eee() interface behave properly too.
Therefore copy only fields which are actually needed.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/ethernet/broadcom/tg3.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 51685cd29..7a07c5216 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -14200,7 +14200,9 @@ static int tg3_set_eee(struct net_device *dev, struct ethtool_keee *edata)
return -EINVAL;
}
- tp->eee = *edata;
+ tp->eee.eee_enabled = edata->eee_enabled;
+ tp->eee.tx_lpi_enabled = edata->tx_lpi_enabled;
+ tp->eee.tx_lpi_timer = edata->tx_lpi_timer;
tp->phy_flags |= TG3_PHYFLG_USER_CONFIGURED;
tg3_warn_mgmt_link_flap(tp);
--
2.43.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] tg3: copy only needed fields from userspace-provided EEE data
2024-02-18 14:49 [PATCH net-next] tg3: copy only needed fields from userspace-provided EEE data Heiner Kallweit
@ 2024-02-18 17:04 ` Andrew Lunn
2024-02-18 17:31 ` Heiner Kallweit
2024-02-21 11:20 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 4+ messages in thread
From: Andrew Lunn @ 2024-02-18 17:04 UTC (permalink / raw)
To: Heiner Kallweit
Cc: Pavan Chebbi, Michael Chan, Jakub Kicinski, David Miller,
Paolo Abeni, Eric Dumazet, Russell King - ARM Linux,
netdev@vger.kernel.org
On Sun, Feb 18, 2024 at 03:49:55PM +0100, Heiner Kallweit wrote:
> The current code overwrites fields in tp->eee with unchecked data from
> edata, e.g. the bitmap with supported modes. ethtool properly returns
> the received data from get_eee() call, but we have no guarantee that
> other users of the ioctl set_eee() interface behave properly too.
> Therefore copy only fields which are actually needed.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
This one needed some time for me to understand. I missed that when
programming the PHY to advertise, it is hard coded what it actually
advertises. So there is no need to copy the advertise linkmode from
edata.
I suspect this driver is broken in that it does not wait for the
result of the auto-neg to enable/disable EEE in the hardware. But it
could be hiding somewhere in the code and i also missed that.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] tg3: copy only needed fields from userspace-provided EEE data
2024-02-18 17:04 ` Andrew Lunn
@ 2024-02-18 17:31 ` Heiner Kallweit
0 siblings, 0 replies; 4+ messages in thread
From: Heiner Kallweit @ 2024-02-18 17:31 UTC (permalink / raw)
To: Andrew Lunn
Cc: Pavan Chebbi, Michael Chan, Jakub Kicinski, David Miller,
Paolo Abeni, Eric Dumazet, Russell King - ARM Linux,
netdev@vger.kernel.org
On 18.02.2024 18:04, Andrew Lunn wrote:
> On Sun, Feb 18, 2024 at 03:49:55PM +0100, Heiner Kallweit wrote:
>> The current code overwrites fields in tp->eee with unchecked data from
>> edata, e.g. the bitmap with supported modes. ethtool properly returns
>> the received data from get_eee() call, but we have no guarantee that
>> other users of the ioctl set_eee() interface behave properly too.
>> Therefore copy only fields which are actually needed.
>>
>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>
> This one needed some time for me to understand. I missed that when
> programming the PHY to advertise, it is hard coded what it actually
> advertises. So there is no need to copy the advertise linkmode from
> edata.
>
Especially as we have the following a few lines earlier:
if (!linkmode_equal(edata->advertised, tp->eee.advertised)) {
netdev_warn(tp->dev,
"Direct manipulation of EEE advertisement is not supported\n");
return -EINVAL;
}
> I suspect this driver is broken in that it does not wait for the
> result of the auto-neg to enable/disable EEE in the hardware. But it
> could be hiding somewhere in the code and i also missed that.
>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
>
> Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] tg3: copy only needed fields from userspace-provided EEE data
2024-02-18 14:49 [PATCH net-next] tg3: copy only needed fields from userspace-provided EEE data Heiner Kallweit
2024-02-18 17:04 ` Andrew Lunn
@ 2024-02-21 11:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-02-21 11:20 UTC (permalink / raw)
To: Heiner Kallweit
Cc: pavan.chebbi, mchan, kuba, davem, pabeni, edumazet, andrew, linux,
netdev
Hello:
This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:
On Sun, 18 Feb 2024 15:49:55 +0100 you wrote:
> The current code overwrites fields in tp->eee with unchecked data from
> edata, e.g. the bitmap with supported modes. ethtool properly returns
> the received data from get_eee() call, but we have no guarantee that
> other users of the ioctl set_eee() interface behave properly too.
> Therefore copy only fields which are actually needed.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>
> [...]
Here is the summary with links:
- [net-next] tg3: copy only needed fields from userspace-provided EEE data
https://git.kernel.org/netdev/net-next/c/8306ee08c0ff
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-02-21 11:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-18 14:49 [PATCH net-next] tg3: copy only needed fields from userspace-provided EEE data Heiner Kallweit
2024-02-18 17:04 ` Andrew Lunn
2024-02-18 17:31 ` Heiner Kallweit
2024-02-21 11:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).