projects
/
openwrt
/
staging
/
blogic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
27594ec
)
net: sched: cls_u32: make sure that divisor is a power of 2
author
Al Viro
<
[email protected]
>
Mon, 8 Oct 2018 10:22:35 +0000
(06:22 -0400)
committer
David S. Miller
<
[email protected]
>
Mon, 8 Oct 2018 17:33:35 +0000
(10:33 -0700)
Tested by modifying iproute2 to allow sending a divisor > 255
Tested-by: Jamal Hadi Salim <
[email protected]
>
Signed-off-by: Al Viro <
[email protected]
>
Signed-off-by: Jamal Hadi Salim <
[email protected]
>
Signed-off-by: David S. Miller <
[email protected]
>
net/sched/cls_u32.c
patch
|
blob
|
history
diff --git
a/net/sched/cls_u32.c
b/net/sched/cls_u32.c
index 3357331a80a21a3ea95de842500692a07c846833..ce55eea448a091518f51d42d040ecb02dda62ddc 100644
(file)
--- a/
net/sched/cls_u32.c
+++ b/
net/sched/cls_u32.c
@@
-994,7
+994,11
@@
static int u32_change(struct net *net, struct sk_buff *in_skb,
if (tb[TCA_U32_DIVISOR]) {
unsigned int divisor = nla_get_u32(tb[TCA_U32_DIVISOR]);
- if (--divisor > 0x100) {
+ if (!is_power_of_2(divisor)) {
+ NL_SET_ERR_MSG_MOD(extack, "Divisor is not a power of 2");
+ return -EINVAL;
+ }
+ if (divisor-- > 0x100) {
NL_SET_ERR_MSG_MOD(extack, "Exceeded maximum 256 hash buckets");
return -EINVAL;
}