* [PATCH net] net/sched: act_pedit: limit negative offset
@ 2016-11-27 15:58 Amir Vadai
2016-11-28 5:39 ` Cong Wang
0 siblings, 1 reply; 4+ messages in thread
From: Amir Vadai @ 2016-11-27 15:58 UTC (permalink / raw)
To: David S. Miller
Cc: netdev, Jamal Hadi Salim, Or Gerlitz, Hadar Har-Zion, Jiri Pirko,
Amir Vadai
Should not allow setting a negative offset that goes below the skb head.
Signed-off-by: Amir Vadai <amir@vadai.me>
---
Hi Dave,
Please pull to -stable branches.
Thanks,
Amir
net/sched/act_pedit.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
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) {
+ 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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] net/sched: act_pedit: limit negative offset
2016-11-27 15:58 [PATCH net] net/sched: act_pedit: limit negative offset Amir Vadai
@ 2016-11-28 5:39 ` Cong Wang
2016-11-28 5:49 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Cong Wang @ 2016-11-28 5:39 UTC (permalink / raw)
To: Amir Vadai
Cc: David S. Miller, Linux Kernel Network Developers,
Jamal Hadi Salim, Or Gerlitz, Hadar Har-Zion, Jiri Pirko
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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net/sched: act_pedit: limit negative offset
2016-11-28 5:39 ` Cong Wang
@ 2016-11-28 5:49 ` David Miller
2016-11-28 7:51 ` Amir Vadai"
0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2016-11-28 5:49 UTC (permalink / raw)
To: xiyou.wangcong; +Cc: amir, netdev, jhs, ogerlitz, hadarh, jiri
From: Cong Wang <xiyou.wangcong@gmail.com>
Date: Sun, 27 Nov 2016 21:39:33 -0800
> 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?
Indeed, this will definitely do the wrong thing when the on-stack area
passed back to ptr.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net/sched: act_pedit: limit negative offset
2016-11-28 5:49 ` David Miller
@ 2016-11-28 7:51 ` Amir Vadai"
0 siblings, 0 replies; 4+ messages in thread
From: Amir Vadai" @ 2016-11-28 7:51 UTC (permalink / raw)
To: David Miller; +Cc: xiyou.wangcong, netdev, jhs, ogerlitz, hadarh, jiri
On Mon, Nov 28, 2016 at 12:49:36AM -0500, David Miller wrote:
> From: Cong Wang <xiyou.wangcong@gmail.com>
> Date: Sun, 27 Nov 2016 21:39:33 -0800
>
> > 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?
>
> Indeed, this will definitely do the wrong thing when the on-stack area
> passed back to ptr.
yes - my bad. will correct it and send v1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-11-28 7:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-27 15:58 [PATCH net] net/sched: act_pedit: limit negative offset Amir Vadai
2016-11-28 5:39 ` Cong Wang
2016-11-28 5:49 ` David Miller
2016-11-28 7:51 ` Amir Vadai"
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.