Skip to content

Commit e910af6

Browse files
congwangdavem330
authored andcommitted
net_sched: use tcf_queue_work() in bpf filter
Defer the tcf_exts_destroy() in RCU callback to tc filter workqueue and get RTNL lock. Reported-by: Chris Mi <[email protected]> Cc: Daniel Borkmann <[email protected]> Cc: Jiri Pirko <[email protected]> Cc: John Fastabend <[email protected]> Cc: Jamal Hadi Salim <[email protected]> Cc: "Paul E. McKenney" <[email protected]> Signed-off-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c96a483 commit e910af6

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

net/sched/cls_bpf.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ struct cls_bpf_prog {
4949
struct sock_filter *bpf_ops;
5050
const char *bpf_name;
5151
struct tcf_proto *tp;
52-
struct rcu_head rcu;
52+
union {
53+
struct work_struct work;
54+
struct rcu_head rcu;
55+
};
5356
};
5457

5558
static const struct nla_policy bpf_policy[TCA_BPF_MAX + 1] = {
@@ -257,9 +260,21 @@ static void __cls_bpf_delete_prog(struct cls_bpf_prog *prog)
257260
kfree(prog);
258261
}
259262

263+
static void cls_bpf_delete_prog_work(struct work_struct *work)
264+
{
265+
struct cls_bpf_prog *prog = container_of(work, struct cls_bpf_prog, work);
266+
267+
rtnl_lock();
268+
__cls_bpf_delete_prog(prog);
269+
rtnl_unlock();
270+
}
271+
260272
static void cls_bpf_delete_prog_rcu(struct rcu_head *rcu)
261273
{
262-
__cls_bpf_delete_prog(container_of(rcu, struct cls_bpf_prog, rcu));
274+
struct cls_bpf_prog *prog = container_of(rcu, struct cls_bpf_prog, rcu);
275+
276+
INIT_WORK(&prog->work, cls_bpf_delete_prog_work);
277+
tcf_queue_work(&prog->work);
263278
}
264279

265280
static void __cls_bpf_delete(struct tcf_proto *tp, struct cls_bpf_prog *prog)

0 commit comments

Comments
 (0)