Skip to content

Commit ccdf6ce

Browse files
Matti Vaittinendavem330
authored andcommitted
net: netlink: Fix multicast group storage allocation for families with more than one groups
Multicast groups are stored in global buffer. Check for needed buffer size incorrectly compares buffer size to first id for family. This means that for families with more than one mcast id one may allocate too small buffer and end up writing rest of the groups to some unallocated memory. Fix the buffer size check to compare allocated space to last mcast id for the family. Tested on ARM using kernel 3.14 Signed-off-by: Matti Vaittinen <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 06928b3 commit ccdf6ce

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/netlink/genetlink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ static int genl_allocate_reserve_groups(int n_groups, int *first_id)
185185
}
186186
}
187187

188-
if (id >= mc_groups_longs * BITS_PER_LONG) {
188+
if (id + n_groups >= mc_groups_longs * BITS_PER_LONG) {
189189
unsigned long new_longs = mc_groups_longs +
190190
BITS_TO_LONGS(n_groups);
191191
size_t nlen = new_longs * sizeof(unsigned long);

0 commit comments

Comments
 (0)