Skip to contentSkip to conversation

ethtool: mark netlink policy as __ro_after_init

PATCH Superseded Jakub Kicinski 1 participant 2 messages Sep 29, 2020

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/1 ethtool: mark netlink policy as __ro_after_init

Like all genl families ethtool_genl_family needs to not be a straight up constant, because it's modified/initialized by genl_register_family(). After init, however, it's only passed to genlmsg_put() & co. therefore we can mark it as __ro_after_init.

Since genl_family structure contains function pointers mark this as a fix.

Fixes 2b4a8990b7df ("ethtool: introduce ethtool netlink interface")
---
 net/ethtool/netlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ethtool/netlink.c +1 -1
index 5c2072765be7..0c3f54baec4e 100644
@@ -866,7 +866,7 @@ static const struct genl_multicast_group ethtool_nl_mcgrps[] = {
 	[ETHNL_MCGRP_MONITOR] = { .name = ETHTOOL_MCGRP_MONITOR_NAME },
 };
 
-static struct genl_family ethtool_genl_family = {
+static struct genl_family ethtool_genl_family __ro_after_init = {
 	.name		= ETHTOOL_GENL_NAME,
 	.version	= ETHTOOL_GENL_VERSION,
 	.netnsok	= true,
Signature · 1 line
2.26.2
author maintainer
#1 lore raw
Quoted 5 lines · On Mon, 28 Sep 2020 17:57:18 -0700 Jakub Kicinski wrote:

Like all genl families ethtool_genl_family needs to not be a straight up constant, because it's modified/initialized by genl_register_family(). After init, however, it's only passed to genlmsg_put() & co. therefore we can mark it as __ro_after_init.

Sorry I just realized the subject is off.