History

io_uring/bpf_filters: retain COW'ed settings on parse failures

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.

Jens Axboe committed 7 months ago

Commit aa35dd61 parent 61a11cf1 file · +9 −1Browse files

Unified · Split

io_uring/register.c+9−1
@@ -178,9 +178,17 @@ static __cold int io_register_restrictions(struct io_ring_ctx *ctx, · 177 unmodified lines
178178 return -EBUSY;
179179
180180 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+ */
182185 if (ret < 0) {
186+ struct io_bpf_filters *bpf = ctx->restrictions.bpf_filters;
187+ bool cowed = ctx->restrictions.bpf_filters_cow;
188+
183189 memset(&ctx->restrictions, 0, sizeof(ctx->restrictions));
190+ ctx->restrictions.bpf_filters = bpf;
191+ ctx->restrictions.bpf_filters_cow = cowed;
184192 return ret;
185193 }
186194 if (ctx->restrictions.op_registered)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t