netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cong Wang <xiyou.wangcong@gmail.com>
To: Amir Vadai <amir@vadai.me>
Cc: "David S. Miller" <davem@davemloft.net>,
	Linux Kernel Network Developers <netdev@vger.kernel.org>,
	Jamal Hadi Salim <jhs@mojatatu.com>,
	Or Gerlitz <ogerlitz@mellanox.com>,
	Hadar Har-Zion <hadarh@mellanox.com>,
	Jiri Pirko <jiri@mellanox.com>
Subject: Re: [PATCH net] net/sched: act_pedit: limit negative offset
Date: Sun, 27 Nov 2016 21:39:33 -0800	[thread overview]
Message-ID: <CAM_iQpX1at1w=3OfRFchn3STTDJGXj640tGetxXToR=EyddpEw@mail.gmail.com> (raw)
In-Reply-To: <20161127155815.10359-1-amir@vadai.me>

On Sun, Nov 27, 2016 at 7:58 AM, Amir Vadai <amir@vadai.me> wrote:
> Should not allow setting a negative offset that goes below the skb head.
...
> diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c
> index b54d56d4959b..e79e8a88f2d2 100644
> --- a/net/sched/act_pedit.c
> +++ b/net/sched/act_pedit.c
> @@ -154,8 +154,11 @@ static int tcf_pedit(struct sk_buff *skb, const struct tc_action *a,
>                         }
>
>                         ptr = skb_header_pointer(skb, off + offset, 4, &_data);
> -                       if (!ptr)
> +                       if ((unsigned char *)ptr < skb->head) {


ptr returned could be &_data, which is on stack, so why this comparison
makes sense for this case?


> +                               pr_info("tc filter pedit offset out of bounds\n");
>                                 goto bad;
> +                       }
> +
>                         /* just do it, baby */
>                         *ptr = ((*ptr & tkey->mask) ^ tkey->val);
>                         if (ptr == &_data)
> --
> 2.10.2
>

  reply	other threads:[~2016-11-28  5:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-27 15:58 [PATCH net] net/sched: act_pedit: limit negative offset Amir Vadai
2016-11-28  5:39 ` Cong Wang [this message]
2016-11-28  5:49   ` David Miller
2016-11-28  7:51     ` Amir Vadai"

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='CAM_iQpX1at1w=3OfRFchn3STTDJGXj640tGetxXToR=EyddpEw@mail.gmail.com' \
    --to=xiyou.wangcong@gmail.com \
    --cc=amir@vadai.me \
    --cc=davem@davemloft.net \
    --cc=hadarh@mellanox.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=ogerlitz@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).