Skip to content

Commit 600b665

Browse files
Asbjørn Sloth Tønnesenaxboe
authored andcommitted
io_uring/cmd_net: fix too strict requirement on ioctl
Attempting SOCKET_URING_OP_SETSOCKOPT on an AF_NETLINK socket resulted in an -EOPNOTSUPP, as AF_NETLINK doesn't have an ioctl in its struct proto, but only in struct proto_ops. Prior to the blamed commit, io_uring_cmd_sock() only had two cmd_op operations, both requiring ioctl, thus the check was warranted. Since then, 4 new cmd_op operations have been added, none of which depend on ioctl. This patch moves the ioctl check, so it only applies to the original operations. AFAICT, the ioctl requirement was unintentional, and it wasn't visible in the blamed patch within 3 lines of context. Cc: stable@vger.kernel.org Fixes: a5d2f99 ("io_uring/cmd: Introduce SOCKET_URING_OP_GETSOCKOPT") Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net> Reviewed-by: Gabriel Krisman Bertazi <krisman@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 5611257 commit 600b665

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

io_uring/cmd_net.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,19 @@ int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags)
160160
struct proto *prot = READ_ONCE(sk->sk_prot);
161161
int ret, arg = 0;
162162

163-
if (!prot || !prot->ioctl)
164-
return -EOPNOTSUPP;
165-
166163
switch (cmd->cmd_op) {
167164
case SOCKET_URING_OP_SIOCINQ:
165+
if (!prot || !prot->ioctl)
166+
return -EOPNOTSUPP;
167+
168168
ret = prot->ioctl(sk, SIOCINQ, &arg);
169169
if (ret)
170170
return ret;
171171
return arg;
172172
case SOCKET_URING_OP_SIOCOUTQ:
173+
if (!prot || !prot->ioctl)
174+
return -EOPNOTSUPP;
175+
173176
ret = prot->ioctl(sk, SIOCOUTQ, &arg);
174177
if (ret)
175178
return ret;

0 commit comments

Comments
 (0)