Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tun: Fix unicast filter overflow

Tap devices can make use of a small MAC filter set via the
TUNSETTXFILTER ioctl. The filter has a set of exact matches
plus a hash for imperfect filtering of additional multicast
addresses. The current code is unbalanced, adding unicast
addresses to the multicast hash, but only checking the hash
against multicast addresses. This results in the filter
dropping unicast addresses that overflow the exact filter.
The fix is simply to disable the filter by leaving count set
to zero if we find non-multicast addresses after the exact
match table is filled.

Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Alex Williamson and committed by
David S. Miller
cfbf84fc 23b904f3

+8 -2
+8 -2
drivers/net/tun.c
··· 157 157 158 158 nexact = n; 159 159 160 - /* The rest is hashed */ 160 + /* Remaining multicast addresses are hashed, 161 + * unicast will leave the filter disabled. */ 161 162 memset(filter->mask, 0, sizeof(filter->mask)); 162 - for (; n < uf.count; n++) 163 + for (; n < uf.count; n++) { 164 + if (!is_multicast_ether_addr(addr[n].u)) { 165 + err = 0; /* no filter */ 166 + goto done; 167 + } 163 168 addr_hash_set(filter->mask, addr[n].u); 169 + } 164 170 165 171 /* For ALLMULTI just set the mask to all ones. 166 172 * This overrides the mask populated above. */