* [PATCH net v3 0/2] Fix tc-ife bugs
@ 2016-09-26 10:45 Yotam Gigi
2016-09-26 10:45 ` [PATCH net v3 1/2] act_ife: Fix external mac header on encode Yotam Gigi
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Yotam Gigi @ 2016-09-26 10:45 UTC (permalink / raw)
To: jhs, davem, netdev, mlxsw; +Cc: Yotam Gigi
This patch-set contains two bugfixes in the tc-ife action, one fixing some
random behaviour in encode side, and one fixing the decode side packet
parsing logic.
v2->v3
- Fix the encode side instead of the decode side
Yotam Gigi (2):
act_ife: Fix external mac header on encode
act_ife: Fix false encoding
net/sched/act_ife.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
--
2.4.11
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net v3 1/2] act_ife: Fix external mac header on encode
2016-09-26 10:45 [PATCH net v3 0/2] Fix tc-ife bugs Yotam Gigi
@ 2016-09-26 10:45 ` Yotam Gigi
2016-09-26 10:45 ` [PATCH net v3 2/2] act_ife: Fix false encoding Yotam Gigi
2016-09-27 13:54 ` [PATCH net v3 0/2] Fix tc-ife bugs David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Yotam Gigi @ 2016-09-26 10:45 UTC (permalink / raw)
To: jhs, davem, netdev, mlxsw; +Cc: Yotam Gigi
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>
---
net/sched/act_ife.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c
index ccf7b4b..b949d97 100644
--- a/net/sched/act_ife.c
+++ b/net/sched/act_ife.c
@@ -766,8 +766,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++;
@@ -778,6 +776,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);
--
2.4.11
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH net v3 2/2] act_ife: Fix false encoding
2016-09-26 10:45 [PATCH net v3 0/2] Fix tc-ife bugs Yotam Gigi
2016-09-26 10:45 ` [PATCH net v3 1/2] act_ife: Fix external mac header on encode Yotam Gigi
@ 2016-09-26 10:45 ` Yotam Gigi
2016-09-27 13:54 ` [PATCH net v3 0/2] Fix tc-ife bugs David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Yotam Gigi @ 2016-09-26 10:45 UTC (permalink / raw)
To: jhs, davem, netdev, mlxsw; +Cc: Yotam Gigi
On ife encode side, the action stores the different tlvs inside the ife
header, where each tlv length field should refer to the length of the
whole tlv (without additional padding) and not just the data length.
On ife decode side, the action iterates over the tlvs in the ife header
and parses them one by one, where in each iteration the current pointer is
advanced according to the tlv size.
Before, the encoding encoded only the data length inside the tlv, which led
to false parsing of ife the header. In addition, due to the fact that the
loop counter was unsigned, it could lead to infinite parsing loop.
This fix changes the loop counter to be signed and fixes the encoding to
take into account the tlv type and size.
Fixes: 28a10c426e81 ("net sched: fix encoding to use real length")
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Yotam Gigi <yotamg@mellanox.com>
---
v2->v3
- Fix the encode side instead of the decode side
---
net/sched/act_ife.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c
index b949d97..95c463c 100644
--- a/net/sched/act_ife.c
+++ b/net/sched/act_ife.c
@@ -53,7 +53,7 @@ int ife_tlv_meta_encode(void *skbdata, u16 attrtype, u16 dlen, const void *dval)
u32 *tlv = (u32 *)(skbdata);
u16 totlen = nla_total_size(dlen); /*alignment + hdr */
char *dptr = (char *)tlv + NLA_HDRLEN;
- u32 htlv = attrtype << 16 | dlen;
+ u32 htlv = attrtype << 16 | (dlen + NLA_HDRLEN);
*tlv = htonl(htlv);
memset(dptr, 0, totlen - NLA_HDRLEN);
@@ -653,7 +653,7 @@ static int tcf_ife_decode(struct sk_buff *skb, const struct tc_action *a,
struct tcf_ife_info *ife = to_ife(a);
int action = ife->tcf_action;
struct ifeheadr *ifehdr = (struct ifeheadr *)skb->data;
- u16 ifehdrln = ifehdr->metalen;
+ int ifehdrln = (int)ifehdr->metalen;
struct meta_tlvhdr *tlv = (struct meta_tlvhdr *)(ifehdr->tlv_data);
spin_lock(&ife->tcf_lock);
--
2.4.11
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net v3 0/2] Fix tc-ife bugs
2016-09-26 10:45 [PATCH net v3 0/2] Fix tc-ife bugs Yotam Gigi
2016-09-26 10:45 ` [PATCH net v3 1/2] act_ife: Fix external mac header on encode Yotam Gigi
2016-09-26 10:45 ` [PATCH net v3 2/2] act_ife: Fix false encoding Yotam Gigi
@ 2016-09-27 13:54 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2016-09-27 13:54 UTC (permalink / raw)
To: yotam.gi; +Cc: jhs, netdev, mlxsw, yotamg
From: Yotam Gigi <yotam.gi@gmail.com>
Date: Mon, 26 Sep 2016 13:45:24 +0300
> This patch-set contains two bugfixes in the tc-ife action, one fixing some
> random behaviour in encode side, and one fixing the decode side packet
> parsing logic.
>
> v2->v3
> - Fix the encode side instead of the decode side
Series applied, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-09-27 13:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-26 10:45 [PATCH net v3 0/2] Fix tc-ife bugs Yotam Gigi
2016-09-26 10:45 ` [PATCH net v3 1/2] act_ife: Fix external mac header on encode Yotam Gigi
2016-09-26 10:45 ` [PATCH net v3 2/2] act_ife: Fix false encoding Yotam Gigi
2016-09-27 13:54 ` [PATCH net v3 0/2] Fix tc-ife bugs 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).