diff options
Diffstat (limited to 'net/ipv4/ping.c')
| -rw-r--r-- | net/ipv4/ping.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c index f4b19e5dde54..8210964a9f19 100644 --- a/net/ipv4/ping.c +++ b/net/ipv4/ping.c | |||
| @@ -252,26 +252,33 @@ int ping_init_sock(struct sock *sk) | |||
| 252 | { | 252 | { |
| 253 | struct net *net = sock_net(sk); | 253 | struct net *net = sock_net(sk); |
| 254 | kgid_t group = current_egid(); | 254 | kgid_t group = current_egid(); |
| 255 | struct group_info *group_info = get_current_groups(); | 255 | struct group_info *group_info; |
| 256 | int i, j, count = group_info->ngroups; | 256 | int i, j, count; |
| 257 | kgid_t low, high; | 257 | kgid_t low, high; |
| 258 | int ret = 0; | ||
| 258 | 259 | ||
| 259 | inet_get_ping_group_range_net(net, &low, &high); | 260 | inet_get_ping_group_range_net(net, &low, &high); |
| 260 | if (gid_lte(low, group) && gid_lte(group, high)) | 261 | if (gid_lte(low, group) && gid_lte(group, high)) |
| 261 | return 0; | 262 | return 0; |
| 262 | 263 | ||
| 264 | group_info = get_current_groups(); | ||
| 265 | count = group_info->ngroups; | ||
| 263 | for (i = 0; i < group_info->nblocks; i++) { | 266 | for (i = 0; i < group_info->nblocks; i++) { |
| 264 | int cp_count = min_t(int, NGROUPS_PER_BLOCK, count); | 267 | int cp_count = min_t(int, NGROUPS_PER_BLOCK, count); |
| 265 | for (j = 0; j < cp_count; j++) { | 268 | for (j = 0; j < cp_count; j++) { |
| 266 | kgid_t gid = group_info->blocks[i][j]; | 269 | kgid_t gid = group_info->blocks[i][j]; |
| 267 | if (gid_lte(low, gid) && gid_lte(gid, high)) | 270 | if (gid_lte(low, gid) && gid_lte(gid, high)) |
| 268 | return 0; | 271 | goto out_release_group; |
| 269 | } | 272 | } |
| 270 | 273 | ||
| 271 | count -= cp_count; | 274 | count -= cp_count; |
| 272 | } | 275 | } |
| 273 | 276 | ||
| 274 | return -EACCES; | 277 | ret = -EACCES; |
| 278 | |||
| 279 | out_release_group: | ||
| 280 | put_group_info(group_info); | ||
| 281 | return ret; | ||
| 275 | } | 282 | } |
| 276 | EXPORT_SYMBOL_GPL(ping_init_sock); | 283 | EXPORT_SYMBOL_GPL(ping_init_sock); |
| 277 | 284 | ||
