* [PATCH net] net: tn40xx: terminate the PHY software node property array
@ 2026-11-24 7:26 FUJITA Tomonori
2026-11-25 16:57 ` Andrew Lunn
2026-11-30 3:50 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 4+ messages in thread
From: FUJITA Tomonori @ 2026-11-24 7:26 UTC (permalink / raw)
To: andrew+netdev, davem, edumazet, kuba, pabeni
Cc: hfdevel, johan, netdev, FUJITA Tomonori
From: FUJITA Tomonori <fujita.tomonori@gmail.com>
The PHY software node uses phy_props[] as its property array. The array
has three entries and no empty entry at the end. Property lookups walk
the array until they find an entry with a NULL name, so they read past
the end of phy_props[].
This happens on every probe of a TN9510 card. When the AQR105 PHY is
registered, mdio_device_register_reset() looks up "reset-gpios" and
"reset-assert-us", and the PHY node has neither of them.
On 32-bit kernels, the walk reads napi.weight in struct tn40_priv as a
name pointer. napi.weight is 64 at this point, so strcmp()
dereferences address 0x40 and the kernel crashes.
On 64-bit kernels, there is no crash only because of the struct
layout: the NULL entry at the end of group[] happens to be at the
offset of a name field, so the walk stops there.
All the properties are constant. Define them in a static const array
with an empty entry at the end, which is the usual way to define
software node properties.
Found by code inspection. The 32-bit crash was reproduced in QEMU with
a test module that sets up the software nodes in struct tn40_priv in
the same way as the driver. The fix was tested on a TN9510 card on
x86_64.
Fixes: 25b6a6d29d40 ("net: tn40xx: create swnode for mdio and aqr105 phy and add to mdiobus")
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
---
drivers/net/ethernet/tehuti/tn40.h | 1 -
drivers/net/ethernet/tehuti/tn40_mdio.c | 14 ++++++++------
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/tehuti/tn40.h b/drivers/net/ethernet/tehuti/tn40.h
index 25da8686d469..73c81cb3e23e 100644
--- a/drivers/net/ethernet/tehuti/tn40.h
+++ b/drivers/net/ethernet/tehuti/tn40.h
@@ -127,7 +127,6 @@ enum tn40_swnodes {
struct tn40_nodes {
char phy_name[32];
char mdio_name[32];
- struct property_entry phy_props[3];
struct software_node swnodes[SWNODE_MAX];
const struct software_node *group[SWNODE_MAX + 1];
};
diff --git a/drivers/net/ethernet/tehuti/tn40_mdio.c b/drivers/net/ethernet/tehuti/tn40_mdio.c
index fb1a4a2e4dbc..c6139f92c23e 100644
--- a/drivers/net/ethernet/tehuti/tn40_mdio.c
+++ b/drivers/net/ethernet/tehuti/tn40_mdio.c
@@ -113,6 +113,13 @@ static int tn40_mdio_write_c45(struct mii_bus *mii_bus, int addr, int devnum,
return tn40_mdio_write(mii_bus->priv, addr, devnum, regnum, val);
}
+static const struct property_entry tn40_phy_props[] = {
+ PROPERTY_ENTRY_STRING("compatible", "ethernet-phy-id03a1.b4a3"),
+ PROPERTY_ENTRY_U32("reg", 1),
+ PROPERTY_ENTRY_STRING("firmware-name", AQR105_FIRMWARE),
+ { }
+};
+
/* registers an mdio node and an aqr105 PHY at address 1
* tn40_mdio-%id {
* ethernet-phy@1 {
@@ -139,14 +146,9 @@ static int tn40_swnodes_register(struct tn40_priv *priv)
swnodes[SWNODE_MDIO] = NODE_PROP(nodes->mdio_name, NULL);
- nodes->phy_props[0] = PROPERTY_ENTRY_STRING("compatible",
- "ethernet-phy-id03a1.b4a3");
- nodes->phy_props[1] = PROPERTY_ENTRY_U32("reg", 1);
- nodes->phy_props[2] = PROPERTY_ENTRY_STRING("firmware-name",
- AQR105_FIRMWARE);
swnodes[SWNODE_PHY] = NODE_PAR_PROP(nodes->phy_name,
&swnodes[SWNODE_MDIO],
- nodes->phy_props);
+ tn40_phy_props);
nodes->group[SWNODE_PHY] = &swnodes[SWNODE_PHY];
nodes->group[SWNODE_MDIO] = &swnodes[SWNODE_MDIO];
base-commit: 4392bb809812ac79449cd0cf1f5e00469ee102d1
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: tn40xx: terminate the PHY software node property array
2026-11-24 7:26 [PATCH net] net: tn40xx: terminate the PHY software node property array FUJITA Tomonori
@ 2026-11-25 16:57 ` Andrew Lunn
2026-11-25 22:21 ` FUJITA Tomonori
2026-11-30 3:50 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 4+ messages in thread
From: Andrew Lunn @ 2026-11-25 16:57 UTC (permalink / raw)
To: FUJITA Tomonori
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, hfdevel, johan,
netdev, FUJITA Tomonori
On Tue, Nov 24, 2026 at 04:26:46PM +0900, FUJITA Tomonori wrote:
> From: FUJITA Tomonori <fujita.tomonori@gmail.com>
>
> The PHY software node uses phy_props[] as its property array. The array
> has three entries and no empty entry at the end. Property lookups walk
> the array until they find an entry with a NULL name, so they read past
> the end of phy_props[].
>
> This happens on every probe of a TN9510 card. When the AQR105 PHY is
> registered, mdio_device_register_reset() looks up "reset-gpios" and
> "reset-assert-us", and the PHY node has neither of them.
>
> On 32-bit kernels, the walk reads napi.weight in struct tn40_priv as a
> name pointer. napi.weight is 64 at this point, so strcmp()
> dereferences address 0x40 and the kernel crashes.
>
> On 64-bit kernels, there is no crash only because of the struct
> layout: the NULL entry at the end of group[] happens to be at the
> offset of a name field, so the walk stops there.
>
> All the properties are constant. Define them in a static const array
> with an empty entry at the end, which is the usual way to define
> software node properties.
>
> Found by code inspection. The 32-bit crash was reproduced in QEMU with
> a test module that sets up the software nodes in struct tn40_priv in
> the same way as the driver. The fix was tested on a TN9510 card on
> x86_64.
The same problem was fixed in the txgbe driver in April.
If you have time, could you look over all ethernet drivers and see if
there are any more drivers with this problem. I don't think there are,
it is pretty unusual to do this, but i don't know every driver...
> Fixes: 25b6a6d29d40 ("net: tn40xx: create swnode for mdio and aqr105 phy and add to mdiobus")
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: tn40xx: terminate the PHY software node property array
2026-11-25 16:57 ` Andrew Lunn
@ 2026-11-25 22:21 ` FUJITA Tomonori
0 siblings, 0 replies; 4+ messages in thread
From: FUJITA Tomonori @ 2026-11-25 22:21 UTC (permalink / raw)
To: andrew
Cc: tomo, andrew+netdev, davem, edumazet, kuba, pabeni, hfdevel,
johan, netdev, fujita.tomonori
On Wed, 25 Nov 2026 17:57:59 +0100
Andrew Lunn <andrew@lunn.ch> wrote:
> On Tue, Nov 24, 2026 at 04:26:46PM +0900, FUJITA Tomonori wrote:
>> From: FUJITA Tomonori <fujita.tomonori@gmail.com>
>>
>> The PHY software node uses phy_props[] as its property array. The array
>> has three entries and no empty entry at the end. Property lookups walk
>> the array until they find an entry with a NULL name, so they read past
>> the end of phy_props[].
[...]
> The same problem was fixed in the txgbe driver in April.
>
> If you have time, could you look over all ethernet drivers and see if
> there are any more drivers with this problem. I don't think there are,
> it is pretty unusual to do this, but i don't know every driver...
Among the ethernet drivers, only txgbe and tn40xx use swnode. I think
that there are no more drivers with this problem.
>> Fixes: 25b6a6d29d40 ("net: tn40xx: create swnode for mdio and aqr105 phy and add to mdiobus")
>> Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: tn40xx: terminate the PHY software node property array
2026-11-24 7:26 [PATCH net] net: tn40xx: terminate the PHY software node property array FUJITA Tomonori
2026-11-25 16:57 ` Andrew Lunn
@ 2026-11-30 3:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-11-30 3:50 UTC (permalink / raw)
To: FUJITA Tomonori
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, hfdevel, johan,
netdev, fujita.tomonori
Hello:
This patch was applied to netdev/net.git (main)
by Willem de Bruijn <willemb@google.com>:
On Tue, 24 Nov 2026 16:26:46 +0900 you wrote:
> From: FUJITA Tomonori <fujita.tomonori@gmail.com>
>
> The PHY software node uses phy_props[] as its property array. The array
> has three entries and no empty entry at the end. Property lookups walk
> the array until they find an entry with a NULL name, so they read past
> the end of phy_props[].
>
> [...]
Here is the summary with links:
- [net] net: tn40xx: terminate the PHY software node property array
https://git.kernel.org/netdev/net/c/274e154322b0
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:[~2026-11-30 3:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 7:26 [PATCH net] net: tn40xx: terminate the PHY software node property array FUJITA Tomonori
2026-11-25 16:57 ` Andrew Lunn
2026-11-25 22:21 ` FUJITA Tomonori
2026-11-30 3:50 ` 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