net: unexport some symbols that are annotated __init
Subsystems (5)
cover net: unexport some symbols that are annotated __init
This patch set fixes odd combinations
of EXPORT_SYMBOL and __init.
Checking this in modpost is a good thing and I really wanted to do it, but Linus Torvalds imposes a very strict rule, "No new warning".
I'd like the maintainer to kindly pick this up and send a fixes pull request.
Unless I eliminate all the sites of warnings beforehand, Linus refuses to re-enable the modpost check. [1]
Masahiro Yamada (3):
net: mdio: unexport __init-annotated mdio_bus_init()
net: xfrm: unexport __init-annotated xfrm4_protocol_init()
net: ipv6: unexport __init-annotated seg6_hmac_init()
drivers/net/phy/mdio_bus.c | 1 - net/ipv4/xfrm4_protocol.c | 1 - net/ipv6/seg6_hmac.c | 1 - 3 files changed, 3 deletions(-)
Signature · 1 line
2.32.0
PATCH 1/3 net: mdio: unexport __init-annotated mdio_bus_init()
EXPORT_SYMBOL and __init is a bad combination because the .init.text section is freed up after the initialization. Hence, modules cannot use symbols annotated __init. The access to a freed symbol may end up with kernel panic.
modpost used to detect it, but it has been broken for a decade.
Recently, I fixed modpost so it started to warn it again, then this showed up in linux-next builds.
There are two ways to fix it:
- Remove __init
- Remove EXPORT_SYMBOL
I chose the latter for this case because the only in-tree call-site, drivers/net/phy/phy_device.c is never compiled as modular. (CONFIG_PHYLIB is boolean)
---
drivers/net/phy/mdio_bus.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/phy/mdio_bus.c +0 -1
@@ -1046,7 +1046,6 @@ int __init mdio_bus_init(void)return ret; } -EXPORT_SYMBOL_GPL (mdio_bus_init);#if IS_ENABLED (CONFIG_PHYLIB )void mdio_bus_exit (void )
Signature · 1 line
2.32.0
Re: [PATCH 1/3] net: mdio: unexport __init-annotated mdio_bus_init()
Quoted 15 lines · Masahiro Yamada
EXPORT_SYMBOLand__initis a bad combination because the .init.text section is freed up after the initialization. Hence, modules cannot use symbols annotated__init. The access to a freed symbol may end up with kernel panic.modpost used to detect it, but it has been broken for a decade.
Recently, I fixed modpost so it started to warn it again, then this showed up in linux-next builds.
There are two ways to fix it:
- Remove
__init
- RemoveEXPORT_SYMBOL
Quoted 7 lines
I chose the latter for this case because the only in-tree call-site,
drivers/net/phy/phy_device.cis never compiled as modular. (CONFIG_PHYLIBis boolean)Fixes 90eff9096c01 ("net: phy: Allow splitting MDIO bus/device support from PHYs")Reported-by Stephen Rothwell <[email protected]>Signed-off-by Masahiro Yamada <[email protected]>
Signature · 1 line
Florian
Re: [PATCH 1/3] net: mdio: unexport __init-annotated mdio_bus_init()
In reply to Masahiro YamadaQuoted 15 lines · Masahiro Yamada
EXPORT_SYMBOLand__initis a bad combination because the .init.text section is freed up after the initialization. Hence, modules cannot use symbols annotated__init. The access to a freed symbol may end up with kernel panic.modpost used to detect it, but it has been broken for a decade.
Recently, I fixed modpost so it started to warn it again, then this showed up in linux-next builds.
There are two ways to fix it:
- Remove
__init
- RemoveEXPORT_SYMBOL
Quoted 7 lines
I chose the latter for this case because the only in-tree call-site,
drivers/net/phy/phy_device.cis never compiled as modular. (CONFIG_PHYLIBis boolean)Fixes 90eff9096c01 ("net: phy: Allow splitting MDIO bus/device support from PHYs")Reported-by Stephen Rothwell <[email protected]>Signed-off-by Masahiro Yamada <[email protected]>
Thanks!
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
PATCH 2/3 net: xfrm: unexport __init-annotated xfrm4_protocol_init()
In reply to Masahiro YamadaEXPORT_SYMBOL and __init is a bad combination because the .init.text section is freed up after the initialization. Hence, modules cannot use symbols annotated __init. The access to a freed symbol may end up with kernel panic.
modpost used to detect it, but it has been broken for a decade.
Recently, I fixed modpost so it started to warn it again, then this showed up in linux-next builds.
There are two ways to fix it:
- Remove __init
- Remove EXPORT_SYMBOL
I chose the latter for this case because the only in-tree call-site, net/ipv4/xfrm4_policy.c is never compiled as modular. (CONFIG_XFRM is boolean)
---
net/ipv4/xfrm4_protocol.c | 1 - 1 file changed, 1 deletion(-)
net/ipv4/xfrm4_protocol.c +0 -1
@@ -304,4 +304,3 @@ void __init xfrm4_protocol_init(void) {xfrm_input_register_afinfo (&xfrm4_input_afinfo); } -EXPORT_SYMBOL (xfrm4_protocol_init);
Signature · 1 line
2.32.0
Paolo Abeni
maintainerRe: [PATCH 2/3] net: xfrm: unexport __init-annotated xfrm4_protocol_init()
Quoted 15 lines · Masahiro Yamada
EXPORT_SYMBOLand__initis a bad combination because the .init.text section is freed up after the initialization. Hence, modules cannot use symbols annotated__init. The access to a freed symbol may end up with kernel panic.modpost used to detect it, but it has been broken for a decade.
Recently, I fixed modpost so it started to warn it again, then this showed up in linux-next builds.
There are two ways to fix it:
- Remove
__init
- RemoveEXPORT_SYMBOL
Quoted 7 lines
I chose the latter for this case because the only in-tree call-site,
net/ipv4/xfrm4_policy.cis never compiled as modular. (CONFIG_XFRMis boolean)Fixes 2f32b51b609f ("xfrm: Introduce xfrm_input_afinfo to access the the callbacks properly")Reported-by Stephen Rothwell <[email protected]>Signed-off-by Masahiro Yamada <[email protected]>
@Steffen: are you ok if we take this one in the -net tree directly? Otherwise a repost would probably be the better option, with this patch stand-alone targeting the ipsec tree and the other 2 targeting -net.
Thanks!
Paolo
Re: [PATCH 2/3] net: xfrm: unexport __init-annotated xfrm4_protocol_init()
Quoted 20 lines · Paolo Abeni
Quoted 19 lines · Masahiro Yamada
EXPORT_SYMBOLand__initis a bad combination because the .init.text section is freed up after the initialization. Hence, modules cannot use symbols annotated__init. The access to a freed symbol may end up with kernel panic.modpost used to detect it, but it has been broken for a decade.
Recently, I fixed modpost so it started to warn it again, then this showed up in linux-next builds.
There are two ways to fix it:
- Remove
__init
- RemoveEXPORT_SYMBOLI chose the latter for this case because the only in-tree call-site,
net/ipv4/xfrm4_policy.cis never compiled as modular. (CONFIG_XFRMis boolean)
Quoted 7 lines
Quoted 3 lines
Fixes 2f32b51b609f ("xfrm: Introduce xfrm_input_afinfo to access the the callbacks properly")Reported-by Stephen Rothwell <[email protected]>Signed-off-by Masahiro Yamada <[email protected]>@Steffen: are you ok if we take this one in the -net tree directly? Otherwise a repost would probably be the better option, with this patch stand-alone targeting the ipsec tree and the other 2 targeting -net.
Yes, just take it.
Thanks!
PATCH 3/3 net: ipv6: unexport __init-annotated seg6_hmac_init()
In reply to Masahiro YamadaEXPORT_SYMBOL and __init is a bad combination because the .init.text section is freed up after the initialization. Hence, modules cannot use symbols annotated __init. The access to a freed symbol may end up with kernel panic.
modpost used to detect it, but it has been broken for a decade.
Recently, I fixed modpost so it started to warn it again, then this showed up in linux-next builds.
There are two ways to fix it:
- Remove __init
- Remove EXPORT_SYMBOL
I chose the latter for this case because the caller (net/ipv6/seg6.c) and the callee (net/ipv6/seg6_hmac.c) belong to the same module. It seems an internal function call in ipv6.ko.
---
net/ipv6/seg6_hmac.c | 1 - 1 file changed, 1 deletion(-)
net/ipv6/seg6_hmac.c +0 -1
@@ -399,7 +399,6 @@ int __init seg6_hmac_init(void) {return seg6_hmac_init_algo (); } -EXPORT_SYMBOL (seg6_hmac_init);int __net_init seg6_hmac_net_init (struct net *net) {
Signature · 1 line
2.32.0
This series was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Mon, 6 Jun 2022 13:53:52 +0900 you wrote:
This patch set fixes odd combinations
ofEXPORT_SYMBOLand__init.Checking this in modpost is a good thing and I really wanted to do it, but Linus Torvalds imposes a very strict rule, "No new warning".
I'd like the maintainer to kindly pick this up and send a fixes pull request.
[...]
Here is the summary with links:
- [1/3] net: mdio: unexport __init-annotated mdio_bus_init()
https://git.kernel.org/netdev/net/c/35b42dce6197 - [2/3] net: xfrm: unexport __init-annotated xfrm4_protocol_init() https://git.kernel.org/netdev/net/c/4a388f08d878 - [3/3] net: ipv6: unexport __init-annotated seg6_hmac_init() https://git.kernel.org/netdev/net/c/5801f064e351
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html