[PATCH v2 for-11.2 0/3] net: Consistently pad short packets for all backends

Peter Maydell posted 3 patches 1 week, 5 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20261110180655.2072265-1-peter.maydell@linaro.org
Maintainers: Dmitry Fleytman <dmitry.fleytman@gmail.com>, Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>, Jason Wang <jasowangio@gmail.com>, Samuel Thibault <samuel.thibault@ens-lyon.org>, Stefan Weil <sw@weilnetz.de>, "Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>, Zhang Chen <zhangckid@gmail.com>, Li Zhijian <lizhijian@fujitsu.com>, Fabiano Rosas <farosas@suse.de>, Laurent Vivier <lvivier@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
include/net/eth.h                    | 22 +++++++++++++++++++
include/net/net.h                    |  3 ++-
net/eth.c                            | 18 ++++++++++++++++
net/net.c                            | 32 ++++++++++++++++++++++++----
net/slirp.c                          |  9 --------
net/tap-win32.c                      | 15 ++-----------
net/tap.c                            | 11 +---------
tests/qtest/test-filter-buffer.c     |  4 +++-
tests/qtest/test-filter-mirror.c     |  4 +++-
tests/qtest/test-filter-redirector.c |  4 +++-
net/vmnet-common.m                   | 11 ----------
11 files changed, 82 insertions(+), 51 deletions(-)
[PATCH v2 for-11.2 0/3] net: Consistently pad short packets for all backends
Posted by Peter Maydell 1 week, 5 days ago
Changes v1->v2:
 * squashed old patches 2 and 3 together -- this fixes the
   problem Akihiko noted where patch 2 makes us stop padding
   packets going backend -> hub -> device before patch 3
   puts the padding back again, and also means that you can't
   accidentally cherry-pick the CVE-tagged commit without the
   required changes that used to be in patch 2
 * added reviewed-by tags and CVE tag

Patches 1 and 2 are reviewed and ready to go in (they are the
actual fix); patch 3 still needs review but it's just the
tidy up of now-unnecessary code.


Cover letter text below is same as for v1:

The net core code design is that by default packets are padded out to
the ethernet frame minimum before being handed to a network device
model, unless that device explicitly opted in by setting do_not_pad.
This avoids a whole class of bugs where network device receive code
has to be very careful about handling short packets.

However, at the moment we do this check manually in the network
backend code before it calls qemu_send_packet() or
qemu_send_packet_async(), and we forgot to do it in all backends.  So
you get the padding for the slirp, tap and vmnet backends, but not
for the "minor" backends like 'passt', 'socket' and 'dgram', or if
you configure two network devices connected by an emulated hub.

This series fixes this by moving the padding code to
qemu_send_packet()/qemu_sendv_packet(), so that it always happens
regardless of the backend.

The main bug this is fixing is
https://gitlab.com/qemu-project/qemu/-/work_items/2362
but it's been re-reported multiple times for various combinations
of network devices and backends.

The whole series is cc stable because without the padding you can
provoke various bugs in different network device models.

thanks
-- PMM


Peter Maydell (3):
  tests/qtest: Make netfilter tests accept padded ethernet packets
  net: Set do_not_pad for net backends
  net: Remove padding code from net backends

 include/net/eth.h                    | 22 +++++++++++++++++++
 include/net/net.h                    |  3 ++-
 net/eth.c                            | 18 ++++++++++++++++
 net/net.c                            | 32 ++++++++++++++++++++++++----
 net/slirp.c                          |  9 --------
 net/tap-win32.c                      | 15 ++-----------
 net/tap.c                            | 11 +---------
 tests/qtest/test-filter-buffer.c     |  4 +++-
 tests/qtest/test-filter-mirror.c     |  4 +++-
 tests/qtest/test-filter-redirector.c |  4 +++-
 net/vmnet-common.m                   | 11 ----------
 11 files changed, 82 insertions(+), 51 deletions(-)

-- 
2.43.0