Skip to content

Conversation

@joe-redpanda
Copy link

Backport of a74d64f
With the modifications for the future api version cut out.

This assert has baked long enough to be reasonable to backport

Posix stack's data_sink implementation stores a net packet locally and
passes it by reference to the file descriptor.

If put is called concurrently, UB can occur.
With two invocations, one faster and one slower the faster invocation
will reset the packet on completion of its write_all invocation, and
the slower may dereference a nullptr in using the referenced packet

This commit changes three things:
1. it initializes the net::packet in posix_data_sink_impl to a null
   packet
2. reset of posix_data_sink_impl's net::packet will now occur in a
   finally s.t. the contained packet will also be reset on excpetions
3. invocation of posix_data_sink_impl::put will now assert that the
   contained packet is null before overwriting.

Any concurrent usages should now fail on an assert.

Closes scylladb#3147
Copilot AI review requested due to automatic review settings January 16, 2026 23:05
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR back-ports a packet assertion and error handling improvement from v26.1.x to detect and prevent potential double-write scenarios in the POSIX network stack implementation.

Changes:

  • Added an assertion to catch double-write attempts before they occur
  • Changed error handling from then to finally to ensure cleanup happens in all cases
  • Initialized _p member variable to a null packet state

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/net/posix-stack.cc Added assertion to detect concurrent writes and improved cleanup reliability by switching to finally
include/seastar/net/posix-stack.hh Initialized _p member to null packet state to support the new assertion

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant