Skip to content

Commit

Permalink
io/channel-socket: qio_channel_socket_flush(): improve msg validation
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Vladimir Sementsov-Ogievskiy authored and pm215 committed Nov 6, 2023
1 parent 59a3aff commit 35bafa9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions io/channel-socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 35bafa9

Please sign in to comment.