* [PATCH] tun: Fix unicast filter overflow
@ 2009-02-07 17:45 Alex Williamson
2009-02-09 1:06 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Alex Williamson @ 2009-02-07 17:45 UTC (permalink / raw)
To: maxk; +Cc: linux-kernel, netdev, alex.williamson
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>
---
Proposed for 2.6.29 and stable.
drivers/net/tun.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index d7b81e4..09fea31 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -157,10 +157,16 @@ static int update_filter(struct tap_filter *filter, void __user *arg)
nexact = n;
- /* The rest is hashed */
+ /* Remaining multicast addresses are hashed,
+ * unicast will leave the filter disabled. */
memset(filter->mask, 0, sizeof(filter->mask));
- for (; n < uf.count; n++)
+ for (; n < uf.count; n++) {
+ if (!is_multicast_ether_addr(addr[n].u)) {
+ err = 0; /* no filter */
+ goto done;
+ }
addr_hash_set(filter->mask, addr[n].u);
+ }
/* For ALLMULTI just set the mask to all ones.
* This overrides the mask populated above. */
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] tun: Fix unicast filter overflow
2009-02-07 17:45 [PATCH] tun: Fix unicast filter overflow Alex Williamson
@ 2009-02-09 1:06 ` David Miller
2009-02-09 1:43 ` Alex Williamson
0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2009-02-09 1:06 UTC (permalink / raw)
To: alex.williamson; +Cc: maxk, linux-kernel, netdev
From: Alex Williamson <alex.williamson@hp.com>
Date: Sat, 07 Feb 2009 10:45:13 -0700
> 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>
Doesn't it make more sense to remove the multicast check
in the filter check function?
With your change, the user gets absolutely no indication
that filtering has been completely disabled simply because
they put too many unicast addresses into the filter. We
just return zero, that's crazy.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tun: Fix unicast filter overflow
2009-02-09 1:06 ` David Miller
@ 2009-02-09 1:43 ` Alex Williamson
2009-02-09 1:48 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Alex Williamson @ 2009-02-09 1:43 UTC (permalink / raw)
To: David Miller; +Cc: maxk, linux-kernel, netdev
On Sun, 2009-02-08 at 17:06 -0800, David Miller wrote:
> From: Alex Williamson <alex.williamson@hp.com>
> Date: Sat, 07 Feb 2009 10:45:13 -0700
>
> > 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>
>
> Doesn't it make more sense to remove the multicast check
> in the filter check function?
>
> With your change, the user gets absolutely no indication
> that filtering has been completely disabled simply because
> they put too many unicast addresses into the filter. We
> just return zero, that's crazy.
Sure, that's another option, but we'd then need to figure out what to do
with TUN_FLT_ALLMULTI. Unicast would almost needs it's own hash list if
we want to support an allmulti mode that's less than promiscuous. The
return value of the ioctl is the number of exact filters, so the user
will know what happened. Thanks,
Alex
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tun: Fix unicast filter overflow
2009-02-09 1:43 ` Alex Williamson
@ 2009-02-09 1:48 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2009-02-09 1:48 UTC (permalink / raw)
To: alex.williamson; +Cc: maxk, linux-kernel, netdev
From: Alex Williamson <alex.williamson@hp.com>
Date: Sun, 08 Feb 2009 18:43:57 -0700
> Sure, that's another option, but we'd then need to figure out what to do
> with TUN_FLT_ALLMULTI. Unicast would almost needs it's own hash list if
> we want to support an allmulti mode that's less than promiscuous. The
> return value of the ioctl is the number of exact filters, so the user
> will know what happened.
Oh so that's what the return value means.
Ok, I guess for now your patch is fine, I'll apply it and
queue it up for -stable, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-02-09 1:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-07 17:45 [PATCH] tun: Fix unicast filter overflow Alex Williamson
2009-02-09 1:06 ` David Miller
2009-02-09 1:43 ` Alex Williamson
2009-02-09 1:48 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).