Skip to content

fix(net): store the checksum an incremental update computes - #1733

Draft
daniel-noland wants to merge 1 commit into
pr/daniel-noland/debug-imagesfrom
pr/daniel-noland/fuzz-net-checksum
Draft

fix(net): store the checksum an incremental update computes#1733
daniel-noland wants to merge 1 commit into
pr/daniel-noland/debug-imagesfrom
pr/daniel-noland/fuzz-net-checksum

Conversation

@daniel-noland

Copy link
Copy Markdown
Collaborator

First of five, stacked on #1724. Extracts the finished fuzzing campaign from
pr/daniel-noland/icmp-flow-lock, which was never opened as a PR and had
drifted well behind main.

This one is a production bug, on its own so it can be taken without the rest.

Checksum::increment_update_checksum works out the new checksum and hands it
back; it does not store it, despite taking &mut self.
EmbeddedTransport::update_checksum called it and dropped the answer, under a
comment about ignoring errors on a truncated header — but there is no error to
ignore, the return value is the checksum. So no quoted transport header has
ever had its checksum updated.

NAT rewrites the ports of the packet quoted inside an ICMP error and calls this
to keep the checksum in step. Receivers that validate the quoted checksum will
reject the error; that is the path PMTUD depends on. Plenty of stacks do not
validate it, which is likely why nothing has complained.

update_checksum_for_address is new, and folds a change of one of the quoted
packet's addresses in — TCP, UDP and ICMPv6 checksum over a pseudo-header built
from the addresses, so rewriting one leaves the quoted checksum describing an
address that is no longer there. ICMPv4 has no pseudo-header and is left alone.

Verified locally rather than in CI, given the outage: dataplane-net 473/473,
fmt --check and clippy -D warnings clean. Reverting the fix fails exactly
a_v4_address_change_matches_a_fresh_tcp_checksum and its v6/UDP twin.

🤖 Generated with Claude Code

@daniel-noland daniel-noland added the dont-merge Do not merge this Pull Request label Aug 17, 2026
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 484a7976-3da9-4734-a03b-719650568c01

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.20879% with 8 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
net/src/headers/embedded.rs 91.20% 6 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@daniel-noland
daniel-noland force-pushed the pr/daniel-noland/fuzz-net-checksum branch from 56e8187 to 61049ae Compare August 18, 2026 20:23
@daniel-noland
daniel-noland force-pushed the pr/daniel-noland/fuzz-net-checksum branch from 61049ae to dd6e234 Compare August 18, 2026 20:31
@daniel-noland
daniel-noland force-pushed the pr/daniel-noland/fuzz-net-checksum branch from dd6e234 to 1ba8747 Compare August 18, 2026 20:38
@daniel-noland
daniel-noland force-pushed the pr/daniel-noland/fuzz-net-checksum branch from 1ba8747 to 94cdc87 Compare August 18, 2026 23:17
@daniel-noland
daniel-noland force-pushed the pr/daniel-noland/fuzz-net-checksum branch 2 times, most recently from a9d9273 to 3268b44 Compare August 20, 2026 01:58
`Checksum::increment_update_checksum` works out the new checksum and
hands it back. It does not store it, despite taking `&mut self`.
`EmbeddedTransport::update_checksum` called it and dropped the answer on
the floor, under a comment about ignoring errors on a truncated header
-- but there is no error to ignore; the return value is the checksum.

So no quoted transport header has ever had its checksum updated. NAT
rewrites the ports of the packet quoted inside an ICMP error and calls
this to keep the checksum in step, and the call has been doing nothing.
The only correct uses of the trait method in the tree are in a test,
which is presumably how the shape survived.

Setting it can fail, on a header too truncated to hold a checksum -- but
that is a header the caller could not have read a checksum out of
either, and every caller reads one first. Hence discarding that error
rather than the value, which is what the comment was reaching for.

update_checksum_for_address is new, and folds a change of one of the
quoted packet's addresses in. TCP, UDP and ICMPv6 are checksummed over a
pseudo-header built from the source and destination addresses, so
rewriting one leaves the quoted checksum describing an address that is
no longer there. ICMPv4 has no pseudo-header and is left alone.
Incremental for the same reason as the rest: a quote is usually
truncated, so there is no payload to compute over from scratch.

The tests build the one case where both routes are open -- a full header
over a known payload -- and hold the fold against a computation from
scratch, over two words for v4 and eight for v6. The checksum starts out
correct on purpose: an RFC 1624 update is exact given a correct starting
value and says nothing given a wrong one. Both fail against the
discarded update; the ICMPv4 one passes either way, which is the point
of it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Daniel Noland <daniel@githedgehog.com>
@daniel-noland
daniel-noland force-pushed the pr/daniel-noland/fuzz-net-checksum branch from 3268b44 to d6c577e Compare August 20, 2026 02:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dont-merge Do not merge this Pull Request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant