Skip to content

Commit

Permalink
act_ife: Fix external mac header on encode
Browse files Browse the repository at this point in the history
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: ef6980b ("net sched: introduce IFE action")
Acked-by: Jamal Hadi Salim <[email protected]>
Signed-off-by: Yotam Gigi <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
yotamgi authored and davem330 committed Sep 27, 2016
1 parent 1190cfd commit 4b1d488
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions net/sched/act_ife.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,8 +740,6 @@ static int tcf_ife_encode(struct sk_buff *skb, const struct tc_action *a,
return TC_ACT_SHOT;
}

iethh = eth_hdr(skb);

err = skb_cow_head(skb, hdrm);
if (unlikely(err)) {
ife->tcf_qstats.drops++;
Expand All @@ -752,6 +750,7 @@ static int tcf_ife_encode(struct sk_buff *skb, const struct tc_action *a,
if (!(at & AT_EGRESS))
skb_push(skb, skb->dev->hard_header_len);

iethh = (struct ethhdr *)skb->data;
__skb_push(skb, hdrm);
memcpy(skb->data, iethh, skb->mac_len);
skb_reset_mac_header(skb);
Expand Down

0 comments on commit 4b1d488

Please sign in to comment.