Files
linux-stable-mirror/io_uring/loop.h
T
Pavel Begunkov ec02fe217f io_uring/bpf-ops: restrict ctx access to BPF
BPF programs should have no need in looking into struct io_ring_ctx, if
anything, most of such cases would be anti patterns like looking up ring
indices directly via the context.

Replace it with a new empty structure, which is just an alias to struct
io_ring_ctx. It'll create a new BTF type and fail verification if a BPF
program tries to access it (beyond the first byte). It'll also give more
flexibility for the future, and otherwise it can be made aligned with
io_ring_ctx as before with struct groups if ever needed or extended in a
different way.

Fixes: d0e437b76b ("io_uring/bpf-ops: implement loop_step with BPF struct_ops")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://patch.msgid.link/5f6ca3649e9e0bae8667db4357e28dd00cd07901.1780394491.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2026-06-02 11:20:21 -06:00

38 lines
689 B
C

// SPDX-License-Identifier: GPL-2.0
#ifndef IOU_LOOP_H
#define IOU_LOOP_H
#include <linux/io_uring_types.h>
struct iou_loop_params {
/*
* The CQE index to wait for. Only serves as a hint and can still be
* woken up earlier.
*/
__u32 cq_wait_idx;
};
enum {
IOU_LOOP_CONTINUE = 0,
IOU_LOOP_STOP,
};
static inline bool io_has_loop_ops(struct io_ring_ctx *ctx)
{
return data_race(ctx->loop_step);
}
int io_run_loop(struct io_ring_ctx *ctx);
static inline struct iou_ctx *io_loop_mangle_ctx(struct io_ring_ctx *ctx)
{
return (struct iou_ctx *)ctx;
}
static inline struct io_ring_ctx *io_loop_demangle_ctx(struct iou_ctx *ctx)
{
return (struct io_ring_ctx *)ctx;
}
#endif