Thread View: linux.kernel.netdev
4 messages
4 total messages
Started by FUJITA Tomonori
Tue, 24 Nov 2026 07:26
[PATCH net] net: tn40xx: terminate the PHY software node property array
Author: FUJITA Tomonori
Date: Tue, 24 Nov 2026 07:26
Date: Tue, 24 Nov 2026 07:26
86 lines
15870 bytes
15870 bytes
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
Re: [PATCH net] net: tn40xx: terminate the PHY software node property array
Author: Andrew Lunn
Date: Wed, 25 Nov 2026 16:57
Date: Wed, 25 Nov 2026 16:57
42 lines
9940 bytes
9940 bytes
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
Re: [PATCH net] net: tn40xx: terminate the PHY software node property array
Author: FUJITA Tomonori
Date: Wed, 25 Nov 2026 22:21
Date: Wed, 25 Nov 2026 22:21
29 lines
13911 bytes
13911 bytes
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!
Re: [PATCH net] net: tn40xx: terminate the PHY software node property array
Author: patchwork-bot+netdevbpf
Date: Mon, 30 Nov 2026 03:50
Date: Mon, 30 Nov 2026 03:50
24 lines
8578 bytes
8578 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads