Commit d3043509 authored by Masahiro Yamada's avatar Masahiro Yamada Committed by Wenyu Huang
Browse files

net: mdio: unexport __init-annotated mdio_bus_init()

stable inclusion
from stable-v4.19.247
commit 5534bcd7c40299862237c4a8fd9c5031b3db1538
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBPK8Q
CVE: CVE-2022-49350

Reference: https://web.git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=5534bcd7c40299862237c4a8fd9c5031b3db1538



--------------------------------

[ Upstream commit 35b42dce ]

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)

Fixes: 90eff909 ("net: phy: Allow splitting MDIO bus/device support from PHYs")
Reported-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Reviewed-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarWenyu Huang <huangwenyu5@huawei.com>
parent 72481518
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -745,7 +745,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)