LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] net: sched: cls: fix a potential missing-check bug
@ 2018-05-04  7:05 Wenwen Wang
  2018-05-04 17:12 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Wenwen Wang @ 2018-05-04  7:05 UTC (permalink / raw)
  To: Wenwen Wang
  Cc: Kangjie Lu, Jamal Hadi Salim, Cong Wang, Jiri Pirko,
	David S. Miller, open list:TC subsystem, open list

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 <wang6495@umn.edu>
---
 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: sched: cls: fix a potential missing-check bug
  2018-05-04  7:05 [PATCH] net: sched: cls: fix a potential missing-check bug Wenwen Wang
@ 2018-05-04 17:12 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-05-04 17:12 UTC (permalink / raw)
  To: wang6495; +Cc: kjlu, jhs, xiyou.wangcong, jiri, netdev, linux-kernel

From: Wenwen Wang <wang6495@umn.edu>
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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-05-04 17:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-04  7:05 [PATCH] net: sched: cls: fix a potential missing-check bug Wenwen Wang
2018-05-04 17:12 ` David Miller

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).