Add runtime-available interface bitmap; behavioral-correctness fixes#76
Merged
Conversation
Address seven findings from a correctness review of the transport core: - tx_free: assert no datagram references remain outstanding, and document that references retained via udpard_tx_refcount_inc() must be released before discarding the instance (prevents a use-after-free of the pipeline). - rx_session_eject: destroy the reassembly slot before invoking on_message() so a re-entrant udpard_rx_port_push() cannot evict and free the delivered payload (application-facing use-after-free). - tx_ensure_queue_space: guard the queue-vacancy subtraction against size_t underflow when enqueued_frames_limit is lowered below the in-flight count. - udpard_rx_poll: add a NULL self guard, mirroring udpard_tx_poll. - header_serialize: use UDPARD_ASSERT instead of raw assert(). - Document that only the head of a scattered TX payload is validated. - Fix the inverted now/deadline relation in the ejection doc comment. Add regression tests for the reassembly-reentrancy UAF and the queue-limit underflow, and a NULL-poll guard check; update test_tx_refcount_retention to release retained frames before udpard_tx_free(). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add udpard_tx_t.iface_bitmap, a runtime-mutable subset of UDPARD_IFACE_BITMAP_ALL naming the locally available interfaces; udpard_tx_new() gains a matching parameter (breaking change). Each push intersects the requested iface set with it, so transfer replicas are no longer enqueued for interfaces the application cannot drain (where they previously expired silently). Zero means listen-only. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1. Runtime-available interface bitmap (breaking API change)
udpard_tx_tgainsiface_bitmap— a runtime-mutable subset ofUDPARD_IFACE_BITMAP_ALLnaming the interfaces that exist locally — andudpard_tx_new()gains a matching parameter. Every push intersects the requested iface set with it, so transfer replicas are no longer enqueued for interfaces the application cannot drain (previously they sat queued until they expired). PassingUDPARD_IFACE_BITMAP_ALLis now correct regardless of interface count;0means listen-only. Init rejects a bitmap with bits beyondUDPARD_IFACE_BITMAP_ALL.Tests:
test_tx_iface_available_mask,test_tx_listen_only,test_tx_iface_bitmap_extra_bits, plus init-validation cases; all 22udpard_tx_newcall sites updated.2. Behavioral-correctness fixes (review findings)
udpard_tx_free()assertsenqueued_frames_count == 0; datagram refs fromudpard_tx_refcount_inc()must be released first.rx_session_eject()destroys the reassembly slot beforeon_message(), so a re-entrant push cannot free the in-flight slot.tx_queue_vacancy()guards thelimit - countsubtraction against underflow when the limit is lowered below the in-flight count.udpard_rx_poll()gains aself != NULLguard.header_serialize()usesUDPARD_ASSERT(); doc fixes (head-only payload validation, invertednow/deadline).Regression tests:
test_rx_reentrant_push_in_callback,test_tx_queue_limit_lowered_below_count,udpard_rx_poll(NULL, …)guard.Verification
Full suite green across x32/x64 × C99/C11 (Debug, assertions on); static-analysis (clang-tidy, warnings-as-errors) and
clang-formatclean.Warning
Breaking:
udpard_tx_new()takes a newiface_bitmapargument, andudpard_tx_free()now requires alludpard_tx_refcount_inc()datagram references to be released before the pipeline is discarded.🤖 Generated with Claude Code