aboutsummaryrefslogtreecommitdiffstats
path: root/net/netlink
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2013-11-19 09:19:33 -0500
committerDavid S. Miller <davem@davemloft.net>2013-11-19 16:39:05 -0500
commit2ecf7536b2787580616d23b6507005d930975ca0 (patch)
tree050b07aaf96d86a83ed42c34511a3f28e1c0d1d4 /net/netlink
parente5dcecba015f9774a402ba559b80b16999747e3b (diff)
quota/genetlink: use proper genetlink multicast APIs
The quota code is abusing the genetlink API and is using its family ID as the multicast group ID, which is invalid and may belong to somebody else (and likely will.) Make the quota code use the correct API, but since this is already used as-is by userspace, reserve a family ID for this code and also reserve that group ID to not break userspace assumptions. Acked-by: Jan Kara <jack@suse.cz> Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netlink')
-rw-r--r--net/netlink/genetlink.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index 353909d46dda..bee91a7527a5 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -69,8 +69,11 @@ static struct list_head family_ht[GENL_FAM_TAB_SIZE];
69 * abuses the API and thinks it can statically use group 1. 69 * abuses the API and thinks it can statically use group 1.
70 * That group will typically conflict with other groups that 70 * That group will typically conflict with other groups that
71 * any proper users use. 71 * any proper users use.
72 * Bit 17 is marked as already used since the VFS quota code
73 * also abused this API and relied on family == group ID, we
74 * cater to that by giving it a static family and group ID.
72 */ 75 */
73static unsigned long mc_group_start = 0x3; 76static unsigned long mc_group_start = 0x3 | BIT(GENL_ID_VFS_DQUOT);
74static unsigned long *mc_groups = &mc_group_start; 77static unsigned long *mc_groups = &mc_group_start;
75static unsigned long mc_groups_longs = 1; 78static unsigned long mc_groups_longs = 1;
76 79
@@ -130,7 +133,8 @@ static u16 genl_generate_id(void)
130 int i; 133 int i;
131 134
132 for (i = 0; i <= GENL_MAX_ID - GENL_MIN_ID; i++) { 135 for (i = 0; i <= GENL_MAX_ID - GENL_MIN_ID; i++) {
133 if (!genl_family_find_byid(id_gen_idx)) 136 if (id_gen_idx != GENL_ID_VFS_DQUOT &&
137 !genl_family_find_byid(id_gen_idx))
134 return id_gen_idx; 138 return id_gen_idx;
135 if (++id_gen_idx > GENL_MAX_ID) 139 if (++id_gen_idx > GENL_MAX_ID)
136 id_gen_idx = GENL_MIN_ID; 140 id_gen_idx = GENL_MIN_ID;
@@ -169,6 +173,8 @@ int genl_register_mc_group(struct genl_family *family,
169 id = GENL_ID_CTRL; 173 id = GENL_ID_CTRL;
170 else if (strcmp(family->name, "NET_DM") == 0) 174 else if (strcmp(family->name, "NET_DM") == 0)
171 id = 1; 175 id = 1;
176 else if (strcmp(family->name, "VFS_DQUOT") == 0)
177 id = GENL_ID_VFS_DQUOT;
172 else 178 else
173 id = find_first_zero_bit(mc_groups, 179 id = find_first_zero_bit(mc_groups,
174 mc_groups_longs * BITS_PER_LONG); 180 mc_groups_longs * BITS_PER_LONG);