Skip to content

Commit 0d1c353

Browse files
congwangdavem330
authored andcommitted
net_sched: keep alloc_hash updated after hash allocation
In commit 599be01 ("net_sched: fix an OOB access in cls_tcindex") I moved cp->hash calculation before the first tcindex_alloc_perfect_hash(), but cp->alloc_hash is left untouched. This difference could lead to another out of bound access. cp->alloc_hash should always be the size allocated, we should update it after this tcindex_alloc_perfect_hash(). Reported-and-tested-by: [email protected] Reported-and-tested-by: [email protected] Fixes: 599be01 ("net_sched: fix an OOB access in cls_tcindex") Cc: Jamal Hadi Salim <[email protected]> Cc: Jiri Pirko <[email protected]> Signed-off-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b1be2e8 commit 0d1c353

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

net/sched/cls_tcindex.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
359359

360360
if (tcindex_alloc_perfect_hash(net, cp) < 0)
361361
goto errout;
362+
cp->alloc_hash = cp->hash;
362363
for (i = 0; i < min(cp->hash, p->hash); i++)
363364
cp->perfect[i].res = p->perfect[i].res;
364365
balloc = 1;

0 commit comments

Comments
 (0)