From ee65da1c75cb295485881e7190b6d7190463ba92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADckolas=20Goline?= Date: Wed, 20 May 2026 11:49:15 -0300 Subject: [PATCH] ecdh_hsmd: ensure HSM fd is blocking on setup 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 --- common/ecdh_hsmd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/ecdh_hsmd.c b/common/ecdh_hsmd.c index 8afa4581c40a..68be59841eb2 100644 --- a/common/ecdh_hsmd.c +++ b/common/ecdh_hsmd.c @@ -1,5 +1,6 @@ #include "config.h" #include +#include #include #include #include @@ -33,4 +34,6 @@ void ecdh_hsmd_setup(int hsm_fd, { stashed_hsm_fd = hsm_fd; stashed_failed = failed; + /* Like read_fds in subd.c: don't trust sender's O_NONBLOCK state (issue #9060). */ + io_fd_block(hsm_fd, true); }