Skip to content

Commit 2ba5af4

Browse files
Jiri Bencdavem330
authored andcommitted
openvswitch: fix panic with multiple vlan headers
When there are multiple vlan headers present in a received frame, the first one is put into vlan_tci and protocol is set to ETH_P_8021Q. Anything in the skb beyond the VLAN TPID may be still non-linear, including the inner TCI and ethertype. While ovs_flow_extract takes care of IP and IPv6 headers, it does nothing with ETH_P_8021Q. Later, if OVS_ACTION_ATTR_POP_VLAN is executed, __pop_vlan_tci pulls the next vlan header into vlan_tci. This leads to two things: 1. Part of the resulting ethernet header is in the non-linear part of the skb. When eth_type_trans is called later as the result of OVS_ACTION_ATTR_OUTPUT, kernel BUGs in __skb_pull. Also, __pop_vlan_tci is in fact accessing random data when it reads past the TPID. 2. network_header points into the ethernet header instead of behind it. mac_len is set to a wrong value (10), too. Reported-by: Yulong Pei <[email protected]> Signed-off-by: Jiri Benc <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 793c3b4 commit 2ba5af4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

net/openvswitch/actions.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *skb,
4242

4343
static int make_writable(struct sk_buff *skb, int write_len)
4444
{
45+
if (!pskb_may_pull(skb, write_len))
46+
return -ENOMEM;
47+
4548
if (!skb_cloned(skb) || skb_clone_writable(skb, write_len))
4649
return 0;
4750

@@ -70,6 +73,8 @@ static int __pop_vlan_tci(struct sk_buff *skb, __be16 *current_tci)
7073

7174
vlan_set_encap_proto(skb, vhdr);
7275
skb->mac_header += VLAN_HLEN;
76+
if (skb_network_offset(skb) < ETH_HLEN)
77+
skb_set_network_header(skb, ETH_HLEN);
7378
skb_reset_mac_len(skb);
7479

7580
return 0;

0 commit comments

Comments
 (0)