netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: roy.qing.li@gmail.com, netdev@vger.kernel.org
Cc: steffen.klassert@secunet.com
Subject: Re: [PATCH 2/2] xfrm6: fix a potential use after free in xfrm6_policy.c
Date: Mon, 20 Oct 2014 14:36:16 +0400	[thread overview]
Message-ID: <5444E5A0.9040004@cogentembedded.com> (raw)
In-Reply-To: <1413794954-16967-2-git-send-email-roy.qing.li@gmail.com>

Hello.

On 10/20/2014 12:49 PM, roy.qing.li@gmail.com wrote:

> From: Li RongQing <roy.qing.li@gmail.com>

> pskb_may_pull() maybe change skb->data and make nh and exthdr pointer
> oboslete, so recompute the nd and exthdr

> Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
> ---
>   net/ipv6/xfrm6_policy.c |   11 ++++++++---
>   1 file changed, 8 insertions(+), 3 deletions(-)

> diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
> index ac49f84..115fd3b 100644
> --- a/net/ipv6/xfrm6_policy.c
> +++ b/net/ipv6/xfrm6_policy.c
> @@ -170,8 +170,10 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
>   		case IPPROTO_DCCP:
>   			if (!onlyproto && (nh + offset + 4 < skb->data ||
>   			     pskb_may_pull(skb, nh + offset + 4 - skb->data))) {
> -				__be16 *ports = (__be16 *)exthdr;
> +				__be16 *ports;
>
> +				nh = skb_network_header(skb);
> +				ports = (__be16*)(nh + offset);

    Please insert a space between '__be16' and * like it was done in the 
deleted assignment.

[...]
> @@ -180,8 +182,10 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
>
>   		case IPPROTO_ICMPV6:
>   			if (!onlyproto && pskb_may_pull(skb, nh + offset + 2 - skb->data)) {
> -				u8 *icmp = (u8 *)exthdr;
> +				u8 *icmp;
>
> +				nh = skb_network_header(skb);
> +				icmp = (u8*)(nh + offset);

    Likewise.

[...]
> @@ -192,8 +196,9 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
>   		case IPPROTO_MH:
>   			if (!onlyproto && pskb_may_pull(skb, nh + offset + 3 - skb->data)) {
>   				struct ip6_mh *mh;
> -				mh = (struct ip6_mh *)exthdr;
>
> +				nh = skb_network_header(skb);
> +				mh = (struct ip6_mh*)(nh + offset);

    Likewise.

[...]

WBR, Sergei

  reply	other threads:[~2014-10-20 10:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-20  8:49 [PATCH 1/2] xfrm: fix a potential use after free in xfrm4_policy.c roy.qing.li
2014-10-20  8:49 ` [PATCH 2/2] xfrm6: fix a potential use after free in xfrm6_policy.c roy.qing.li
2014-10-20 10:36   ` Sergei Shtylyov [this message]
2014-10-22  1:42 ` [PATCH 1/2] xfrm: fix a potential use after free in xfrm4_policy.c David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5444E5A0.9040004@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=netdev@vger.kernel.org \
    --cc=roy.qing.li@gmail.com \
    --cc=steffen.klassert@secunet.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).