[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
Only 0 patches received!
There is a newer version of this series
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
Re: [PATCH v2 for-11.2 0/3] net: Consistently pad short packets for all backends
Posted by Peter Maydell 1 week, 3 days ago
On Tue, 10 Nov 2026 at 18:06, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> 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.

In fact patch 3 was reviewed and I just missed that it had
been (the patch in this series has the r-by tag because
my tooling spotted it even if I didn't :-)). So I'm going
to queue these via target-arm.next for a pullreq I plan
to send out by Monday, as they are a CVE fix and I think we
should get them in sooner rather than later.

Shout if you'd rather have more time or would prefer them
to go via a different route.

thanks
-- PMM