netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: avoid vlan ptype specific match to be leaked on real device
@ 2016-06-22 10:25 Paolo Abeni
  2016-06-22 10:55 ` Jiri Pirko
  0 siblings, 1 reply; 8+ messages in thread
From: Paolo Abeni @ 2016-06-22 10:25 UTC (permalink / raw)
  To: netdev
  Cc: David S. Miller, Jiri Pirko, Alexander Duyck, Eric Dumazet,
	Daniel Borkmann

Before the commit 0dfe17823945 ("net: vlan: goto another_round
instead of calling __netif_receive_skb"), on tagged skb ingress,
ptype specific protocol matches were delivered only to the
related vlan device, if any.
After said commit, jumping back to the 'another_round' label, allows
the later ptype specific check to match both orig_dev and skb->dev,
delivering the skb to both the vlan device and the underlying
device.
This cause i.e. packet sockets bound to a specific protocol type on
one of said devices to receive also frames really targeting the
other device.
This commit resets orig_dev before performing another round due to
vlan processing, allowing the skb to be delivered once again only
to the vlan specific ptypes.

Fixes: 0dfe17823945 ("net: vlan: goto another_round instead of calling __netif_receive_skb")
Reported-by: Ryan Liu <Ryan.Liu@alcatel-lucent.com>
Reported-by: Cliff Chen <Cliff.Chen@alcatel-lucent.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 net/core/dev.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 904ff43..9d08dd6 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4144,10 +4144,15 @@ ncls:
 			ret = deliver_skb(skb, pt_prev, orig_dev);
 			pt_prev = NULL;
 		}
-		if (vlan_do_receive(&skb))
+		if (vlan_do_receive(&skb)) {
+			/* avoid delivering to ptype registered on
+			 * vlan's underlying device only
+			 */
+			orig_dev = skb->dev;
 			goto another_round;
-		else if (unlikely(!skb))
+		} else if (unlikely(!skb)) {
 			goto out;
+		}
 	}
 
 	rx_handler = rcu_dereference(skb->dev->rx_handler);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-06-27 14:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-22 10:25 [PATCH net] net: avoid vlan ptype specific match to be leaked on real device Paolo Abeni
2016-06-22 10:55 ` Jiri Pirko
2016-06-22 12:21   ` Paolo Abeni
2016-06-22 12:40     ` Jiri Pirko
2016-06-26 20:06       ` David Miller
2016-06-27  9:28         ` Paolo Abeni
2016-06-27  9:37           ` Jiri Pirko
2016-06-27 13:43           ` 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).