2018-05-04 07:05:47

by Wenwen Wang

[permalink] [raw]
Subject: [PATCH] net: sched: cls: fix a potential missing-check bug

In rsvp_change(), the value of f->res.classid is checked to be no more
than 255. Otherwise, the execution will goto errout. This is enforced by a
if-statement check. However, in the following execution, f->res.classid is
assigned with a new value returned from gen_tunnel(), and the new value
is only checked against 0. Given that gen_tunnel() may return a value
larger than 255 based on data, the new value of f->res.classid should
be re-checked.

This patch adds a re-check to ensure the new value of f->res.classid is not
great than 255; otherwise, an error code will be returned.

Signed-off-by: Wenwen Wang <[email protected]>
---
net/sched/cls_rsvp.h | 3 +++
1 file changed, 3 insertions(+)

diff --git a/net/sched/cls_rsvp.h b/net/sched/cls_rsvp.h
index 4f12976..7ced8fc 100644
--- a/net/sched/cls_rsvp.h
+++ b/net/sched/cls_rsvp.h
@@ -590,6 +590,9 @@ static int rsvp_change(struct net *net, struct sk_buff *in_skb,
if (f->res.classid == 0 &&
(f->res.classid = gen_tunnel(data)) == 0)
goto errout;
+
+ if (f->res.classid > 255)
+ goto errout;
}

for (sp = &data->ht[h1];
--
2.7.4



2018-05-04 17:13:21

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] net: sched: cls: fix a potential missing-check bug

From: Wenwen Wang <[email protected]>
Date: Fri, 4 May 2018 02:05:05 -0500

> Given that gen_tunnel() may return a value larger than 255 based on
> data, the new value of f->res.classid should be re-checked.

gen_tunnel() may not ever return a value larger than 255.

data->tgenerator is a u8 and therefore can never take on a value
outside of the range of 0 to 255.

I'm not applying this patch, sorry.