Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: a5d2f99aff6b ("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>

authored by

Asbjørn Sloth Tønnesen and committed by
Jens Axboe
600b665b 56112578

+6 -3
+6 -3
io_uring/cmd_net.c
··· 160 160 struct proto *prot = READ_ONCE(sk->sk_prot); 161 161 int ret, arg = 0; 162 162 163 - if (!prot || !prot->ioctl) 164 - return -EOPNOTSUPP; 165 - 166 163 switch (cmd->cmd_op) { 167 164 case SOCKET_URING_OP_SIOCINQ: 165 + if (!prot || !prot->ioctl) 166 + return -EOPNOTSUPP; 167 + 168 168 ret = prot->ioctl(sk, SIOCINQ, &arg); 169 169 if (ret) 170 170 return ret; 171 171 return arg; 172 172 case SOCKET_URING_OP_SIOCOUTQ: 173 + if (!prot || !prot->ioctl) 174 + return -EOPNOTSUPP; 175 + 173 176 ret = prot->ioctl(sk, SIOCOUTQ, &arg); 174 177 if (ret) 175 178 return ret;