void io_uring_unreg_ringfd(void)
{ struct io_uring_task *tctx = current->io_uring; int i;
for (i = 0; i < IO_RINGFD_REG_MAX; i++) { if (tctx->registered_rings[i]) {
fput(tctx->registered_rings[i]);
tctx->registered_rings[i] = NULL;
}
}
}
int io_ring_add_registered_file(struct io_uring_task *tctx, struct file *file, int start, int end)
{ int offset; for (offset = start; offset < end; offset++) {
offset = array_index_nospec(offset, IO_RINGFD_REG_MAX); if (tctx->registered_rings[offset]) continue;
if (!nr_args || nr_args > IO_RINGFD_REG_MAX) return -EINVAL;
mutex_unlock(&ctx->uring_lock);
ret = __io_uring_add_tctx_node(ctx);
mutex_lock(&ctx->uring_lock); if (ret) return ret;
tctx = current->io_uring; for (i = 0; i < nr_args; i++) { int start, end;
if (copy_from_user(®, &arg[i], sizeof(reg))) {
ret = -EFAULT; break;
}
if (reg.resv) {
ret = -EINVAL; break;
}
if (reg.offset == -1U) {
start = 0;
end = IO_RINGFD_REG_MAX;
} else { if (reg.offset >= IO_RINGFD_REG_MAX) {
ret = -EINVAL; break;
}
start = reg.offset;
end = start + 1;
}
ret = io_ring_add_registered_fd(tctx, reg.data, start, end); if (ret < 0) break;
reg.offset = ret; if (copy_to_user(&arg[i], ®, sizeof(reg))) {
fput(tctx->registered_rings[reg.offset]);
tctx->registered_rings[reg.offset] = NULL;
ret = -EFAULT; break;
}
}
return i ? i : ret;
}
int io_ringfd_unregister(struct io_ring_ctx *ctx, void __user *__arg, unsigned nr_args)
{ struct io_uring_rsrc_update __user *arg = __arg; struct io_uring_task *tctx = current->io_uring; struct io_uring_rsrc_update reg; int ret = 0, i;
if (!nr_args || nr_args > IO_RINGFD_REG_MAX) return -EINVAL; if (!tctx) return0;
for (i = 0; i < nr_args; i++) { if (copy_from_user(®, &arg[i], sizeof(reg))) {
ret = -EFAULT; break;
} if (reg.resv || reg.data || reg.offset >= IO_RINGFD_REG_MAX) {
ret = -EINVAL; break;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.