Skip to content

ecdh_hsmd: ensure HSM fd is blocking on setup#9155

Open
nGoline wants to merge 1 commit into
ElementsProject:masterfrom
nGoline:segwit-shutdown-script-ecdh-fix
Open

ecdh_hsmd: ensure HSM fd is blocking on setup#9155
nGoline wants to merge 1 commit into
ElementsProject:masterfrom
nGoline:segwit-shutdown-script-ecdh-fix

Conversation

@nGoline
Copy link
Copy Markdown
Collaborator

@nGoline nGoline commented May 20, 2026

  • On macOS under load, socketpair fds sent via SCM_RIGHTS can have O_NONBLOCK set (from io_new_conn called on the sender's end in hsmd:pass_client_hsmfd), causing wire_sync_read to return NULL with EAGAIN and killing connectd/channeld with "BROKEN STATUS_FAIL_HSM_IO: No hsmd ECDH response"
  • Fix mirrors the existing "Don't trust subd to set it blocking" pattern in lightningd/subd.c:read_fds — call io_fd_block(hsm_fd, true) in ecdh_hsmd_setup, which is used by connectd, channeld, and lightningd itself
  • Applies to both responder (Act 1) and initiator (Act 3) NOISE handshake paths that call ecdh()

Closes #9060

🤖 Generated with Claude Code

On macOS under load, socketpair fds sent via SCM_RIGHTS can have
O_NONBLOCK set (from the sender's io_new_conn call in hsmd's
pass_client_hsmfd).  This causes wire_sync_read to return NULL
with EAGAIN, killing connectd or channeld with "No hsmd ECDH response".

The fix mirrors the "Don't trust subd to set it blocking" pattern
already used in lightningd/subd.c:read_fds(): explicitly call
io_fd_block(hsm_fd, true) in ecdh_hsmd_setup.

Changelog-Fixed: connectd: fix intermittent "No hsmd ECDH response" crash on macOS under load.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

pytest: *BROKEN* in test_segwit_shutdown_script

1 participant