Skip to content

Commit

Permalink
Merge branch 'net-sched-bind-logic-fixes-for-cls_fw-cls_u32-and-cls_r…
Browse files Browse the repository at this point in the history
…oute'

valis says:

====================
net/sched Bind logic fixes for cls_fw, cls_u32 and cls_route

Three classifiers (cls_fw, cls_u32 and cls_route) always copy
tcf_result struct into the new instance of the filter on update.

This causes a problem when updating a filter bound to a class,
as tcf_unbind_filter() is always called on the old instance in the
success path, decreasing filter_cnt of the still referenced class
and allowing it to be deleted, leading to a use-after-free.

This patch set fixes this issue in all affected classifiers by no longer
copying the tcf_result struct from the old filter.
====================

Link: https://lore.kernel.org/r/20230729123202.72406-1-jhs@mojatatu.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed Aug 1, 2023
2 parents 611e1b0 + b80b829 commit c5ccff7
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 3 deletions.
1 change: 0 additions & 1 deletion net/sched/cls_fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ static int fw_change(struct net *net, struct sk_buff *in_skb,
return -ENOBUFS;

fnew->id = f->id;
fnew->res = f->res;
fnew->ifindex = f->ifindex;
fnew->tp = f->tp;

Expand Down
1 change: 0 additions & 1 deletion net/sched/cls_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@ static int route4_change(struct net *net, struct sk_buff *in_skb,
if (fold) {
f->id = fold->id;
f->iif = fold->iif;
f->res = fold->res;
f->handle = fold->handle;

f->tp = fold->tp;
Expand Down
1 change: 0 additions & 1 deletion net/sched/cls_u32.c
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,6 @@ static struct tc_u_knode *u32_init_knode(struct net *net, struct tcf_proto *tp,

new->ifindex = n->ifindex;
new->fshift = n->fshift;
new->res = n->res;
new->flags = n->flags;
RCU_INIT_POINTER(new->ht_down, ht);

Expand Down

0 comments on commit c5ccff7

Please sign in to comment.