Skip to content

Commit

Permalink
io_uring: Fix probe of disabled operations
Browse files Browse the repository at this point in the history
BugLink: https://bugs.launchpad.net/bugs/2083196

[ Upstream commit 3e05b22 ]

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]>
Signed-off-by: Sasha Levin <[email protected]>
Signed-off-by: Portia Stephens <[email protected]>
Signed-off-by: Roxana Nicolescu <[email protected]>
  • Loading branch information
krisman authored and mehmetb0 committed Nov 9, 2024
1 parent 3adea29 commit e97096d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions io_uring/opdef.c
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,14 @@ const char *io_uring_get_opcode(u8 opcode)
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)
{
int i;
Expand Down
4 changes: 2 additions & 2 deletions io_uring/opdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ struct io_issue_def {
unsigned poll_exclusive : 1;
/* op supports buffer selection */
unsigned buffer_select : 1;
/* opcode is not supported by this kernel */
unsigned not_supported : 1;
/* skip auditing */
unsigned audit_skip : 1;
/* supports ioprio */
Expand Down Expand Up @@ -50,5 +48,7 @@ struct io_cold_def {
extern const struct io_issue_def io_issue_defs[];
extern const struct io_cold_def io_cold_defs[];

bool io_uring_op_supported(u8 opcode);

void io_uring_optable_init(void);
#endif
2 changes: 1 addition & 1 deletion io_uring/register.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static __cold int io_probe(struct io_ring_ctx *ctx, void __user *arg,

for (i = 0; i < nr_args; 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_len = i;
Expand Down

0 comments on commit e97096d

Please sign in to comment.