If io_parse_restrictions() fails, it ends up clearing any restrictions currently set. The intent is only to clear whatever it already applied, but it ends up clearing everything, including whatever settings may have been applied in a copy-on-write fashion already. Ensure that those are retained.
Unified · Split
| @@ -178,9 +178,17 @@ static __cold int io_register_restrictions(struct io_ring_ctx *ctx, · 177 unmodified lines | ||
| 178 | 178 | return -EBUSY; |
| 179 | 179 | |
| 180 | 180 | ret = io_parse_restrictions(arg, nr_args, &ctx->restrictions); |
| 181 | − /* Reset all restrictions if an error happened */ | |
| 181 | + /* | |
| 182 | + * Reset all restrictions if an error happened, but retain any COW'ed | |
| 183 | + * settings. | |
| 184 | + */ | |
| 182 | 185 | if (ret < 0) { |
| 186 | + struct io_bpf_filters *bpf = ctx->restrictions.bpf_filters; | |
| 187 | + bool cowed = ctx->restrictions.bpf_filters_cow; | |
| 188 | + | |
| 183 | 189 | memset(&ctx->restrictions, 0, sizeof(ctx->restrictions)); |
| 190 | + ctx->restrictions.bpf_filters = bpf; | |
| 191 | + ctx->restrictions.bpf_filters_cow = cowed; | |
| 184 | 192 | return ret; |
| 185 | 193 | } |
| 186 | 194 | if (ctx->restrictions.op_registered) |