All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] ethtool: prevent endless loop if eeprom size is smaller than announced
@ 2021-09-13 19:58 Heiner Kallweit
  2021-09-14 13:30 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Heiner Kallweit @ 2021-09-13 19:58 UTC (permalink / raw)
  To: Jakub Kicinski, David Miller; +Cc: netdev

It shouldn't happen, but can happen that readable eeprom size is smaller
than announced. Then we would be stuck in an endless loop here because
after reaching the actual end reads return eeprom.len = 0. I faced this
issue when making a mistake in driver development. Detect this scenario
and return an error.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 net/ethtool/ioctl.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index f2abc3152..999e2a6be 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -1537,6 +1537,10 @@ static int ethtool_get_any_eeprom(struct net_device *dev, void __user *useraddr,
 		ret = getter(dev, &eeprom, data);
 		if (ret)
 			break;
+		if (!eeprom.len) {
+			ret = -EIO;
+			break;
+		}
 		if (copy_to_user(userbuf, data, eeprom.len)) {
 			ret = -EFAULT;
 			break;
-- 
2.33.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] ethtool: prevent endless loop if eeprom size is smaller than announced
  2021-09-13 19:58 [PATCH net-next] ethtool: prevent endless loop if eeprom size is smaller than announced Heiner Kallweit
@ 2021-09-14 13:30 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-09-14 13:30 UTC (permalink / raw)
  To: Heiner Kallweit; +Cc: kuba, davem, netdev

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Mon, 13 Sep 2021 21:58:26 +0200 you wrote:
> It shouldn't happen, but can happen that readable eeprom size is smaller
> than announced. Then we would be stuck in an endless loop here because
> after reaching the actual end reads return eeprom.len = 0. I faced this
> issue when making a mistake in driver development. Detect this scenario
> and return an error.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> 
> [...]

Here is the summary with links:
  - [net-next] ethtool: prevent endless loop if eeprom size is smaller than announced
    https://git.kernel.org/netdev/net-next/c/b9bbc4c1debc

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] 2+ messages in thread

end of thread, other threads:[~2021-09-14 13:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-13 19:58 [PATCH net-next] ethtool: prevent endless loop if eeprom size is smaller than announced Heiner Kallweit
2021-09-14 13:30 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.