The ipf module calculates fragment bounds with uint16_t, that can be
wrapped around, causing access to invalid memory.  Fix it.

Patch 1 is a test-only change.  Patch 2 is a kernel alignment: exact
duplicates are dropped, as the kernel does.

Patch 3 drops the whole datagram on overlap for IPv4 and IPv6 alike
(RFC 5722 / RFC 8200).  RFC 791 allows IPv4 reassembly but it is not a
must.  For simplicity we treat IPv4/IPv6 the same.

Rejected fragments are dropped instead of forwarded with ct_state=invalid,
to align userspace with the kernel.  The kernel already does not give
these fragments to the controller.

For backports:
Patches 1-3 are not bugfixes and should not be backported.
Patch 4 ("ipf: Reject IPv4/v6 fragments with wrapping bounds.") should
be backported.  Wrapped bounds corrupt the reassembly buffer.  It does
not depend on the other patches.
Patch 5 ("ipf: Reject fragments beyond the last fragment.") should be
backported.  Data past an MF=0 fragment was accepted.  It is on top
of patches 2 and 3.  A backport might either pull them too or
adapt it to keep the old ct_state=invalid behaviour.

v3-v2:
- Added ipf: Drop overlap fragments.
- Added ofproto-dpif: Use strip_recirc in reassembly dump-flows checks.
- Zero-payload commit now focuses only on adding an additional byte to
  the test, as the new bounds commit would reject it otherwise.
- Wrapping bounds - separated checks for rest_len <= 0.

v4-v3:
- Added 2 more commits.
- Wrapping bounds - added a TOO_LARGE counter.

v5-v4:
- Added a test coverage for drop overlap fragments.
- Fixed a wrongly counted IPv6 too-large counter.
- Added BEYOND_LAST counter.

v6-v5:
- Overlap now drops the whole datagram.  Exact duplicates are dropped alone.
- Added RFC references in the code comments.

v7-v6:
- Added a DISCARDED counter.
- A last-fragment duplicate now completes the datagram.
- Reordered "Distinguish" before "Drop overlapping" to keep commits
  bisectable.
- Folded the zero-payload test commit into the wrapping-bounds and
  "Distinguish" commits.
- Added beyond-last tests (last seen second, IPv6).

v8-v7:
- Fixed the last-fragment duplicate handling.
- Added tests and clarified comments.

v9-v8:
- An exact duplicate no longer replaces the stored fragment.
- Added a system-traffic test that an exact duplicate is not forwarded
  on either datapath.
- Added NEWS notes.
- Other review comments addressed.
- Removed Fixes tags from patches 2 and 3.

Eli Britstein (5):
  ofproto-dpif: Use strip_recirc in reassembly dump-flows checks.
  ipf: Distinguish duplicate and overlapping fragments.
  ipf: Drop overlapping fragments and their datagram.
  ipf: Reject IPv4/v6 fragments with wrapping bounds.
  ipf: Reject fragments beyond the last fragment.

 NEWS                             |   5 +
 lib/dpctl.c                      |  16 +
 lib/dpif-provider.h              |   4 +
 lib/ipf.c                        | 218 ++++++++++--
 lib/ipf.h                        |   4 +
 tests/ofproto-dpif.at            | 577 +++++++++++++++++++++++++++++--
 tests/system-traffic.at          |  50 +++
 tests/system-userspace-macros.at |  32 ++
 8 files changed, 852 insertions(+), 54 deletions(-)

-- 
2.43.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to