xfrm4: fix the ports decode of sctp protocol
Subsystems (3)
PATCH 1/2 xfrm4: fix the ports decode of sctp protocol
The SCTP pushed the skb data above the sctp chunk header, so the check of pskb_may_pull(skb, xprth + 4 - skb->data) in _decode_session4() will never return 0 because xprth + 4 - skb->data < 0, the ports decode of sctp will always fail.
--- net/ipv4/xfrm4_policy.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
net/ipv4/xfrm4_policy.c +2 -1
@@ -136,7 +136,8 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)case IPPROTO_TCP :case IPPROTO_SCTP :case IPPROTO_DCCP : -if (pskb_may_pull (skb, xprth +4 - skb->data)) { +if (xprth +4 < skb->data || +pskb_may_pull (skb, xprth +4 - skb->data)) {__be16 *ports = (__be16 *)xprth; fl->fl_ip_sport = ports[!!reverse];
Signature · 1 line
1.6.2.2
PATCH 2/2 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)
--- net/ipv6/xfrm6_policy.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
net/ipv6/xfrm6_policy.c +4 -2
@@ -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];
Signature · 1 line
1.6.2.2
Quoted 6 lines · Wei Yongjun
The SCTP pushed the skb data above the sctp chunk header, so the check of
pskb_may_pull(skb, xprth + 4 - skb->data)in_decode_session4()will never return 0 because xprth + 4 -skb->data< 0, the ports decode of sctp will always fail.Signed-off-by Wei Yongjun <[email protected]>
Longer term I wonder if we can move this stuff into the protocol code, i.e., before they call xfrm_policy_check.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtRe: [PATCH 2/2] xfrm6: fix the proto and ports decode of sctp protocol
In reply to Wei YongjunQuoted 6 lines · Wei Yongjun
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 <[email protected]>
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtFrom: Herbert Xu <[email protected]>
Date: Fri, 3 Jul 2009 11:48:49 +0800
Quoted 9 lines · Wei Yongjun
Quoted 6 lines
The SCTP pushed the skb data above the sctp chunk header, so the check of
pskb_may_pull(skb, xprth + 4 - skb->data)in_decode_session4()will never return 0 because xprth + 4 -skb->data< 0, the ports decode of sctp will always fail.Signed-off-by Wei Yongjun <[email protected]>Acked-by Herbert Xu <[email protected]>
Applied.
Quoted 2 lines
Longer term I wonder if we can move this stuff into the protocol code, i.e., before they call
xfrm_policy_check.
That ought to work.
Re: [PATCH 2/2] xfrm6: fix the proto and ports decode of sctp protocol
In reply to Herbert XuFrom: Herbert Xu <[email protected]>
Date: Fri, 3 Jul 2009 11:49:17 +0800
Quoted 9 lines · Wei Yongjun
Quoted 6 lines
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 <[email protected]>Acked-by Herbert Xu <[email protected]>
Applied.