diff options
author | Thomas Graf <tgraf@suug.ch> | 2007-07-24 18:32:46 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-07-24 18:32:46 -0400 |
commit | 79dc4386aec655ad829f320ab90888bacbc7037b (patch) | |
tree | 82340d9c2be1c96e3e894a4fa29132e4234e74a1 /net/netlink/genetlink.c | |
parent | 85ccc365e91de9f0053c94de4cbc6ce97f8170e7 (diff) |
[GENETLINK]: Fix race in genl_unregister_mc_groups()
family->mcast_groups is protected by genl_lock so it must
be held while accessing the list in genl_unregister_mc_groups().
Requires adding a non-locking variant of genl_unregister_mc_group().
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netlink/genetlink.c')
-rw-r--r-- | net/netlink/genetlink.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c index e146531faf1d..61d65569e2be 100644 --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c | |||
@@ -200,6 +200,18 @@ int genl_register_mc_group(struct genl_family *family, | |||
200 | } | 200 | } |
201 | EXPORT_SYMBOL(genl_register_mc_group); | 201 | EXPORT_SYMBOL(genl_register_mc_group); |
202 | 202 | ||
203 | static void __genl_unregister_mc_group(struct genl_family *family, | ||
204 | struct genl_multicast_group *grp) | ||
205 | { | ||
206 | BUG_ON(grp->family != family); | ||
207 | netlink_clear_multicast_users(genl_sock, grp->id); | ||
208 | clear_bit(grp->id, mc_groups); | ||
209 | list_del(&grp->list); | ||
210 | genl_ctrl_event(CTRL_CMD_DELMCAST_GRP, grp); | ||
211 | grp->id = 0; | ||
212 | grp->family = NULL; | ||
213 | } | ||
214 | |||
203 | /** | 215 | /** |
204 | * genl_unregister_mc_group - unregister a multicast group | 216 | * genl_unregister_mc_group - unregister a multicast group |
205 | * | 217 | * |
@@ -217,14 +229,8 @@ EXPORT_SYMBOL(genl_register_mc_group); | |||
217 | void genl_unregister_mc_group(struct genl_family *family, | 229 | void genl_unregister_mc_group(struct genl_family *family, |
218 | struct genl_multicast_group *grp) | 230 | struct genl_multicast_group *grp) |
219 | { | 231 | { |
220 | BUG_ON(grp->family != family); | ||
221 | genl_lock(); | 232 | genl_lock(); |
222 | netlink_clear_multicast_users(genl_sock, grp->id); | 233 | __genl_unregister_mc_group(family, grp); |
223 | clear_bit(grp->id, mc_groups); | ||
224 | list_del(&grp->list); | ||
225 | genl_ctrl_event(CTRL_CMD_DELMCAST_GRP, grp); | ||
226 | grp->id = 0; | ||
227 | grp->family = NULL; | ||
228 | genl_unlock(); | 234 | genl_unlock(); |
229 | } | 235 | } |
230 | 236 | ||
@@ -232,8 +238,10 @@ static void genl_unregister_mc_groups(struct genl_family *family) | |||
232 | { | 238 | { |
233 | struct genl_multicast_group *grp, *tmp; | 239 | struct genl_multicast_group *grp, *tmp; |
234 | 240 | ||
241 | genl_lock(); | ||
235 | list_for_each_entry_safe(grp, tmp, &family->mcast_groups, list) | 242 | list_for_each_entry_safe(grp, tmp, &family->mcast_groups, list) |
236 | genl_unregister_mc_group(family, grp); | 243 | __genl_unregister_mc_group(family, grp); |
244 | genl_unlock(); | ||
237 | } | 245 | } |
238 | 246 | ||
239 | /** | 247 | /** |