net: pse-pd: Fix possible issues with a PSE supporting both c33 and PoDL
Subsystems (4)
Kory Maincent
maintainerv3 cover net: pse-pd: Fix possible issues with a PSE supporting both c33 and PoDL
Although PSE controllers supporting both c33 and PoDL are not on the market yet, we want to prevent potential issues from arising in the future. Two possible issues could occur with a PSE supporting both c33 and PoDL:
- Setting the config for one type of PSE leaves the other type's config null. In this case, the PSE core would return EOPNOTSUPP, which is not the correct behavior.
- Null dereference of Netlink attributes as only one of the Netlink attributes would be specified at a time.
This patch series contains two patches to fix these issues.
Changes in v3:
- Add a cover letter and the net prefix
Changes in v2:
- Add a patch to deal with null config
---
Kory Maincent (2):
net: pse-pd: Do not return EOPNOSUPP if config is null
net: ethtool: pse-pd: Fix possible null-deref
drivers/net/pse-pd/pse_core.c | 4 ++-- net/ethtool/pse-pd.c | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-)
---
base-commit: d7c199e77ef2fe259ad5b1beca5ddd6c951fcba2
change-id: 20240711-fix_pse_pd_deref-6a7d0de068a4
Best regards,
Signature · 3 lines
Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com
Kory Maincent
maintainerPATCH v3 1/2 net: pse-pd: Do not return EOPNOSUPP if config is null
For a PSE supporting both c33 and PoDL, setting config for one type of PoE leaves the other type's config null. Currently, this case returns EOPNOTSUPP, which is incorrect. Instead, we should do nothing if the configuration is empty.
---
Changes in v2:
- New patch to fix dealing with a null config.
--- drivers/net/pse-pd/pse_core.c | 4 ++-- net/ethtool/pse-pd.c | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/net/pse-pd/pse_core.c +2 -2
@@ -719,13 +719,13 @@ int pse_ethtool_set_config(struct pse_control *psec, {int err =0 ; -if (pse_has_c33 (psec)) { +if (pse_has_c33 (psec) && config->c33_admin_control) { err =pse_ethtool_c33_set_config (psec, config);if (err)return err; } -if (pse_has_podl (psec)) +if (pse_has_podl (psec) && config->podl_admin_control) err =pse_ethtool_podl_set_config (psec, config);return err;
net/ethtool/pse-pd.c +3 -1
@@ -183,7 +183,9 @@ ethnl_set_pse(struct ethnl_req_info *req_info, struct genl_info *info)if (pse_has_c33 (phydev->psec)) config.c33_admin_control =nla_get_u32 (tb[ETHTOOL_A_C33_PSE_ADMIN_CONTROL ]); -/* Return errno directly - PSE has no notification */ +/* Return errno directly - PSE has no notification +* pse_ethtool_set_config() will do nothing if the config is null +*/ return pse_ethtool_set_config (phydev->psec, info->extack, &config); }
Signature · 1 line
2.34.1
Kory Maincent
maintainerPATCH v3 2/2 net: ethtool: pse-pd: Fix possible null-deref
In reply to Kory MaincentFix a possible null dereference when a PSE supports both c33 and PoDL, but only one of the netlink attributes is specified. The c33 or PoDL PSE capabilities are already validated in the ethnl_set_pse_validate() call.
--- net/ethtool/pse-pd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/ethtool/pse-pd.c +2 -2
@@ -178,9 +178,9 @@ ethnl_set_pse(struct ethnl_req_info *req_info, struct genl_info *info) phydev = dev->phydev;/* These values are already validated by the ethnl_pse_set_policy */ -if (pse_has_podl (phydev->psec)) +if (tb[ETHTOOL_A_PODL_PSE_ADMIN_CONTROL ]) config.podl_admin_control =nla_get_u32 (tb[ETHTOOL_A_PODL_PSE_ADMIN_CONTROL ]); -if (pse_has_c33 (phydev->psec)) +if (tb[ETHTOOL_A_C33_PSE_ADMIN_CONTROL ]) config.c33_admin_control =nla_get_u32 (tb[ETHTOOL_A_C33_PSE_ADMIN_CONTROL ]);/* Return errno directly - PSE has no notification
Signature · 1 line
2.34.1
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 5 lines · On Thu, 11 Jul 2024 15:55:17 +0200 you wrote:
Although PSE controllers supporting both c33 and PoDL are not on the market yet, we want to prevent potential issues from arising in the future. Two possible issues could occur with a PSE supporting both c33 and PoDL:
Quoted 7 lines
- Setting the config for one type of PSE leaves the other type's config null. In this case, the PSE core would return EOPNOTSUPP, which is not the correct behavior.
- Null dereference of Netlink attributes as only one of the Netlink attributes would be specified at a time.[...]
Here is the summary with links:
- [net,v3,1/2] net: pse-pd: Do not return EOPNOSUPP if config is null
https://git.kernel.org/netdev/net/c/93c3a96c301f - [net,v3,2/2] net: ethtool: pse-pd: Fix possible null-deref https://git.kernel.org/netdev/net/c/4cddb0f15ea9
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html