* [PATCH net] bridge: mdb: zero out the local br_ip variable before use
@ 2015-07-07 13:55 Nikolay Aleksandrov
2015-07-08 23:11 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Nikolay Aleksandrov @ 2015-07-07 13:55 UTC (permalink / raw)
To: netdev; +Cc: bridge, stephen, davem, vyasevich, Nikolay Aleksandrov
Since commit b0e9a30dd669 ("bridge: Add vlan id to multicast groups")
there's a check in br_ip_equal() for a matching vlan id, but the mdb
functions were not modified to use (or at least zero it) so when an
entry was added it would have a garbage vlan id (from the local br_ip
variable in __br_mdb_add/del) and this would prevent it from being
matched and also deleted. So zero out the whole local ip var to protect
ourselves from future changes and also to fix the current bug, since
there's no vlan id support in the mdb uapi - use always vlan id 0.
Example before patch:
root@debian:~# bridge mdb add dev br0 port eth1 grp 239.0.0.1 permanent
root@debian:~# bridge mdb
dev br0 port eth1 grp 239.0.0.1 permanent
root@debian:~# bridge mdb del dev br0 port eth1 grp 239.0.0.1 permanent
RTNETLINK answers: Invalid argument
After patch:
root@debian:~# bridge mdb add dev br0 port eth1 grp 239.0.0.1 permanent
root@debian:~# bridge mdb
dev br0 port eth1 grp 239.0.0.1 permanent
root@debian:~# bridge mdb del dev br0 port eth1 grp 239.0.0.1 permanent
root@debian:~# bridge mdb
Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
Fixes: b0e9a30dd669 ("bridge: Add vlan id to multicast groups")
---
net/bridge/br_mdb.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c
index e29ad70b3000..cc00066c0622 100644
--- a/net/bridge/br_mdb.c
+++ b/net/bridge/br_mdb.c
@@ -371,6 +371,7 @@ static int __br_mdb_add(struct net *net, struct net_bridge *br,
if (!p || p->br != br || p->state == BR_STATE_DISABLED)
return -EINVAL;
+ memset(&ip, 0, sizeof(ip));
ip.proto = entry->addr.proto;
if (ip.proto == htons(ETH_P_IP))
ip.u.ip4 = entry->addr.u.ip4;
@@ -417,6 +418,7 @@ static int __br_mdb_del(struct net_bridge *br, struct br_mdb_entry *entry)
if (!netif_running(br->dev) || br->multicast_disabled)
return -EINVAL;
+ memset(&ip, 0, sizeof(ip));
ip.proto = entry->addr.proto;
if (ip.proto == htons(ETH_P_IP)) {
if (timer_pending(&br->ip4_other_query.timer))
--
1.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] bridge: mdb: zero out the local br_ip variable before use
2015-07-07 13:55 [PATCH net] bridge: mdb: zero out the local br_ip variable before use Nikolay Aleksandrov
@ 2015-07-08 23:11 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2015-07-08 23:11 UTC (permalink / raw)
To: razor; +Cc: netdev, bridge, stephen, vyasevich
From: Nikolay Aleksandrov <razor@blackwall.org>
Date: Tue, 7 Jul 2015 15:55:56 +0200
> Since commit b0e9a30dd669 ("bridge: Add vlan id to multicast groups")
> there's a check in br_ip_equal() for a matching vlan id, but the mdb
> functions were not modified to use (or at least zero it) so when an
> entry was added it would have a garbage vlan id (from the local br_ip
> variable in __br_mdb_add/del) and this would prevent it from being
> matched and also deleted. So zero out the whole local ip var to protect
> ourselves from future changes and also to fix the current bug, since
> there's no vlan id support in the mdb uapi - use always vlan id 0.
> Example before patch:
> root@debian:~# bridge mdb add dev br0 port eth1 grp 239.0.0.1 permanent
> root@debian:~# bridge mdb
> dev br0 port eth1 grp 239.0.0.1 permanent
> root@debian:~# bridge mdb del dev br0 port eth1 grp 239.0.0.1 permanent
> RTNETLINK answers: Invalid argument
>
> After patch:
> root@debian:~# bridge mdb add dev br0 port eth1 grp 239.0.0.1 permanent
> root@debian:~# bridge mdb
> dev br0 port eth1 grp 239.0.0.1 permanent
> root@debian:~# bridge mdb del dev br0 port eth1 grp 239.0.0.1 permanent
> root@debian:~# bridge mdb
>
> Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
> Fixes: b0e9a30dd669 ("bridge: Add vlan id to multicast groups")
Applied and queued up for -stable.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-07-08 23:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-07 13:55 [PATCH net] bridge: mdb: zero out the local br_ip variable before use Nikolay Aleksandrov
2015-07-08 23:11 ` 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).