Skip to content

Do signal-aware waits and meta snapshot#5

Merged
jserv merged 1 commit into
mainfrom
signal-aware
Jul 3, 2026
Merged

Do signal-aware waits and meta snapshot#5
jserv merged 1 commit into
mainfrom
signal-aware

Conversation

@jserv

@jserv jserv commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

dnsfs_query_record no longer re-waits uninterruptibly after a signal wakes wait_for_completion_interruptible. A signaled foreground waiter now returns -ERESTARTSYS at once, drops its reference, and reads no req fields (the worker may still be writing them). Safe by the existing refcount contract: the worker holds its own reference until after complete_all, so the shared coalesced request stays queued, still resolves, fills the cache, and wakes the other waiters; the last reference drop frees it. Adds test_signal_interrupt: a 3s-delayed resolver, SIGINT a cat once the wire query is observed, expect it to die within 1s.

dnsfs_storage_assemble_once and dnsfs_storage_read_range_once snapshot storage->meta and storage->epoch into locals before sizing buffers. The read path runs without storage->lock, so a concurrent re-pin could grow chunk_count or size between the allocation and the loop bound, a heap OOB write; the snapshot closes it. A torn generation is caught by epoch/CRC and retried.

dnsfs_query_tcp loops kernel_sendmsg until the whole framed query is sent (TCP is a byte stream) and fails a zero-length send; dnsfs_query_udp_once requires the datagram send to report the ful length.


Summary by cubic

Make DNS queries signal-aware and harden send/read paths. Interrupted reads return fast, storage reads snapshot metadata to avoid races, and TCP/UDP sends ensure full writes.

  • Bug Fixes
    • dnsfs_query_record: on signal, return -ERESTARTSYS immediately, drop ref, and avoid reading request fields.
    • Snapshot storage->meta and storage->epoch in assemble/read paths to prevent heap OOB during lockless reads; torn generations are retried via epoch/CRC.
    • TCP: loop kernel_sendmsg until the full framed query is sent; treat zero-length send as -EIO. UDP: require full datagram length or fail.
    • Added test_signal_interrupt to verify a SIGINT aborts a slow read within 1s.

Written for commit dd43a09. Summary will update on new commits.

Review in cubic

dnsfs_query_record no longer re-waits uninterruptibly after a signal
wakes wait_for_completion_interruptible. A signaled foreground waiter
now returns -ERESTARTSYS at once, drops its reference, and reads no req
fields (the worker may still be writing them). Safe by the existing
refcount contract: the worker holds its own reference until after
complete_all, so the shared coalesced request stays queued, still
resolves, fills the cache, and wakes the other waiters; the last
reference drop frees it. Adds test_signal_interrupt: a 3s-delayed
resolver, SIGINT a cat once the wire query is observed, expect it to die
within 1s.

dnsfs_storage_assemble_once and dnsfs_storage_read_range_once snapshot
storage->meta and storage->epoch into locals before sizing buffers. The
read path runs without storage->lock, so a concurrent re-pin could grow
chunk_count or size between the allocation and the loop bound, a heap
OOB write; the snapshot closes it. A torn generation is caught by
epoch/CRC and retried.

dnsfs_query_tcp loops kernel_sendmsg until the whole framed query is
sent (TCP is a byte stream) and fails a zero-length send;
dnsfs_query_udp_once requires the datagram send to report the ful
length.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 3 files

Re-trigger cubic

@jserv jserv merged commit 0544e23 into main Jul 3, 2026
5 checks passed
@jserv jserv deleted the signal-aware branch July 3, 2026 15:28
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