datapath: Scrub skb between namespaces
authorJoe Stringer <joestringer@nicira.com>
Thu, 3 Dec 2015 07:53:55 +0000 (23:53 -0800)
committerJoe Stringer <joe@ovn.org>
Fri, 4 Dec 2015 01:17:26 +0000 (17:17 -0800)
If OVS receives a packet from another namespace, then the packet should
be scrubbed. However, people have already begun to rely on the behaviour
that skb->mark is preserved across namespaces, so retain this one field.

This is mainly to address information leakage between namespaces when
using OVS internal ports, but by placing it in ovs_vport_receive() it is
more generally applicable, meaning it should not be overlooked if other
port types are allowed to be moved into namespaces in future.

Upstream: 740dbc289155 ("openvswitch: Scrub skb between namespaces")
Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
datapath/vport.c

index 0951cbb..899119f 100644 (file)
@@ -494,6 +494,15 @@ int ovs_vport_receive(struct vport *vport, struct sk_buff *skb,
 
        OVS_CB(skb)->input_vport = vport;
        OVS_CB(skb)->mru = 0;
+       if (unlikely(dev_net(skb->dev) != ovs_dp_get_net(vport->dp))) {
+               u32 mark;
+
+               mark = skb->mark;
+               skb_scrub_packet(skb, true);
+               skb->mark = mark;
+               tun_info = NULL;
+       }
+
        ovs_skb_init_inner_protocol(skb);
        skb_clear_ovs_gso_cb(skb);
        /* Extract flow from 'skb' into 'key'. */