Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring/bpf_filter: add ref counts to struct io_bpf_filter

In preparation for allowing inheritance of BPF filters and filter
tables, add a reference count to the filter. This allows multiple tables
to safely include the same filter.

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

+7
+7
io_uring/bpf_filter.c
··· 15 15 #include "openclose.h" 16 16 17 17 struct io_bpf_filter { 18 + refcount_t refs; 18 19 struct bpf_prog *prog; 19 20 struct io_bpf_filter *next; 20 21 }; ··· 126 125 */ 127 126 if (f == &dummy_filter) 128 127 break; 128 + 129 + /* Someone still holds a ref, stop iterating. */ 130 + if (!refcount_dec_and_test(&f->refs)) 131 + break; 132 + 129 133 bpf_prog_destroy(f->prog); 130 134 kfree(f); 131 135 f = next; ··· 304 298 ret = -ENOMEM; 305 299 goto err; 306 300 } 301 + refcount_set(&filter->refs, 1); 307 302 filter->prog = prog; 308 303 res->bpf_filters = filters; 309 304