aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYotam Gigi <yotam.gi@gmail.com>2016-09-26 06:45:25 -0400
committerDavid S. Miller <davem@davemloft.net>2016-09-27 09:53:16 -0400
commit4b1d488a285a446329825d5fe91f987b7880e6e5 (patch)
treeb2ef6d341e8eac085aa828f66ecc08a22979ed17
parent1190cfdb1a19d89561ae51cff7d9c2ead24b3ebe (diff)
act_ife: Fix external mac header on encode
On ife encode side, external mac header is copied from the original packet and may be overridden if the user requests. Before, the mac header copy was done from memory region that might not be accessible anymore, as skb_cow_head might free it and copy the packet. This led to random values in the external mac header once the values were not set by user. This fix takes the internal mac header from the packet, after the call to skb_cow_head. Fixes: ef6980b6becb ("net sched: introduce IFE action") Acked-by: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: Yotam Gigi <yotamg@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/sched/act_ife.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c
index e87cd81315e1..88ac9a8c9bbd 100644
--- a/net/sched/act_ife.c
+++ b/net/sched/act_ife.c
@@ -740,8 +740,6 @@ static int tcf_ife_encode(struct sk_buff *skb, const struct tc_action *a,
740 return TC_ACT_SHOT; 740 return TC_ACT_SHOT;
741 } 741 }
742 742
743 iethh = eth_hdr(skb);
744
745 err = skb_cow_head(skb, hdrm); 743 err = skb_cow_head(skb, hdrm);
746 if (unlikely(err)) { 744 if (unlikely(err)) {
747 ife->tcf_qstats.drops++; 745 ife->tcf_qstats.drops++;
@@ -752,6 +750,7 @@ static int tcf_ife_encode(struct sk_buff *skb, const struct tc_action *a,
752 if (!(at & AT_EGRESS)) 750 if (!(at & AT_EGRESS))
753 skb_push(skb, skb->dev->hard_header_len); 751 skb_push(skb, skb->dev->hard_header_len);
754 752
753 iethh = (struct ethhdr *)skb->data;
755 __skb_push(skb, hdrm); 754 __skb_push(skb, hdrm);
756 memcpy(skb->data, iethh, skb->mac_len); 755 memcpy(skb->data, iethh, skb->mac_len);
757 skb_reset_mac_header(skb); 756 skb_reset_mac_header(skb);