Commit b963ea89f00f13c648af4082e5efb2172d369727

Authored by David S. Miller
1 parent 628e300ccc

netlink: Make NETLINK_USERSOCK work again.

Once we started enforcing the a nl_table[] entry exist for
a protocol, NETLINK_USERSOCK stopped working.  Add a dummy
table entry so that it works again.

Reported-by: Thomas Voegtle <tv@lio96.de>
Tested-by: Thomas Voegtle <tv@lio96.de>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 1 changed file with 22 additions and 0 deletions Side-by-side Diff

net/netlink/af_netlink.c
... ... @@ -2102,6 +2102,26 @@
2102 2102 #endif
2103 2103 }
2104 2104  
  2105 +static void __init netlink_add_usersock_entry(void)
  2106 +{
  2107 + unsigned long *listeners;
  2108 + int groups = 32;
  2109 +
  2110 + listeners = kzalloc(NLGRPSZ(groups) + sizeof(struct listeners_rcu_head),
  2111 + GFP_KERNEL);
  2112 + if (!listeners)
  2113 + panic("netlink_add_usersock_entry: Cannot allocate listneres\n");
  2114 +
  2115 + netlink_table_grab();
  2116 +
  2117 + nl_table[NETLINK_USERSOCK].groups = groups;
  2118 + nl_table[NETLINK_USERSOCK].listeners = listeners;
  2119 + nl_table[NETLINK_USERSOCK].module = THIS_MODULE;
  2120 + nl_table[NETLINK_USERSOCK].registered = 1;
  2121 +
  2122 + netlink_table_ungrab();
  2123 +}
  2124 +
2105 2125 static struct pernet_operations __net_initdata netlink_net_ops = {
2106 2126 .init = netlink_net_init,
2107 2127 .exit = netlink_net_exit,
... ... @@ -2149,6 +2169,8 @@
2149 2169 hash->mask = 0;
2150 2170 hash->rehash_time = jiffies;
2151 2171 }
  2172 +
  2173 + netlink_add_usersock_entry();
2152 2174  
2153 2175 sock_register(&netlink_family_ops);
2154 2176 register_pernet_subsys(&netlink_net_ops);