Skip to contentSkip to conversation

ethtool: zero initialize coalesce struct

PATCH In review Maciej Żenczykowski 4 participants 5 messages Dec 15, 2018 – Jan 18, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ethtool: zero initialize coalesce struct

From: Maciej Żenczykowski <[email protected]>

prior to fetching it from kernel.

Otherwise we run the risk of very tail portion of it (dmac field) being left entirely uninitialized, and likely containing some sort of stale data.

It seems to likely be some sort of time (a second's counter).

Tested:
'ethtool -c eth1' with old kernel now reports 'dmac: 0' where previously it reported some sort of second counter.

---
 ethtool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ethtool.c +1 -1
index 2f7e96bb58db..465eeecb9318 100644
@@ -2076,7 +2076,7 @@ static int do_gchannels(struct cmd_context *ctx)
 
 static int do_gcoalesce(struct cmd_context *ctx)
 {
-	struct ethtool_coalesce ecoal;
+	struct ethtool_coalesce ecoal = {};
 	int err;
 
 	if (ctx->argc != 0)
Signature · 1 line
2.20.0.405.gbc1bbc6f85-goog
#1 lore raw
Quoted 7 lines · Maciej Żenczykowski

From: Maciej Żenczykowski <[email protected]>

prior to fetching it from kernel.

Otherwise we run the risk of very tail portion of it (dmac field) being left entirely uninitialized, and likely containing some sort of stale data.

The dmac member of struct ethtool_coalesce was removed by commit c0b078ce7e88 ("Revert "ethtool: Add DMA Coalescing support"") because it has never been added in kernel (as that would break compatibility with older ethtool versions).

Michal Kubecek

#2 lore raw
Quoted 4 lines

The dmac member of struct ethtool_coalesce was removed by commit c0b078ce7e88 ("Revert "ethtool: Add DMA Coalescing support"") because it has never been added in kernel (as that would break compatibility with older ethtool versions).

Hmm, well, it doesn't hurt to zero init either way...

#3 lore raw
In reply to Maciej Żenczykowski

I handed over ethtool to John Linville some time ago.

Ben.

Quoted 32 lines · Maciej Żenczykowski

From: Maciej Żenczykowski <[email protected]>

prior to fetching it from kernel.

Otherwise we run the risk of very tail portion of it (dmac field) being left entirely uninitialized, and likely containing some sort of stale data.

It seems to likely be some sort of time (a second's counter).

Tested:
'ethtool -c eth1' with old kernel now reports 'dmac: 0' where previously it reported some sort of second counter.

---
 ethtool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ethtool.c +1 -1
index 2f7e96bb58db..465eeecb9318 100644
@@ -2076,7 +2076,7 @@ static int do_gchannels(struct cmd_context *ctx)
 
 static int do_gcoalesce(struct cmd_context *ctx)
 {
-	struct ethtool_coalesce ecoal;
+	struct ethtool_coalesce ecoal = {};
 	int err;
 
 	if (ctx->argc != 0)
Signature · 2 lines
Ben Hutchings
If you seem to know what you are doing, you'll be given more to do.
#4 lore raw
In reply to Maciej Żenczykowski
Quoted 8 lines · Maciej Żenczykowski

From: Maciej Żenczykowski <[email protected]>

prior to fetching it from kernel.

Otherwise we run the risk of very tail portion of it (dmac field) being left entirely uninitialized, and likely containing some sort of stale data.

Quoted 7 lines

It seems to likely be some sort of time (a second's counter).

Tested:
'ethtool -c eth1' with old kernel now reports 'dmac: 0' where previously it reported some sort of second counter.

Queued for next release.

Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
[email protected]			might be all we have.  Be ready.