netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Alexander Aring <aring@mojatatu.com>, yotam.gi@gmail.com
Cc: jhs@mojatatu.com, davem@davemloft.net, xiyou.wangcong@gmail.com,
	jiri@resnulli.us, yuvalm@mellanox.com, netdev@vger.kernel.org,
	kernel@mojatatu.com
Subject: Re: [PATCHv3 net 3/3] net: sched: ife: check on metadata length
Date: Thu, 19 Apr 2018 15:24:01 -0700	[thread overview]
Message-ID: <cfa269fe-443c-3440-8b41-48b7d7a6fd3c@gmail.com> (raw)
In-Reply-To: <20180419221445.26205-4-aring@mojatatu.com>



On 04/19/2018 03:14 PM, Alexander Aring wrote:
> This patch checks if sk buffer is available to dererence ife header. If
> not then NULL will returned to signal an malformed ife packet. This
> avoids to crashing the kernel from outside.
> 
> Signed-off-by: Alexander Aring <aring@mojatatu.com>
> Reviewed-by: Yotam Gigi <yotam.gi@gmail.com>
> Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
> ---
>  net/ife/ife.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/net/ife/ife.c b/net/ife/ife.c
> index 7fbe70a0af4b..570a18d4ca32 100644
> --- a/net/ife/ife.c
> +++ b/net/ife/ife.c
> @@ -70,6 +70,9 @@ void *ife_decode(struct sk_buff *skb, u16 *metalen)
>  	u16 ifehdrln;
>  
>  	ifehdr = (struct ifeheadr *) (skb->data + skb->dev->hard_header_len);
> +	if (!pskb_may_pull(skb, skb->dev->hard_header_len + IFE_METAHDRLEN))
> +		return NULL;
> +



No, you need to move here :

       ifehdr = (struct ifeheadr *) (skb->data + skb->dev->hard_header_len);

>  	ifehdrln = ntohs(ifehdr->metalen);
>  	total_pull = skb->dev->hard_header_len + ifehdrln;
>  
> 


Please do not rush, wait one day before sending V4, no need to flood netdev@

      reply	other threads:[~2018-04-19 22:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-19 22:14 [PATCHv3 net 0/3] net: sched: ife: malformed ife packet fixes Alexander Aring
2018-04-19 22:14 ` [PATCHv3 net 1/3] net: sched: ife: signal not finding metaid Alexander Aring
2018-04-19 22:14 ` [PATCHv3 net 2/3] net: sched: ife: handle malformed tlv length Alexander Aring
2018-04-19 22:14 ` [PATCHv3 net 3/3] net: sched: ife: check on metadata length Alexander Aring
2018-04-19 22:24   ` Eric Dumazet [this message]

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=cfa269fe-443c-3440-8b41-48b7d7a6fd3c@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=aring@mojatatu.com \
    --cc=davem@davemloft.net \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kernel@mojatatu.com \
    --cc=netdev@vger.kernel.org \
    --cc=xiyou.wangcong@gmail.com \
    --cc=yotam.gi@gmail.com \
    --cc=yuvalm@mellanox.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).