Skip to content

wolfsshd: survive fork failure, fail startup loudly - #1328

Open
ejohnstown wants to merge 2 commits into
wolfSSL:masterfrom
ejohnstown:fork-fail
Open

ejohnstown wants to merge 2 commits into
wolfSSL:masterfrom
ejohnstown:fork-fail

Conversation

@ejohnstown

@ejohnstown ejohnstown commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

wolfsshd keeps listening when a fork() or CreateThread() for one
connection fails, and now exits non-zero when startup fails.

  • A failed fork drops that connection instead of ending the accept
    loop; sshd_fork_fail_test.sh forces EAGAIN with an LD_PRELOAD shim.
  • StartSSHD() returns EXIT_FAILURE on a bad config (-t), host key, or
    port, and on a select() error; sshd_exit_status_test.sh checks them.

Issue: F-16052, F-16053

StartSSHD() no longer stores the NewConnection() result in ret, the
accept loop's condition. A failed fork() or CreateThread() now drops
that one connection, and the daemon goes on listening.

- add sshd_fork_fail_test.sh with an LD_PRELOAD shim that fails the
  first connection's fork() with EAGAIN
- run it from run_all_sshd_tests.sh on leased port +7

Issue: F-16052
The POSIX StartSSHD() now returns EXIT_FAILURE when ret holds an error,
and main() passes that on. A config check (-t) of a bad config, a
failed host key load, or a bad -p now exit 1 instead of 0.

- set ret when the accept loop cannot allocate a connection, so that
  stop also exits non-zero
- PendingConnection() returns negative on a select() error other than
  EINTR, and the accept loop sets ret from it instead of quit
- add sshd_exit_status_test.sh, which checks -D -t exit codes for a
  valid config and three startup failures

Issue: F-16053
Copilot AI balanced review requested due to automatic review settings October 19, 2026 22:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-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.

Fenrir Automated Review — PR #1328

Scan targets checked: wolfssh-src, wolfssh-bugs
Not reviewed (no scan target covers them): .gitignore, apps/wolfsshd/test/run_all_sshd_tests.sh, apps/wolfsshd/test/sshd_exit_status_test.sh, apps/wolfsshd/test/sshd_fork_fail_test.sh
Coverage: 1 of 2 in-scope changed file(s) opened by the reviewer; not opened: apps/wolfsshd/test/sshd_fork_preload.c

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

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.

4 participants