Skip to content

Commit 116f84c

Browse files
Thadeu Lima de Souza Cascardojfvogel
authored andcommitted
net_sched: cls_route: remove from list when handle is 0
When a route filter is replaced and the old filter has a 0 handle, the old one won't be removed from the hashtable, while it will still be freed. The test was there since before commit 1109c00 ("net: sched: RCU cls_route"), when a new filter was not allocated when there was an old one. The old filter was reused and the reinserting would only be necessary if an old filter was replaced. That was still wrong for the same case where the old handle was 0. Remove the old filter from the list independently from its handle value. This fixes CVE-2022-2588, also reported as ZDI-CAN-17440. Reported-by: Zhenpeng Lin <[email protected]> Signed-off-by: Thadeu Lima de Souza Cascardo <[email protected]> Reviewed-by: Kamal Mostafa <[email protected]> Orabug: 34484536 CVE: CVE-2022-2588 Signed-off-by: Maciej S. Szmigiero <[email protected]> Reviewed-by: John Haxby <[email protected]> Reviewed-by: Liam Merwick <[email protected]>
1 parent b0444a7 commit 116f84c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/sched/cls_route.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ static int route4_change(struct net *net, struct sk_buff *in_skb,
526526
rcu_assign_pointer(f->next, f1);
527527
rcu_assign_pointer(*fp, f);
528528

529-
if (fold && fold->handle && f->handle != fold->handle) {
529+
if (fold) {
530530
th = to_hash(fold->handle);
531531
h = from_hash(fold->handle >> 16);
532532
b = rtnl_dereference(head->table[th]);

0 commit comments

Comments
 (0)