Commit a6ab0586 authored by Eric Dumazet's avatar Eric Dumazet Committed by Kleber Sacilotto de Souza

sch_dsmark: fix invalid skb_cow() usage

BugLink: http://bugs.launchpad.net/bugs/1745054

[ Upstream commit aea92fb2 ]

skb_cow(skb, sizeof(ip header)) is not very helpful in this context.

First we need to use pskb_may_pull() to make sure the ip header
is in skb linear part, then use skb_try_make_writable() to
address clones issues.

Fixes: 4c30719f ("[PKT_SCHED] dsmark: handle cloned and non-linear skb's")
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
parent 2b70f4f1
...@@ -199,9 +199,13 @@ static int dsmark_enqueue(struct sk_buff *skb, struct Qdisc *sch) ...@@ -199,9 +199,13 @@ static int dsmark_enqueue(struct sk_buff *skb, struct Qdisc *sch)
pr_debug("%s(skb %p,sch %p,[qdisc %p])\n", __func__, skb, sch, p); pr_debug("%s(skb %p,sch %p,[qdisc %p])\n", __func__, skb, sch, p);
if (p->set_tc_index) { if (p->set_tc_index) {
int wlen = skb_network_offset(skb);
switch (tc_skb_protocol(skb)) { switch (tc_skb_protocol(skb)) {
case htons(ETH_P_IP): case htons(ETH_P_IP):
if (skb_cow_head(skb, sizeof(struct iphdr))) wlen += sizeof(struct iphdr);
if (!pskb_may_pull(skb, wlen) ||
skb_try_make_writable(skb, wlen))
goto drop; goto drop;
skb->tc_index = ipv4_get_dsfield(ip_hdr(skb)) skb->tc_index = ipv4_get_dsfield(ip_hdr(skb))
...@@ -209,7 +213,9 @@ static int dsmark_enqueue(struct sk_buff *skb, struct Qdisc *sch) ...@@ -209,7 +213,9 @@ static int dsmark_enqueue(struct sk_buff *skb, struct Qdisc *sch)
break; break;
case htons(ETH_P_IPV6): case htons(ETH_P_IPV6):
if (skb_cow_head(skb, sizeof(struct ipv6hdr))) wlen += sizeof(struct ipv6hdr);
if (!pskb_may_pull(skb, wlen) ||
skb_try_make_writable(skb, wlen))
goto drop; goto drop;
skb->tc_index = ipv6_get_dsfield(ipv6_hdr(skb)) skb->tc_index = ipv6_get_dsfield(ipv6_hdr(skb))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment