xfrm6: fix the proto and ports decode of sctp protocol
The SCTP pushed the skb above the sctp chunk header, so the check of pskb_may_pull(skb, nh + offset + 1 - skb->data) in _decode_session6() will never return 0 and the ports decode of sctp will always fail. (nh + offset + 1 - skb->data < 0) Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Acked-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
c615c9f3f3
commit
59cae0092e
|
@ -157,7 +157,8 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
|
|||
ipv6_addr_copy(&fl->fl6_dst, reverse ? &hdr->saddr : &hdr->daddr);
|
||||
ipv6_addr_copy(&fl->fl6_src, reverse ? &hdr->daddr : &hdr->saddr);
|
||||
|
||||
while (pskb_may_pull(skb, nh + offset + 1 - skb->data)) {
|
||||
while (nh + offset + 1 < skb->data ||
|
||||
pskb_may_pull(skb, nh + offset + 1 - skb->data)) {
|
||||
nh = skb_network_header(skb);
|
||||
exthdr = (struct ipv6_opt_hdr *)(nh + offset);
|
||||
|
||||
|
@ -177,7 +178,8 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
|
|||
case IPPROTO_TCP:
|
||||
case IPPROTO_SCTP:
|
||||
case IPPROTO_DCCP:
|
||||
if (!onlyproto && pskb_may_pull(skb, nh + offset + 4 - skb->data)) {
|
||||
if (!onlyproto && (nh + offset + 4 < skb->data ||
|
||||
pskb_may_pull(skb, nh + offset + 4 - skb->data))) {
|
||||
__be16 *ports = (__be16 *)exthdr;
|
||||
|
||||
fl->fl_ip_sport = ports[!!reverse];
|
||||
|
|
Loading…
Reference in New Issue