aboutsummaryrefslogtreecommitdiffstats
path: root/net/wimax
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2013-11-19 09:19:39 -0500
committerDavid S. Miller <davem@davemloft.net>2013-11-19 16:39:06 -0500
commit2a94fe48f32ccf7321450a2cc07f2b724a444e5b (patch)
treee5a066d8f83d8822d448421019a4503f361295f9 /net/wimax
parent68eb55031da7c967d954e5f9415cd05f4abdb692 (diff)
genetlink: make multicast groups const, prevent abuse
Register generic netlink multicast groups as an array with the family and give them contiguous group IDs. Then instead of passing the global group ID to the various functions that send messages, pass the ID relative to the family - for most families that's just 0 because the only have one group. This avoids the list_head and ID in each group, adding a new field for the mcast group ID offset to the family. At the same time, this allows us to prevent abusing groups again like the quota and dropmon code did, since we can now check that a family only uses a group it owns. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/wimax')
-rw-r--r--net/wimax/op-msg.c3
-rw-r--r--net/wimax/stack.c21
-rw-r--r--net/wimax/wimax-internal.h1
3 files changed, 10 insertions, 15 deletions
diff --git a/net/wimax/op-msg.c b/net/wimax/op-msg.c
index f37dd3c5576d..c278b3356f75 100644
--- a/net/wimax/op-msg.c
+++ b/net/wimax/op-msg.c
@@ -279,8 +279,7 @@ int wimax_msg_send(struct wimax_dev *wimax_dev, struct sk_buff *skb)
279 279
280 d_printf(1, dev, "CTX: wimax msg, %zu bytes\n", size); 280 d_printf(1, dev, "CTX: wimax msg, %zu bytes\n", size);
281 d_dump(2, dev, msg, size); 281 d_dump(2, dev, msg, size);
282 genlmsg_multicast(&wimax_gnl_family, skb, 0, 282 genlmsg_multicast(&wimax_gnl_family, skb, 0, 0, GFP_KERNEL);
283 wimax_gnl_mcg.id, GFP_KERNEL);
284 d_printf(1, dev, "CTX: genl multicast done\n"); 283 d_printf(1, dev, "CTX: genl multicast done\n");
285 return 0; 284 return 0;
286} 285}
diff --git a/net/wimax/stack.c b/net/wimax/stack.c
index 18888748e699..ef2191b969a7 100644
--- a/net/wimax/stack.c
+++ b/net/wimax/stack.c
@@ -116,8 +116,9 @@ struct sk_buff *wimax_gnl_re_state_change_alloc(
116 dev_err(dev, "RE_STCH: can't create message\n"); 116 dev_err(dev, "RE_STCH: can't create message\n");
117 goto error_new; 117 goto error_new;
118 } 118 }
119 data = genlmsg_put(report_skb, 0, wimax_gnl_mcg.id, &wimax_gnl_family, 119 /* FIXME: sending a group ID as the seq is wrong */
120 0, WIMAX_GNL_RE_STATE_CHANGE); 120 data = genlmsg_put(report_skb, 0, wimax_gnl_family.mcgrp_offset,
121 &wimax_gnl_family, 0, WIMAX_GNL_RE_STATE_CHANGE);
121 if (data == NULL) { 122 if (data == NULL) {
122 dev_err(dev, "RE_STCH: can't put data into message\n"); 123 dev_err(dev, "RE_STCH: can't put data into message\n");
123 goto error_put; 124 goto error_put;
@@ -177,8 +178,7 @@ int wimax_gnl_re_state_change_send(
177 goto out; 178 goto out;
178 } 179 }
179 genlmsg_end(report_skb, header); 180 genlmsg_end(report_skb, header);
180 genlmsg_multicast(&wimax_gnl_family, report_skb, 0, 181 genlmsg_multicast(&wimax_gnl_family, report_skb, 0, 0, GFP_KERNEL);
181 wimax_gnl_mcg.id, GFP_KERNEL);
182out: 182out:
183 d_fnend(3, dev, "(wimax_dev %p report_skb %p) = %d\n", 183 d_fnend(3, dev, "(wimax_dev %p report_skb %p) = %d\n",
184 wimax_dev, report_skb, result); 184 wimax_dev, report_skb, result);
@@ -580,8 +580,8 @@ struct genl_family wimax_gnl_family = {
580 .maxattr = WIMAX_GNL_ATTR_MAX, 580 .maxattr = WIMAX_GNL_ATTR_MAX,
581}; 581};
582 582
583struct genl_multicast_group wimax_gnl_mcg = { 583static const struct genl_multicast_group wimax_gnl_mcgrps[] = {
584 .name = "msg", 584 { .name = "msg", },
585}; 585};
586 586
587 587
@@ -598,21 +598,18 @@ int __init wimax_subsys_init(void)
598 598
599 snprintf(wimax_gnl_family.name, sizeof(wimax_gnl_family.name), 599 snprintf(wimax_gnl_family.name, sizeof(wimax_gnl_family.name),
600 "WiMAX"); 600 "WiMAX");
601 result = genl_register_family_with_ops(&wimax_gnl_family, 601 result = genl_register_family_with_ops_groups(&wimax_gnl_family,
602 wimax_gnl_ops); 602 wimax_gnl_ops,
603 wimax_gnl_mcgrps);
603 if (unlikely(result < 0)) { 604 if (unlikely(result < 0)) {
604 printk(KERN_ERR "cannot register generic netlink family: %d\n", 605 printk(KERN_ERR "cannot register generic netlink family: %d\n",
605 result); 606 result);
606 goto error_register_family; 607 goto error_register_family;
607 } 608 }
608 609
609 result = genl_register_mc_group(&wimax_gnl_family, &wimax_gnl_mcg);
610 if (result < 0)
611 goto error_mc_group;
612 d_fnend(4, NULL, "() = 0\n"); 610 d_fnend(4, NULL, "() = 0\n");
613 return 0; 611 return 0;
614 612
615error_mc_group:
616 genl_unregister_family(&wimax_gnl_family); 613 genl_unregister_family(&wimax_gnl_family);
617error_register_family: 614error_register_family:
618 d_fnend(4, NULL, "() = %d\n", result); 615 d_fnend(4, NULL, "() = %d\n", result);
diff --git a/net/wimax/wimax-internal.h b/net/wimax/wimax-internal.h
index 8567d3079a83..b445b82020a8 100644
--- a/net/wimax/wimax-internal.h
+++ b/net/wimax/wimax-internal.h
@@ -86,7 +86,6 @@ void wimax_rfkill_rm(struct wimax_dev *);
86 86
87/* generic netlink */ 87/* generic netlink */
88extern struct genl_family wimax_gnl_family; 88extern struct genl_family wimax_gnl_family;
89extern struct genl_multicast_group wimax_gnl_mcg;
90 89
91/* ops */ 90/* ops */
92int wimax_gnl_doit_msg_from_user(struct sk_buff *skb, struct genl_info *info); 91int wimax_gnl_doit_msg_from_user(struct sk_buff *skb, struct genl_info *info);