OSDN Git Service

io/channel-socket: qio_channel_socket_flush(): improve msg validation
authorVladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Mon, 6 Nov 2023 15:00:28 +0000 (15:00 +0000)
committerPeter Maydell <peter.maydell@linaro.org>
Mon, 6 Nov 2023 15:00:28 +0000 (15:00 +0000)
For SO_EE_ORIGIN_ZEROCOPY the 32-bit notification range is encoded
as [ee_info, ee_data] inclusively, so ee_info should be less or
equal to ee_data.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Maksim Davydov <davydov-max@yandex-team.ru>
Message-id: 20231017125941.810461-7-vsementsov@yandex-team.ru
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
io/channel-socket.c

index 02ffb51..3a899b0 100644 (file)
@@ -782,6 +782,11 @@ static int qio_channel_socket_flush(QIOChannel *ioc,
                              "Error not from zero copy");
             return -1;
         }
+        if (serr->ee_data < serr->ee_info) {
+            error_setg_errno(errp, serr->ee_origin,
+                             "Wrong notification bounds");
+            return -1;
+        }
 
         /* No errors, count successfully finished sendmsg()*/
         sioc->zero_copy_sent += serr->ee_data - serr->ee_info + 1;