io_uring/bpf_filter: mark source as COW when cloning filters

io_bpf_filter_clone() shares the filter table between source and
destination and marks the destination as needing a copy before it can be
modified, but leaves the source as is. Registering another filter on the
source then modifies the shared table in place, and the change shows up
in everything that cloned it.

Mark the source as COW as well.

Fixes: ed82f35b92 ("io_uring: allow registration of per-task restrictions")
Assisted-by: LLM
Signed-off-by: Hui Peng <[email protected]>
Link: https://patch.msgid.link/[email protected]
[axboe: edited patch and commit message]
Signed-off-by: Jens Axboe <[email protected]>
This commit is contained in:
Hui Peng
2026-09-21 10:50:04 -06:00
committed by Jens Axboe
parent 47ccc3f1c6
commit 50b617ba78
+1
View File
@@ -253,6 +253,7 @@ void io_bpf_filter_clone(struct io_restriction *dst, struct io_restriction *src)
* If the src filter is going away, just ignore it.
*/
if (refcount_inc_not_zero(&src->bpf_filters->refs)) {
src->bpf_filters_cow = true;
dst->bpf_filters = src->bpf_filters;
dst->bpf_filters_cow = true;
}