Skip to content

Commit 3e05b22

Browse files
krismanaxboe
authored andcommitted
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: 66f4af9 ("io_uring: add support for probing opcodes") Signed-off-by: Gabriel Krisman Bertazi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent ff140cc commit 3e05b22

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

io_uring/opdef.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,14 @@ const char *io_uring_get_opcode(u8 opcode)
751751
return "INVALID";
752752
}
753753

754+
bool io_uring_op_supported(u8 opcode)
755+
{
756+
if (opcode < IORING_OP_LAST &&
757+
io_issue_defs[opcode].prep != io_eopnotsupp_prep)
758+
return true;
759+
return false;
760+
}
761+
754762
void __init io_uring_optable_init(void)
755763
{
756764
int i;

io_uring/opdef.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ struct io_issue_def {
1717
unsigned poll_exclusive : 1;
1818
/* op supports buffer selection */
1919
unsigned buffer_select : 1;
20-
/* opcode is not supported by this kernel */
21-
unsigned not_supported : 1;
2220
/* skip auditing */
2321
unsigned audit_skip : 1;
2422
/* supports ioprio */
@@ -47,5 +45,7 @@ struct io_cold_def {
4745
extern const struct io_issue_def io_issue_defs[];
4846
extern const struct io_cold_def io_cold_defs[];
4947

48+
bool io_uring_op_supported(u8 opcode);
49+
5050
void io_uring_optable_init(void);
5151
#endif

io_uring/register.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static __cold int io_probe(struct io_ring_ctx *ctx, void __user *arg,
5959

6060
for (i = 0; i < nr_args; i++) {
6161
p->ops[i].op = i;
62-
if (!io_issue_defs[i].not_supported)
62+
if (io_uring_op_supported(i))
6363
p->ops[i].flags = IO_URING_OP_SUPPORTED;
6464
}
6565
p->ops_len = i;

0 commit comments

Comments
 (0)