qemu-patch-raspberry4/net
Jason Wang b528bb2840 net: drop too large packet early
We try to detect and drop too large packet (>INT_MAX) in 1592a99470
("net: ignore packet size greater than INT_MAX") during packet
delivering. Unfortunately, this is not sufficient as we may hit
another integer overflow when trying to queue such large packet in
qemu_net_queue_append_iov():

- size of the allocation may overflow on 32bit
- packet->size is integer which may overflow even on 64bit

Fixing this by moving the check to qemu_sendv_packet_async() which is
the entrance of all networking codes and reduce the limit to
NET_BUFSIZE to be more conservative. This works since:

- For the callers that call qemu_sendv_packet_async() directly, they
  only care about if zero is returned to determine whether to prevent
  the source from producing more packets. A callback will be triggered
  if peer can accept more then source could be enabled. This is
  usually used by high speed networking implementation like virtio-net
  or netmap.
- For the callers that call qemu_sendv_packet() that calls
  qemu_sendv_packet_async() indirectly, they often ignore the return
  value. In this case qemu will just the drop packets if peer can't
  receive.

Qemu will copy the packet if it was queued. So it was safe for both
kinds of the callers to assume the packet was sent.

Since we move the check from qemu_deliver_packet_iov() to
qemu_sendv_packet_async(), it would be safer to make
qemu_deliver_packet_iov() static to prevent any external user in the
future.

This is a revised patch of CVE-2018-17963.

Cc: qemu-stable@nongnu.org
Cc: Li Qiang <liq3ea@163.com>
Fixes: 1592a99470 ("net: ignore packet size greater than INT_MAX")
Reported-by: Li Qiang <liq3ea@gmail.com>
Reviewed-by: Li Qiang <liq3ea@gmail.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-id: 20181204035347.6148-2-jasowang@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit 25c01bd19d)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
2019-04-01 20:36:21 -05:00
..
can object: fix OBJ_PROP_LINK_UNREF_ON_RELEASE ambivalence 2018-06-12 12:07:30 +02:00
Makefile.objs net/can: simple messages transport implementation for QEMU 2018-02-13 11:44:13 +01:00
checksum.c net: optimize checksum computation 2017-01-20 10:36:38 +08:00
clients.h Drop superfluous includes of qapi-types.h and test-qapi-types.h 2018-02-09 05:05:11 +01:00
colo-compare.c object: fix OBJ_PROP_LINK_UNREF_ON_RELEASE ambivalence 2018-06-12 12:07:30 +02:00
colo.c colo: use local path for local headers 2018-06-01 19:20:38 +03:00
colo.h colo: compare the packet based on the tcp sequence number 2018-01-29 16:05:37 +08:00
dump.c net: Remove the deprecated way of dumping network packets 2018-03-05 10:30:15 +08:00
eth.c net/eth: fix incorrect check of iov_to_buf() return value 2017-07-31 13:06:38 +03:00
filter-buffer.c qapi: Move qapi-schema.json to qapi/, rename generated files 2018-03-02 13:45:57 -06:00
filter-mirror.c Include less of the generated modular QAPI headers 2018-03-02 13:45:50 -06:00
filter-replay.c Include qapi/error.h exactly where needed 2018-02-09 13:50:17 +01:00
filter-rewriter.c colo: use local path for local headers 2018-06-01 19:20:38 +03:00
filter.c qapi: Change data type of the FOO_lookup generated for enum FOO 2017-09-04 13:09:13 +02:00
hub.c net: Get rid of 'vlan' terminology and use 'hub' instead in the source files 2018-05-14 15:47:14 +08:00
hub.h net: Allow hubports to connect to other netdevs 2018-01-29 16:05:37 +08:00
l2tpv3.c qapi: Change Netdev into a flat union 2016-07-19 20:18:02 +02:00
net.c net: drop too large packet early 2019-04-01 20:36:21 -05:00
netmap.c qapi: Change Netdev into a flat union 2016-07-19 20:18:02 +02:00
queue.c net: Clean up includes 2016-02-04 17:41:30 +00:00
slirp.c slirp: Add sanity check for str option length 2019-03-21 15:47:26 -05:00
socket.c net/socket: fix coverity issue 2017-11-13 18:05:12 +08:00
tap-bsd.c tap-bsd: OpenBSD uses tap(4) now 2016-10-26 09:57:59 +08:00
tap-linux.c Convert error_report() to warn_report() 2017-07-13 13:49:58 +02:00
tap-linux.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
tap-solaris.c util: move declarations out of qemu-common.h 2016-03-22 22:20:17 +01:00
tap-stub.c net/tap: Replace tap-haiku.c and tap-aix.c by a generic tap-stub.c 2017-05-23 10:10:38 +08:00
tap-win32.c qapi: Change Netdev into a flat union 2016-07-19 20:18:02 +02:00
tap.c tap: fix memory leak on success to create a tap device 2018-07-20 08:30:49 +08:00
tap_int.h Include less of the generated modular QAPI headers 2018-03-02 13:45:50 -06:00
trace-events colo: compare the packet based on the tcp sequence number 2018-01-29 16:05:37 +08:00
util.c net: Clean up includes 2016-02-04 17:41:30 +00:00
util.h all: Clean up includes 2016-02-23 12:43:05 +00:00
vde.c net/vde: print error on vde_open() failure 2018-03-26 14:52:43 +08:00
vhost-user.c vhost-user: delete net client if necessary 2018-06-15 10:39:53 +08:00