Skip to content

Commit

Permalink
net: sched: cls_u32: make sure that divisor is a power of 2
Browse files Browse the repository at this point in the history
Tested by modifying iproute2 to allow sending a divisor > 255

Tested-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Al Viro authored and davem330 committed Oct 8, 2018
1 parent 27594ec commit 2f0c982
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion net/sched/cls_u32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 2f0c982

Please sign in to comment.