Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d6cdc5bb authored by Cong Wang's avatar Cong Wang Committed by Greg Kroah-Hartman
Browse files

net_sched: keep alloc_hash updated after hash allocation



[ Upstream commit 0d1c3530e1bd38382edef72591b78e877e0edcd3 ]

In commit 599be01ee567 ("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: default avatar <syzbot+dcc34d54d68ef7d2d53d@syzkaller.appspotmail.com>
Reported-and-tested-by: default avatar <syzbot+c72da7b9ed57cde6fca2@syzkaller.appspotmail.com>
Fixes: 599be01ee567 ("net_sched: fix an OOB access in cls_tcindex")
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7518af64
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -293,6 +293,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
				      sizeof(*r) * cp->hash, GFP_KERNEL);
		if (!cp->perfect)
			goto errout;
		cp->alloc_hash = cp->hash;
		for (i = 0; i < min(cp->hash, p->hash); i++)
			tcf_exts_init(&cp->perfect[i].exts,
				      TCA_TCINDEX_ACT, TCA_TCINDEX_POLICE);