Skip to content

Propagate only WANT_WRITE in DoKexInit - #1278

Merged
philljj merged 1 commit into
wolfSSL:masterfrom
ejohnstown:kexinit-stale-error
Oct 1, 2026
Merged

philljj merged 1 commit into
wolfSSL:masterfrom
ejohnstown:kexinit-stale-error

Conversation

@ejohnstown

@ejohnstown ejohnstown commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

DoKexInit() takes a blocked KEXINIT reply from SendKexInit()'s return,
not ssh->error, so a stale WS_WINDOW_FULL no longer fails the peer's
rekey and a stale WS_WANT_WRITE is not reported again.

  • tests/regress.c runs DoKexInit() with stale WS_SUCCESS,
    WS_WINDOW_FULL, WS_CHAN_RXD and WS_WANT_WRITE, with the reply sent,
    blocked, failed, or not owed. The test runs in server-only builds.

Issue: F-14394

@ejohnstown
ejohnstown requested review from wolfSSL-Fenrir-bot and a balanced review from Copilot September 29, 2026 00:24

@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 #1278

Scan targets checked: wolfssh-src, wolfssh-bugs
Coverage: 1 of 2 in-scope changed file(s) opened by the reviewer; not opened: tests/regress.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

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

Review effort: Lite
Findings: 1 High severity · 4 Medium severity

Open (5)
What changed in this PR

Updates DoKexInit() to only propagate WS_WANT_WRITE back to the caller (avoiding failures due to unrelated stale ssh->error values) and adds regression coverage around stale errors and blocked reply sends.

Changes:

  • Limit DoKexInit() error propagation to WS_WANT_WRITE only.
  • Add a regression helper and test cases to validate stale ssh->error handling and blocked send behavior.
  • Wire the new regression test into main() under an existing compile-time guard.
File Description
tests/​regress.c Adds a regression harness/test to ensure stale ssh->error values don’t break peer rekey, while still reporting blocked reply sends.
src/​internal.c Changes DoKexInit() to propagate only WS_WANT_WRITE instead of any non-zero ssh->error.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/internal.c Outdated
Comment thread src/internal.c Outdated
Comment thread tests/regress.c
Comment thread tests/regress.c
Comment thread tests/regress.c

@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 #1278

Scan targets checked: wolfssh-src, wolfssh-bugs
Coverage: 2 of 2 in-scope changed file(s) opened by the reviewer

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

philljj
philljj previously requested changes Oct 1, 2026

@philljj philljj 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.

merge conflict in tests/regress.c (from merging the terrapin PR probably)

@philljj philljj assigned ejohnstown and unassigned wolfSSL-Bot Oct 1, 2026
@ejohnstown
ejohnstown force-pushed the kexinit-stale-error branch 2 times, most recently from c99ef2e to 1ebee2e Compare October 1, 2026 15:51
@ejohnstown
ejohnstown requested a review from philljj October 1, 2026 15:51
@philljj
philljj dismissed their stale review October 1, 2026 17:31

addressed

DoKexInit() reports a blocked KEXINIT reply to its caller. Take it from
SendKexInit()'s return, not ssh->error, which holds whatever an earlier
call left there: a WS_WINDOW_FULL from SendChannelData() failed the
peer's rekey, and a WS_WANT_WRITE whose send had finished came back.

- tests/regress.c runs DoKexInit() with WS_SUCCESS, WS_WINDOW_FULL,
  WS_CHAN_RXD and WS_WANT_WRITE left in ssh->error, its reply sent,
  blocked, failed, or not owed, and checks the KEXINIT is consumed.
- The test needs only the server: REGRESS_SERVER_KEY_PATH moves out of
  the KEXDH_REPLY_REGRESS_KEX_ALGO block.

Issue: F-14394
@ejohnstown
ejohnstown force-pushed the kexinit-stale-error branch from 1ebee2e to f2fd963 Compare October 1, 2026 17:49
@philljj
philljj merged commit 19bac6d into wolfSSL:master Oct 1, 2026
252 of 261 checks passed
@ejohnstown
ejohnstown deleted the kexinit-stale-error branch October 1, 2026 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants