]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
io_uring/net: fail zc send when unsupported by socket
authorPavel Begunkov <asml.silence@gmail.com>
Fri, 21 Oct 2022 10:16:40 +0000 (11:16 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Oct 2022 10:22:55 +0000 (12:22 +0200)
commit edf81438799ccead7122948446d7e44b083e788d upstream.

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.

Cc: <stable@vger.kernel.org> # 6.0
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/2db3c7f16bb6efab4b04569cd16e6242b40c5cb3.1666346426.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
io_uring/net.c

index 4878bf40f8b1c6bf34526afc7f546c545447c61c..7804ac77745b15ffdb6654d9500c5a74d0ee6f4c 100644 (file)
@@ -1001,6 +1001,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 (!test_bit(SOCK_SUPPORT_ZC, &sock->flags))
+               return -EOPNOTSUPP;
 
        msg.msg_name = NULL;
        msg.msg_control = NULL;