htb: fix sign extension bug
authorstephen hemminger <stephen@networkplumber.org>
Fri, 2 Aug 2013 05:32:07 +0000 (22:32 -0700)
committerWilly Tarreau <w@1wt.eu>
Mon, 19 May 2014 05:53:51 +0000 (07:53 +0200)
commit63251ed09df444c561f7dddf2d97539e1257a7b6
tree57c565f4f753e419f798780cbbf6091f3b619437
parentf5a2119c90fba5150930082491bceee731f52c90
htb: fix sign extension bug

[ Upstream commit cbd375567f7e4811b1c721f75ec519828ac6583f ]

When userspace passes a large priority value
the assignment of the unsigned value hopt->prio
to  signed int cl->prio causes cl->prio to become negative and the
comparison is with TC_HTB_NUMPRIO is always false.

The result is that HTB crashes by referencing outside
the array when processing packets. With this patch the large value
wraps around like other values outside the normal range.

See: https://bugzilla.kernel.org/show_bug.cgi?id=60669

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Willy Tarreau <w@1wt.eu>
net/sched/sch_htb.c