AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 21 Bitcoin

common: explain why mlock() failed instead of a bare abort.

Public commit record

What the developer wrote

Authored by Matt Watson

85/100 · Strong
common: explain why mlock() failed instead of a bare abort.

mlock_tal_memory() aborts when sodium_mlock() fails, with no output at
all. The operator sees only "lightning_hsmd: FATAL SIGNAL 6" and has no
indication of the cause.

This is easy to hit. FreeBSD jails deny mlock(2) unless the jail has
allow.mlock set, and containerized Linux deployments hit the same wall
against RLIMIT_MEMLOCK. In both cases the failure is indistinguishable
from a crash.

Keep the abort -- falling back to unlocked memory would silently leave
the secret in swappable pages -- but say what failed and how to grant
the privilege.

The message goes to stderr via warnx() rather than status_failed():
common/utils.c is linked into every binary, and mlock_tal_memory() is
also reached from common/hsm_secret.c, where no status fd need exist.
stderr is the one channel available at every call site, and warnx()
gives it the same daemon-name prefix as the crashdump() line that
follows.

Changelog-Fixed: Report the cause when locking secret memory fails, instead of aborting with no diagnostic.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode
The short version

What changed, and why it matters

This change only improves the error message shown when the program aborts because it cannot lock secret memory. It does not fix a security vulnerability, change behavior, or remove the abort. The program still crashes, but now tells the operator why and how to grant the needed permission.

Recommended action

No security action required; this is a usability/diagnostics improvement. Operators who previously saw unexplained SIGABRT/SIGSEGV will now get a actionable message.

Security signals we found

01

diagnostic-only change around memory-locking failure path

02

abort-on-mlock-failure retained to avoid silently using swappable memory

03

no cryptographic or memory-safety logic altered

Risk score

Why this scored 21/100

Our methodology →
Potential impact 2/30
Exploitability 0/25
Stealth signal 0/15
Affected reach 5/15
Confidence 9/10
Evidence quality 5/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.