If a protocol doesn't support zerocopy it will silently fall back to copying. This type of behaviour has always been a source of troubles so it's better to fail such requests instead. For now explicitly whitelist supported protocols in io_uring, which should be turned later into a socket flag. Cc: <stable@xxxxxxxxxxxxxxx> # 6.0 Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx> --- io_uring/net.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/io_uring/net.c b/io_uring/net.c index 8c7226b5bf41..28127f1de1f0 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -120,6 +120,13 @@ static void io_netmsg_recycle(struct io_kiocb *req, unsigned int issue_flags) } } +static inline bool io_sock_support_zc(struct socket *sock) +{ + return likely(sock->sk && sk_fullsock(sock->sk) && + (sock->sk->sk_protocol == IPPROTO_TCP || + sock->sk->sk_protocol == IPPROTO_UDP)); +} + static struct io_async_msghdr *io_msg_alloc_async(struct io_kiocb *req, unsigned int issue_flags) { @@ -1056,6 +1063,8 @@ int io_send_zc(struct io_kiocb *req, unsigned int issue_flags) sock = sock_from_file(req->file); if (unlikely(!sock)) return -ENOTSOCK; + if (!io_sock_support_zc(sock)) + return -EOPNOTSUPP; msg.msg_name = NULL; msg.msg_control = NULL; -- 2.38.0