Commit 3e05b222 authored by Gabriel Krisman Bertazi's avatar Gabriel Krisman Bertazi Committed by Jens Axboe

io_uring: Fix probe of disabled operations

io_probe checks io_issue_def->not_supported, but we never really set
that field, as we mark non-supported functions through a specific ->prep
handler.  This means we end up returning IO_URING_OP_SUPPORTED, even for
disabled operations.  Fix it by just checking the prep handler itself.

Fixes: 66f4af93 ("io_uring: add support for probing opcodes")
Signed-off-by: default avatarGabriel Krisman Bertazi <krisman@suse.de>
Link: https://lore.kernel.org/r/20240619020620.5301-2-krisman@suse.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent ff140cc8
...@@ -751,6 +751,14 @@ const char *io_uring_get_opcode(u8 opcode) ...@@ -751,6 +751,14 @@ const char *io_uring_get_opcode(u8 opcode)
return "INVALID"; return "INVALID";
} }
bool io_uring_op_supported(u8 opcode)
{
if (opcode < IORING_OP_LAST &&
io_issue_defs[opcode].prep != io_eopnotsupp_prep)
return true;
return false;
}
void __init io_uring_optable_init(void) void __init io_uring_optable_init(void)
{ {
int i; int i;
......
...@@ -17,8 +17,6 @@ struct io_issue_def { ...@@ -17,8 +17,6 @@ struct io_issue_def {
unsigned poll_exclusive : 1; unsigned poll_exclusive : 1;
/* op supports buffer selection */ /* op supports buffer selection */
unsigned buffer_select : 1; unsigned buffer_select : 1;
/* opcode is not supported by this kernel */
unsigned not_supported : 1;
/* skip auditing */ /* skip auditing */
unsigned audit_skip : 1; unsigned audit_skip : 1;
/* supports ioprio */ /* supports ioprio */
...@@ -47,5 +45,7 @@ struct io_cold_def { ...@@ -47,5 +45,7 @@ struct io_cold_def {
extern const struct io_issue_def io_issue_defs[]; extern const struct io_issue_def io_issue_defs[];
extern const struct io_cold_def io_cold_defs[]; extern const struct io_cold_def io_cold_defs[];
bool io_uring_op_supported(u8 opcode);
void io_uring_optable_init(void); void io_uring_optable_init(void);
#endif #endif
...@@ -59,7 +59,7 @@ static __cold int io_probe(struct io_ring_ctx *ctx, void __user *arg, ...@@ -59,7 +59,7 @@ static __cold int io_probe(struct io_ring_ctx *ctx, void __user *arg,
for (i = 0; i < nr_args; i++) { for (i = 0; i < nr_args; i++) {
p->ops[i].op = i; p->ops[i].op = i;
if (!io_issue_defs[i].not_supported) if (io_uring_op_supported(i))
p->ops[i].flags = IO_URING_OP_SUPPORTED; p->ops[i].flags = IO_URING_OP_SUPPORTED;
} }
p->ops_len = i; p->ops_len = i;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment