[PATCH v2 00/14] net, hw/net: Validate header lengths and harden packet handling

Akihiko Odaki posted 14 patches 1 week, 6 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20261109-eth-v2-0-334cc08e2f2e@rsg.ci.i.u-tokyo.ac.jp
Maintainers: Dmitry Fleytman <dmitry.fleytman@gmail.com>, Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>, Jason Wang <jasowangio@gmail.com>
include/net/eth.h   |   4 +-
hw/net/net_rx_pkt.c |  22 +++++----
hw/net/net_tx_pkt.c |  20 ++++++++-
net/eth.c           | 125 ++++++++++++++++++++++++++++++++++++++++++----------
4 files changed, 137 insertions(+), 34 deletions(-)
[PATCH v2 00/14] net, hw/net: Validate header lengths and harden packet handling
Posted by Akihiko Odaki 1 week, 6 days ago
Supersedes: <20261102201828.1879576-1-peter.maydell@linaro.org>
("[PATCH 00/11] net, hw/net: Harden common code against bogus offsets")

This 14-patch revision combines the IPv6 parser fixes from v1 with ten
patches from Peter Maydell's networking hardening series.

The series tightens L2, IPv4, TCP and SCTP header bounds checks. It also
corrects IPv6 Fragment and Authentication Header lengths and stops
parsing extension headers in noninitial fragments. The checksum and
segmentation changes guard against length underflows, invalid GSO sizes
and header-length overflow.

The Type 2 Routing Header length check is also moved into the RSS
destination address helper, alongside the Routing Type and Segments Left
checks.

The IPv4 and TCP bounds checks precede the IPv6 parser fixes, so that
correcting an IPv6 header offset does not expose an unchecked TCP data
offset to callers.

The IPv6 parser fixes replace Peter's separate IPv6 bounds-check patch.

Both this series and the igb patch series [1] have been stalled on the
mailing list for a while. Jason used to submit pull requests for
network patches like these, but he hasn't been active recently. Could
someone please pick these up?

[1] https://lore.kernel.org/qemu-devel/20260623-igb-trl-v8-0-c9b1fc6c3304@google.com/

Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
---
Changes in v2:
- Split the IPv4 and TCP bounds checks from the IPv6 parser fixes.
- Add L2 offset and header-length bounds checks.
- Adopt Peter's IPv4 checks, including the minimum header length, and
  use subtraction for the IPv4 and TCP bounds checks.
- Incorporate Peter's related parser, checksum and segmentation
  hardening patches, correcting the SCTP header-presence condition.
- Move the Type 2 Routing Header length check into the RSS destination
  address helper, alongside the Routing Type and Segments Left checks.
- Add comments explaining the Fragment and Authentication Header length
  rules and why parsing stops at noninitial fragments.
- Link to v1: https://lore.kernel.org/qemu-devel/20260920-eth-v1-1-ddd05ce24843@rsg.ci.i.u-tokyo.ac.jp

---
Akihiko Odaki (4):
      net/eth.c: Check for undersized L2 headers in eth_get_protocols()
      net/eth.c: In eth_get_protocols(), don't report TCP data offset off end of packet
      net/eth.c: In eth_parse_ipv6_hdr(), fix check of input size
      net/eth.c: Move the Routing Header Hdr Ext Len check

Peter Maydell (10):
      hw/net/net_rx_pkt: Handle bogus l4hdr_off when validating SCTP checksum
      net/eth.c: Check for undersized IPv4 headers in eth_get_protocols()
      net/eth.c: In eth_get_protocols(), don't report SCTP header off end of packet
      net/eth.c: Harden _eth_tcp_has_data() against short lengths
      net/eth.c: Tighten size checks in eth_get_l3_proto()
      include/net/eth.h: Make eth_get_l2_hdr_length_iov() check protocol
      hw/net/net_tx_pkt: Sanity check GSO headers in net_tx_pkt_build_vheader()
      hw/net/net_tx_pkt: Sanity check virt hdr len in net_tx_tcp_fragment_init
      hw/net/net_tx_pkt: Sanity check L2+L3 header len in net_tx_pkt_parse_headers()
      hw/net/net_rx_pkt: Check for overflow in _net_rx_pkt_calc_l4_csum()

 include/net/eth.h   |   4 +-
 hw/net/net_rx_pkt.c |  22 +++++----
 hw/net/net_tx_pkt.c |  20 ++++++++-
 net/eth.c           | 125 ++++++++++++++++++++++++++++++++++++++++++----------
 4 files changed, 137 insertions(+), 34 deletions(-)
---
base-commit: 74f7bf4c59e6b6d50dbc6e124d93440be8be4386
change-id: 20260920-eth-022349fda27e

Best regards,
--  
Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Re: [PATCH v2 00/14] net, hw/net: Validate header lengths and harden packet handling
Posted by Peter Maydell 1 week, 5 days ago
On Mon, 9 Nov 2026 at 05:31, Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> wrote:
>
> Supersedes: <20261102201828.1879576-1-peter.maydell@linaro.org>
> ("[PATCH 00/11] net, hw/net: Harden common code against bogus offsets")
>
> This 14-patch revision combines the IPv6 parser fixes from v1 with ten
> patches from Peter Maydell's networking hardening series.

> Both this series and the igb patch series [1] have been stalled on the
> mailing list for a while. Jason used to submit pull requests for
> network patches like these, but he hasn't been active recently. Could
> someone please pick these up?
>
> [1] https://lore.kernel.org/qemu-devel/20260623-igb-trl-v8-0-c9b1fc6c3304@google.com/

I'm happy to pick these two series up via target-arm.next if nobody
else objects.

thanks
-- PMM
Re: [PATCH v2 00/14] net, hw/net: Validate header lengths and harden packet handling
Posted by Peter Maydell 1 week, 3 days ago
On Tue, 10 Nov 2026 at 15:56, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> On Mon, 9 Nov 2026 at 05:31, Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> wrote:
> >
> > Supersedes: <20261102201828.1879576-1-peter.maydell@linaro.org>
> > ("[PATCH 00/11] net, hw/net: Harden common code against bogus offsets")
> >
> > This 14-patch revision combines the IPv6 parser fixes from v1 with ten
> > patches from Peter Maydell's networking hardening series.
>
> > Both this series and the igb patch series [1] have been stalled on the
> > mailing list for a while. Jason used to submit pull requests for
> > network patches like these, but he hasn't been active recently. Could
> > someone please pick these up?
> >
> > [1] https://lore.kernel.org/qemu-devel/20260623-igb-trl-v8-0-c9b1fc6c3304@google.com/
>
> I'm happy to pick these two series up via target-arm.next if nobody
> else objects.

I have applied these to target-arm.next since between us we've given
them all reviewed-by tags, and expect to send a pullreq by Monday.
Shout if you'd rather have more time to look at them or prefer
them to go via a different route, and I'll drop them.

thanks
-- PMM