History

io_uring: ensure we return -EINVAL on unknown opcode

If we submit an unknown opcode and have fd == -1, io_op_needs_file() will return true as we default to needing a file. Then when we go and assign the file, we find the 'fd' invalid and return -EBADF. We really should be returning -EINVAL for that case, as we normally do for unsupported opcodes. Change io_op_needs_file() to have the following return values: 0 - does not need a file 1 - does need a file < 0 - error value and use this to pass back the right value for this invalid case.

Jens Axboe committed 6 years ago

Commit 9e3aa611 parent 10d59342 files · +36 −24Browse files

Showing the changes to include/uapi/linux (1 of 2 files). Show all

Unified · Split

include/uapi/linux/io_uring.h+22−17
@@ -58,23 +58,28 @@ struct io_uring_sqe { · 57 unmodified lines
58#define IORING_SETUP_SQ_AFF (1U << 2) /* sq_thread_cpu is valid */58#define IORING_SETUP_SQ_AFF (1U << 2) /* sq_thread_cpu is valid */
59#define IORING_SETUP_CQSIZE (1U << 3) /* app defines CQ size */59#define IORING_SETUP_CQSIZE (1U << 3) /* app defines CQ size */
60 60
61#define IORING_OP_NOP 061enum {
62#define IORING_OP_READV 162 IORING_OP_NOP,
63#define IORING_OP_WRITEV 263 IORING_OP_READV,
64#define IORING_OP_FSYNC 364 IORING_OP_WRITEV,
65#define IORING_OP_READ_FIXED 465 IORING_OP_FSYNC,
66#define IORING_OP_WRITE_FIXED 566 IORING_OP_READ_FIXED,
67#define IORING_OP_POLL_ADD 667 IORING_OP_WRITE_FIXED,
68#define IORING_OP_POLL_REMOVE 768 IORING_OP_POLL_ADD,
69#define IORING_OP_SYNC_FILE_RANGE 869 IORING_OP_POLL_REMOVE,
70#define IORING_OP_SENDMSG 970 IORING_OP_SYNC_FILE_RANGE,
71#define IORING_OP_RECVMSG 1071 IORING_OP_SENDMSG,
72#define IORING_OP_TIMEOUT 1172 IORING_OP_RECVMSG,
73#define IORING_OP_TIMEOUT_REMOVE 1273 IORING_OP_TIMEOUT,
74#define IORING_OP_ACCEPT 1374 IORING_OP_TIMEOUT_REMOVE,
75#define IORING_OP_ASYNC_CANCEL 1475 IORING_OP_ACCEPT,
76#define IORING_OP_LINK_TIMEOUT 1576 IORING_OP_ASYNC_CANCEL,
77#define IORING_OP_CONNECT 1677 IORING_OP_LINK_TIMEOUT,
78 IORING_OP_CONNECT,
79
80 /* this goes last, obviously */
81 IORING_OP_LAST,
82};
78 83
79/*84/*
80 * sqe->fsync_flags85 * sqe->fsync_flags