Public issue detail

Runaway CPU investigation for sshd-auth: busy poll at unresolved offset in sshd-auth

sshd-auth is stuck in a likely busy poll loop: 100.00% of sampled CPU passed through unresolved offset, with repeated read x3, write x2, clock_nanosleep x1.

highpackage: openssh-serversource: opensshscore: 106reports: 2patch attempt ready

Last seen: 2026-05-19 02:02 UTC. Public JSON: /v1/issues/019e1519-78c6-7813-bebb-aeb6177e1897

Pull-request-ready diff

This is the current best public patch attempt for the issue. The downloadable .patch now includes a short cover letter so it reads like something you could send upstream with git am. If you only want the raw diff, grab the .diff instead.

best patchcreated: 2026-05-11 17:06 UTCvalidation: ready

sshd-auth likely remains stuck in a busy-poll loop. A diagnosis report and patch proposal were created locally.

Suggested subject

sshd-auth: enforce LoginGraceTime during pre-authentication

Commit message.

Fixer observed `sshd-auth`, the split helper that handles pre-authentication SSH key exchange and user authentication, in a short trace around sleep, monitor writes, and `ppoll`. The trace does not prove an infinite spin, but it does show the pre-auth helper in the area that should be bounded by `LoginGraceTime`.

`sshd-session.c` already arms that timer before pre-authentication. Mirror that bounded timer setup in `sshd-auth.c`, and clear it after authentication succeeds.

Problem. sshd-auth is stuck in a likely busy poll loop: 100.00% of sampled CPU passed through unresolved offset, with repeated read x3, write x2, clock_nanosleep x1.

How this patch connects to the issue.

Fixer observed an `sshd-auth: root [net]` process with profiler evidence in `sshd-auth`, a dominant syscall sequence of `clock_nanosleep`, `write`, and `ppoll`, `/proc` state sleeping in `unix_stream_read_generic`, and a captured strace ending with `ECONNRESET` and exit. This was observed by Fixer and not independently reproduced.

The cautious code-level cause is that split `sshd-auth.c` reset `SIGALRM` to the default action and then entered key exchange and authentication without arming the configured `LoginGraceTime` alarm. I improved the prior Fixer patch by keeping the same bounded linear control flow, cleaning up style, and adding only the timer setup/clear logic already used by the nearby session path.

The change uses existing OpenSSH conventions and helpers: `ssh_signal`, `setitimer`, `timerclear`, `arc4random_uniform`, `fatal`, and `_exit(EXIT_LOGIN_GRACE)`. `README.md` was the only contribution/style document found; no relevant local file-I/O, path, process-spawn, allocation, or locking helper was needed for this change. The expected effect is that slow or wedged `sshd-auth` pre-authentication workers are terminated by the configured login grace timeout instead of being allowed to remain in pre-authentication indefinitely.

Files touched

  • sshd-auth.c

Validation

  • Fixer marked this proposal `ready` on 2026-05-11 17:06 UTC.
  • The underlying issue cluster has 2 report(s) and was last seen 2026-05-19 02:02 UTC.
  • The published diff touches sshd-auth.c.
  • `./configure && make` from the workspace root failed first with: `configure: error: ./m4/openssh.m4 newer than configure, run autoreconf` Because this git checkout had stale generated-file timestamps, I then ran: `touch configure && ./configure && make` That completed successfully and built `sshd-auth`. I also ran: `git diff --check` That completed with no whitespace/style errors. Bounded independent runtime smoke was attempted with a temporary `sshd` config using `LoginGraceTime 1` and the built `sshd-session`/`sshd-auth` paths, but the environment blocked startup before any socket test: `Missing privilege separation directory: /var/empty` Confidence remains `observed`, not `reproduced`.
diff --git a/sshd-auth.c b/sshd-auth.c
index 502a342..07384ca 100644
--- a/sshd-auth.c
+++ b/sshd-auth.c
@@ -175,6 +175,17 @@ mm_is_monitor(void)
 	return 0;
 }
 
+/*
+ * Signal handler for the alarm after the login grace period has expired.
+ * As usual, this may only take signal-safe actions, even though it is
+ * terminal.
+ */
+static void
+grace_alarm_handler(int sig)
+{
+	_exit(EXIT_LOGIN_GRACE);
+}
+
 static void
 privsep_child_demote(void)
 {
@@ -445,6 +456,7 @@ main(int ac, char **av)
 	Authctxt *authctxt;
 	struct connection_info *connection_info = NULL;
 	sigset_t sigmask;
+	struct itimerval itv;
 	uint64_t timing_secret = 0;
 
 	closefrom(PRIVSEP_MIN_FREE_FD);
@@ -725,6 +737,27 @@ main(int ac, char **av)
 	ssh_signal(SIGQUIT, SIG_DFL);
 	ssh_signal(SIGCHLD, SIG_DFL);
 
+	/*
+	 * We don't want to listen forever unless the other side
+	 * successfully authenticates itself.  So we set up an alarm which is
+	 * cleared after successful authentication.  A limit of zero
+	 * indicates no limit. Note that we don't set the alarm in debugging
+	 * mode; it is just annoying to have the server exit just when you
+	 * are about to discover the bug.
+	 */
+	ssh_signal(SIGALRM, grace_alarm_handler);
+	if (!debug_flag && options.login_grace_time > 0) {
+		int ujitter = arc4random_uniform(4 * 1000000);
+
+		timerclear(&itv.it_interval);
+		itv.it_value.tv_sec = options.login_grace_time;
+		itv.it_value.tv_sec += ujitter / 1000000;
+		itv.it_value.tv_usec = ujitter % 1000000;
+
+		if (setitimer(ITIMER_REAL, &itv, NULL) == -1)
+			fatal("login grace time setitimer failed");
+	}
+
 	/* Prepare the channels layer */
 	channel_init_channels(ssh);
 	channel_set_af(ssh, options.address_family);
@@ -761,6 +794,16 @@ main(int ac, char **av)
 	do_ssh2_kex(ssh);
 	do_authentication2(ssh);
 
+	/*
+	 * Cancel the alarm we set to limit the time taken for
+	 * authentication.
+	 */
+	timerclear(&itv.it_interval);
+	timerclear(&itv.it_value);
+	if (setitimer(ITIMER_REAL, &itv, NULL) == -1)
+		fatal("login grace time clear failed");
+	ssh_signal(SIGALRM, SIG_DFL);
+
 	/*
 	 * The unprivileged child now transfers the current keystate and exits.
 	 */

Technical snapshot

This is the clearest retained userspace thread cluster Fixer captured while the process was spinning.

Representative thread backtrace

  • Command: sshd-auth: root [net]
  • Why Fixer classified it this way: The trace repeatedly returns to a poll-family syscall without meaningful blocking, which suggests a busy event-loop wakeup.
  • Wait site: unix_stream_read_generic
  • Hot path: unresolved offset (100.00% sampled CPU)
  • Repeated loop: clock_nanosleep -> write -> ppoll
  • Top syscalls: read x3, write x2, clock_nanosleep x1, exit_group x1
  • Package: openssh-server 1:10.3p1-1
  • Kernel: 6.17.10+deb14-amd64
  • Distribution: debian
unix_stream_read_generic
unix_stream_recvmsg
sock_recvmsg
sock_read_iter
vfs_read
ksys_read
do_syscall_64
entry_SYSCALL_64_after_hwframe

Possible duplicates

These are suggestions based on sanitized trigram similarity plus structured fields like package, subsystem, classification, and wait site. They are not auto-merged.

sshd-auth is stuck in a likely busy poll loop: 100.00% of sampled CPU passed through do_syscall_64, with repeated read x3, write x2, clock_nanosleep x1.

highpackage: openssh-serversource: opensshscore: 106reports: 2patch attempt readysimilarity: 99%

Why this looks related: same classification, same package, same source package, same subsystem, same target, same wait site, very similar public summary

Last seen: 2026-05-17 22:28 UTC. Public page: /issues/019e3654-a65e-7280-96ec-a71efe4a27f7. Public JSON: /v1/issues/019e3654-a65e-7280-96ec-a71efe4a27f7

sshd-auth is stuck in a likely busy poll loop: 25.00% of sampled CPU passed through __smp_call_single_queue, with repeated read x3, write x2, clock_nanosleep x1.

highpackage: openssh-serversource: opensshscore: 106reports: 2patch attempt readysimilarity: 99%

Why this looks related: same classification, same package, same source package, same subsystem, same target, same wait site

Last seen: 2026-05-14 02:49 UTC. Public page: /issues/019e20bd-40d6-7792-a29a-0bbad3f4023d. Public JSON: /v1/issues/019e20bd-40d6-7792-a29a-0bbad3f4023d

sshd-auth is stuck in a likely timer churn loop: 53.23% of sampled CPU passed through unresolved offset, with repeated thread backtraces show 1 thread(s) around 0x00007f97dda9a7d2 in ?? () from target:<path>.

highpackage: openssh-serversource: opensshscore: 106reports: 2patch attempt readysimilarity: 98%

Why this looks related: same package, same source package, same subsystem, same target, same wait site

Last seen: 2026-05-13 06:39 UTC. Public page: /issues/019dfdca-f6fb-77c3-987d-954b3b228857. Public JSON: /v1/issues/019dfdca-f6fb-77c3-987d-954b3b228857

sshd-auth is stuck in a likely unclassified userspace loop: 50.00% of sampled CPU passed through unresolved offset, with repeated restart_syscall x1.

highpackage: openssh-serversource: opensshscore: 106reports: 1successful triagesimilarity: 86%

Why this looks related: same package, same source package, same subsystem, same target

Last seen: 2026-05-15 12:12 UTC. Public page: /issues/019e280a-4492-7191-b9ec-076dfc0d450f. Public JSON: /v1/issues/019e280a-4492-7191-b9ec-076dfc0d450f

sshd-auth is stuck in a likely unclassified userspace loop: 100.00% of sampled CPU passed through unresolved offset, with repeated restart_syscall x1.

highpackage: openssh-serversource: opensshscore: 106reports: 1successful triagesimilarity: 86%

Why this looks related: same package, same source package, same subsystem, same target

Last seen: 2026-05-13 09:30 UTC. Public page: /issues/019e2078-d1a4-74b3-bda0-47898d09c470. Public JSON: /v1/issues/019e2078-d1a4-74b3-bda0-47898d09c470

sshd-auth is stuck in a likely timer churn loop: 100.00% of sampled CPU passed through vfs_write, with repeated thread backtraces show 1 thread(s) around 0x00007f76d5c9a7d2 in ?? () from target:<path>.

highpackage: openssh-serversource: opensshscore: 106reports: 2patch attempt readysimilarity: 80%

Why this looks related: same package, same source package, same subsystem, same target, same wait site

Last seen: 2026-05-15 18:05 UTC. Public page: /issues/019e2c59-6707-7471-b7b2-5329d3cdd34e. Public JSON: /v1/issues/019e2c59-6707-7471-b7b2-5329d3cdd34e

Worker outcome summary

This issue has 4 recorded worker attempts. Only ready diffs and ready triage handoffs get dedicated public boards. Diagnosis-only reports and blocked attempts are summarized here so it is easier to see why work stalled.

4 ready patch attempts

No ready triage handoffs, diagnosis-only reports, failed patch attempts, explained impossible attempts, or other attempt states.

Published attempts

ready patch attempt

patch

sshd-auth likely remains stuck in a busy-poll loop. A diagnosis report and patch proposal were created locally.

state: readycreated: 2026-05-11 17:06 UTCvalidation: ready
Published session

Prompt

## Plan Pass

You are planning a fixer patch before any edits happen.

Read the evidence bundle at `./evidence.json`. The prepared workspace is `./workspace` and it was acquired via `debian-vcs-git`. The original pre-edit snapshot is available at `./source` if you need to inspect it. For interpreter processes, plan from the script/application entrypoint evidence first and include the runtime only as a second investigation target unless the evidence proves a runtime bug.

Validation expectation: try the project-level build/test entrypoint from the workspace root before reporting only a focused leaf compile. Detected candidate(s): `./configure && make`. If the project-level command fails because dependencies or generated files are missing, include the exact command and failure reason in `## Validation`, then run the narrowest relevant compile/test that is still reproducible from a clean checkout.

Upstream-style expectation: before planning or editing, check for contribution/style docs (`CONTRIBUTING`, `HACKING`, `README-hacking`, `README.md`, `docs/`, `dev-docs/`) and scan the touched subsystem for local helpers. If the project has wrappers for file IO, path-relative IO, process spawning, memory allocation, logging, locking, or platform compatibility, prefer those wrappers over generic libc/std APIs. Do not invent a reproducer or user-visible failure that is not in the evidence bundle; if the evidence is profiler-only or indirect, describe it as a targeted mitigation or stop with a diagnosis instead of presenting a speculative patch as a confirmed bug fix. In the plan and final validation, name any such helper, convention, or evidence limit you found, or say that no relevant local helper was found. Treat this as a `openssh` upstream patch, not just a Debian-local workaround. Inspect the relevant code, nearby callers, project contribution docs, and local helper/compat APIs, but do not edit files in this pass.

Return a short markdown plan with these exact sections:

## Problem
## Evidence Confidence
## Proposed Subject
## Patch Plan
## Risks
## Validation

Classify `## Evidence Confidence` as exactly one of `reproduced`, `observed`, or `inferred`. Use `inferred` only for a no-patch diagnosis/report plan unless you can name the extra evidence you will collect before editing; inferred source patches are blocked by Fixer because they are not pull-request-ready. For `observed` source-patch plans, plan to say in the final `## Issue Connection` that the failure was observed by Fixer and not independently reproduced. The plan must explain how the proposed code change addresses the observed issue evidence, call out any prior Fixer patch that should be improved or replaced, reject awkward control flow such as avoidable `goto` if there is a cleaner bounded alternative, name any local helper APIs or maintainer conventions the patch should follow, and keep the intended maintainer-facing explanation clear enough that someone unfamiliar with the local complaint wording can still follow the fix. In `## Validation`, name the reproducible configure/build/test entrypoint you will try from the workspace root before any focused leaf compile or smoke check, and include one bounded independent reproduction attempt for the collected failure signal when it is safe and cheap. Do not plan to claim `reproduced` unless that reproduction command or test can actually show the failure.

## Patch Pass

You are working on a bounded fixer proposal.

Read the evidence bundle at `./evidence.json`. The prepared workspace is `./workspace` and it was acquired via `debian-vcs-git`. Produce the smallest reasonable patch for the target repository, keep the change upstreamable, prefer the clearest control flow available, and do not keep avoidable `goto` when a simpler structure would read better. Before introducing new file, process, allocation, locking, networking, or platform APIs, inspect nearby code and project contribution docs for existing helpers or compatibility wrappers and use those local patterns unless you can explain why they do not fit. Validate from a reproducible workspace-root entrypoint before falling back to focused leaf commands; if a build or test cannot run, report the exact command, the exact blocker, and any narrower check you ran instead. During validation, also try one bounded independent reproduction of the collected failure signal when it is safe and cheap, such as a failing test, smoke command, perf/strace comparison, or before/after runtime check. Only use `reproduced` if that command or test actually reproduced the failure; otherwise keep `observed` and report the reproduction blocker. The final explanation must connect the observed issue evidence to the actual code change, not just paraphrase the diff. Write like a maintainer is going to read the patch mail cold: explain the bug in plain language, define subsystem-specific jargon the first time you need it, and make the causal story obvious. Explicitly classify evidence confidence as `reproduced`, `observed`, or `inferred`: `reproduced` means you reproduced the failure locally; `observed` means Fixer has direct crash/log/trace evidence but you did not independently reproduce it; `inferred` means the source patch is not pull-request-ready, so do not leave a source diff unless you first gather stronger observed/reproduced evidence; otherwise return a no-patch diagnosis/report. For any source-changing `observed` patch, say explicitly in `## Issue Connection` that the failure was observed by Fixer and not independently reproduced. If you introduce non-obvious state translation, index remapping, or backend split logic, add a short source comment that explains the invariant being preserved.

Start by explaining the likely root cause from the collected perf, strace, and /proc evidence. If you cannot land a safe patch, leave a diagnosis that is strong enough for an upstream bug report.

A previous Fixer patch attempt already exists for this issue. It was generated by Fixer `0.148.0`. Review that patch before changing code, improve it instead of starting blind, and clean up anything awkward or underexplained. In particular, remove avoidable `goto`, tighten the explanation of what the patch is doing, and make the resulting diff feel ready for upstream git review.
- Prior patch: `./prior-best.patch`
- Prior published session: `./prior-best-session.md`

Validation expectation: try the project-level build/test entrypoint from the workspace root before reporting only a focused leaf compile. Detected candidate(s): `./configure && make`. If the project-level command fails because dependencies or generated files are missing, include the exact command and failure reason in `## Validation`, then run the narrowest relevant compile/test that is still reproducible from a clean checkout.

Upstream-style expectation: before planning or editing, check for contribution/style docs (`CONTRIBUTING`, `HACKING`, `README-hacking`, `README.md`, `docs/`, `dev-docs/`) and scan the touched subsystem for local helpers. If the project has wrappers for file IO, path-relative IO, process spawning, memory allocation, logging, locking, or platform compatibility, prefer those wrappers over generic libc/std APIs. Do not invent a reproducer or user-visible failure that is not in the evidence bundle; if the evidence is profiler-only or indirect, describe it as a targeted mitigation or stop with a diagnosis instead of presenting a speculative patch as a confirmed bug fix. In the plan and final validation, name any such helper, convention, or evidence limit you found, or say that no relevant local helper was found. Treat this as a `openssh` upstream patch, not just a Debian-local workaround. 

Keep the change narrowly scoped and summarize validation clearly.

In every authoring pass, your final response must start with `Subject: <single-line git commit subject>` and then include these markdown sections exactly:

## Commit Message
A short upstream-friendly explanation of what changed and why. Write it in plain language that a maintainer can follow without local complaint context. If you use subsystem jargon, define it immediately.

## Evidence Confidence
Exactly one word: `reproduced`, `observed`, or `inferred`. Use `reproduced` only when you reproduced the failure locally with a command or test, and include that command/test in `## Validation`. Use `observed` when Fixer has direct crash/log/trace evidence but you did not independently reproduce it. If `## Git Add Paths` lists source files for an `observed` patch, `## Issue Connection` must explicitly say the failure was observed by Fixer and not independently reproduced. Use `inferred` for profiler/strace/indirect evidence; inferred responses may be no-patch diagnoses or reports, but inferred source patches are not pull-request-ready until stronger evidence is gathered.

## Issue Connection
Write this as maintainer-facing patch mail, not as local Fixer notes. Cover four things explicitly in readable sentences: the user-visible symptom or the exact collected signal, the code-level cause or the cautious inference from evidence, the specific change you made, and the expected effect. Do not invent a reproducer, command line, crash, or user-visible failure that is not present in the evidence bundle. If the evidence is direct-but-not-reproduced, say it was observed by Fixer and not independently reproduced. If the evidence is indirect and you did not gather stronger evidence, do not leave a source diff; write a no-patch diagnosis/report instead. Include an explicit effect sentence such as `The expected effect is ...`, `This should reduce ...`, or `This prevents ...` for source patches. If the logic is non-obvious in code, mention that you added a short explanatory comment.

## Git Add Paths
List the repo-relative paths that belong in the final patch, one per line. Use `None` only when you intentionally made no source changes. Include intentionally new files, and do not list generated build artifacts.

## Validation
List the checks you ran, or say clearly that you could not run them. Include the independent reproduction command/test and result when `## Evidence Confidence` is `reproduced`; if reproduction was attempted but blocked, name the exact blocker and keep confidence at `observed` or `inferred`.

Before editing, read the plan at `./plan-output.txt` and follow it unless the code proves part of it wrong. If you change course, say so explicitly in the final write-up instead of silently drifting from the plan.

## Review Pass 1

You are reviewing a freshly generated fixer patch.

Read the evidence bundle at `./evidence.json`. The prepared workspace is `./workspace` and it was acquired via `debian-vcs-git`. Review the first patch pass. The original pre-edit snapshot is available at `./source` for diffing. The workspace currently changes these repo-relative paths: sshd-auth.c. Verify that `## Git Add Paths` matches this exact set and that `## Issue Connection` explains every shipped functional file.

Upstream-style expectation: before planning or editing, check for contribution/style docs (`CONTRIBUTING`, `HACKING`, `README-hacking`, `README.md`, `docs/`, `dev-docs/`) and scan the touched subsystem for local helpers. If the project has wrappers for file IO, path-relative IO, process spawning, memory allocation, logging, locking, or platform compatibility, prefer those wrappers over generic libc/std APIs. Do not invent a reproducer or user-visible failure that is not in the evidence bundle; if the evidence is profiler-only or indirect, describe it as a targeted mitigation or stop with a diagnosis instead of presenting a speculative patch as a confirmed bug fix. In the plan and final validation, name any such helper, convention, or evidence limit you found, or say that no relevant local helper was found. Treat this as a `openssh` upstream patch, not just a Debian-local workaround.

Validation expectation: try the project-level build/test entrypoint from the workspace root before reporting only a focused leaf compile. Detected candidate(s): `./configure && make`, `make` and, if available, `make check`. If the project-level command fails because dependencies or generated files are missing, include the exact command and failure reason in `## Validation`, then run the narrowest relevant compile/test that is still reproducible from a clean checkout. The latest author response is at `./patch-output.txt`. Inspect the current code and changed paths like a strict code reviewer. Focus on correctness, regressions, maintainability, awkward control flow such as avoidable `goto`, missing validation, weak or non-gittable commit message text, and explanations that fail to connect the observed issue evidence to the code change. Also review the maintainer experience: the patch mail should be easy to accept upstream, the user-visible bug should be explained in plain language, subsystem-specific jargon should be defined when first used, and any non-obvious state translation or index remapping in code should have a short explanatory comment. Reject patches that omit `## Evidence Confidence`, use anything other than `reproduced`, `observed`, or `inferred`, or sound more certain than that evidence level allows. Reject patches that claim `reproduced` unless `## Validation` names the concrete reproduction command or test and its result. Reject patches that invent a reproducer, command line, crash, or user-visible failure not present in the evidence bundle; indirect profiler or strace evidence may justify a cautious mitigation, but the author must say it is indirect instead of presenting it as a confirmed upstream bug. Reject patches that introduce generic libc/std APIs when nearby code or project docs provide a local compat/helper API for the same job, unless the author explicitly justifies the exception. Reject validation that only reports a leaf object/syntax build when a project-level configure/build/test entrypoint exists and was not attempted; if a full build cannot run, the author must show the exact failed command and blocker.

Do not apply code changes in this pass.

Return a short markdown review report. The first non-empty line must be exactly one of:

RESULT: ok
RESULT: fix-needed

If you choose `RESULT: fix-needed`, add a `## Findings` section with concrete, actionable items.

Response

## Plan Pass

## Problem
`sshd-auth` was observed by Fixer in a suspected pre-auth busy-poll path, but the captured strace ends with `ECONNRESET` and process exit, so the evidence does not prove an infinite loop. A concrete upstream code gap remains: unlike `sshd-session.c`, split `sshd-auth.c` resets `SIGALRM` and enters KEX/authentication without arming the configured `LoginGraceTime` alarm.

## Evidence Confidence
observed

## Proposed Subject
`sshd-auth: enforce LoginGraceTime during pre-authentication`

## Patch Plan
Mirror the existing `sshd-session.c` login-grace timer in `sshd-auth.c`: add a local `grace_alarm_handler`, install it with `ssh_signal(SIGALRM, ...)`, arm `setitimer(ITIMER_REAL, ...)` before KEX/authentication, and clear it after successful authentication before keystate transfer.

Improve the prior Fixer patch rather than inventing a different fix: keep the same bounded linear control flow, avoid any `goto`, remove style issues such as trailing whitespace, and make the explanation cautious about the observed-but-not-reproduced trace.

Follow OpenSSH local conventions/helpers found in the subsystem: `ssh_signal`, `fatal`, `timerclear`, `arc4random_uniform`, `_exit(EXIT_LOGIN_GRACE)`, plus existing allocation/buffer conventions such as `xcalloc`/`sshbuf` where relevant. No relevant file-I/O or path helper is needed. Style docs found: `README.md`; no `CONTRIBUTING`, `HACKING`, `README-hacking`, `docs/`, or `dev-docs/` were found.

## Risks
The main risk is diverging from `sshd-session.c` behavior by arming the alarm too early or failing to clear it after authentication. The patch should stay close to the existing session implementation and avoid touching monitor IPC, packet loops, or generic poll handling.

Because the evidence is trace/profiler evidence and not a local reproduction, the final `## Issue Connection` must say the failure was observed by Fixer and not independently reproduced.

## Validation
First try the project-level entrypoint from the workspace root:

```sh
./configure && make
```

If that fails due to stale generated files or missing dependencies, report the exact failure, then run the narrowest reproducible focused build, likely:

```sh
make sshd-auth.o
```

Also attempt one bounded independent smoke check: run a temporary local `sshd` config with `LoginGraceTime 1`, connect and stall during pre-auth, and confirm the `sshd-auth` worker exits via the grace timeout. Do not claim `reproduced` unless that smoke check actually demonstrates the failure/fix signal.

## Patch Pass

Subject: sshd-auth: enforce LoginGraceTime during pre-authentication

## Commit Message
Fixer observed `sshd-auth`, the split helper that handles pre-authentication SSH key exchange and user authentication, in a short trace around sleep, monitor writes, and `ppoll`. The trace does not prove an infinite spin, but it does show the pre-auth helper in the area that should be bounded by `LoginGraceTime`.

`sshd-session.c` already arms that timer before pre-authentication. Mirror that bounded timer setup in `sshd-auth.c`, and clear it after authentication succeeds.

## Evidence Confidence
observed

## Issue Connection
Fixer observed an `sshd-auth: root [net]` process with profiler evidence in `sshd-auth`, a dominant syscall sequence of `clock_nanosleep`, `write`, and `ppoll`, `/proc` state sleeping in `unix_stream_read_generic`, and a captured strace ending with `ECONNRESET` and exit. This was observed by Fixer and not independently reproduced.

The cautious code-level cause is that split `sshd-auth.c` reset `SIGALRM` to the default action and then entered key exchange and authentication without arming the configured `LoginGraceTime` alarm. I improved the prior Fixer patch by keeping the same bounded linear control flow, cleaning up style, and adding only the timer setup/clear logic already used by the nearby session path.

The change uses existing OpenSSH conventions and helpers: `ssh_signal`, `setitimer`, `timerclear`, `arc4random_uniform`, `fatal`, and `_exit(EXIT_LOGIN_GRACE)`. `README.md` was the only contribution/style document found; no relevant local file-I/O, path, process-spawn, allocation, or locking helper was needed for this change. The expected effect is that slow or wedged `sshd-auth` pre-authentication workers are terminated by the configured login grace timeout instead of being allowed to remain in pre-authentication indefinitely.

## Git Add Paths
sshd-auth.c

## Validation
`./configure && make` from the workspace root failed first with:
`configure: error: ./m4/openssh.m4 newer than configure, run autoreconf`

Because this git checkout had stale generated-file timestamps, I then ran:
`touch configure && ./configure && make`

That completed successfully and built `sshd-auth`.

I also ran:
`git diff --check`

That completed with no whitespace/style errors.

Bounded independent runtime smoke was attempted with a temporary `sshd` config using `LoginGraceTime 1` and the built `sshd-session`/`sshd-auth` paths, but the environment blocked startup before any socket test:
`Missing privilege separation directory: /var/empty`

Confidence remains `observed`, not `reproduced`.

## Review Pass 1

RESULT: ok

No blocking findings.

The changed path set is exactly `sshd-auth.c`, and `## Git Add Paths` matches it. The issue connection explains the only shipped functional file and stays appropriately cautious: it says the Fixer trace was observed, not independently reproduced, and does not claim a confirmed infinite spin.

The patch follows the nearby `sshd-session.c` timer pattern and uses local OpenSSH conventions/helpers (`ssh_signal`, `setitimer`, `timerclear`, `arc4random_uniform`, `fatal`, `_exit(EXIT_LOGIN_GRACE)`). No avoidable `goto` or unrelated API churn was introduced.

Validation is acceptable for this pass: the author attempted `./configure && make`, reported the stale generated-file blocker, then completed `touch configure && ./configure && make`, and documented the runtime smoke blocker. I also confirmed `make check` is not available in this generated Makefile.

Diff

diff --git a/sshd-auth.c b/sshd-auth.c
index 502a342..07384ca 100644
--- a/sshd-auth.c
+++ b/sshd-auth.c
@@ -175,6 +175,17 @@ mm_is_monitor(void)
 	return 0;
 }
 
+/*
+ * Signal handler for the alarm after the login grace period has expired.
+ * As usual, this may only take signal-safe actions, even though it is
+ * terminal.
+ */
+static void
+grace_alarm_handler(int sig)
+{
+	_exit(EXIT_LOGIN_GRACE);
+}
+
 static void
 privsep_child_demote(void)
 {
@@ -445,6 +456,7 @@ main(int ac, char **av)
 	Authctxt *authctxt;
 	struct connection_info *connection_info = NULL;
 	sigset_t sigmask;
+	struct itimerval itv;
 	uint64_t timing_secret = 0;
 
 	closefrom(PRIVSEP_MIN_FREE_FD);
@@ -725,6 +737,27 @@ main(int ac, char **av)
 	ssh_signal(SIGQUIT, SIG_DFL);
 	ssh_signal(SIGCHLD, SIG_DFL);
 
+	/*
+	 * We don't want to listen forever unless the other side
+	 * successfully authenticates itself.  So we set up an alarm which is
+	 * cleared after successful authentication.  A limit of zero
+	 * indicates no limit. Note that we don't set the alarm in debugging
+	 * mode; it is just annoying to have the server exit just when you
+	 * are about to discover the bug.
+	 */
+	ssh_signal(SIGALRM, grace_alarm_handler);
+	if (!debug_flag && options.login_grace_time > 0) {
+		int ujitter = arc4random_uniform(4 * 1000000);
+
+		timerclear(&itv.it_interval);
+		itv.it_value.tv_sec = options.login_grace_time;
+		itv.it_value.tv_sec += ujitter / 1000000;
+		itv.it_value.tv_usec = ujitter % 1000000;
+
+		if (setitimer(ITIMER_REAL, &itv, NULL) == -1)
+			fatal("login grace time setitimer failed");
+	}
+
 	/* Prepare the channels layer */
 	channel_init_channels(ssh);
 	channel_set_af(ssh, options.address_family);
@@ -761,6 +794,16 @@ main(int ac, char **av)
 	do_ssh2_kex(ssh);
 	do_authentication2(ssh);
 
+	/*
+	 * Cancel the alarm we set to limit the time taken for
+	 * authentication.
+	 */
+	timerclear(&itv.it_interval);
+	timerclear(&itv.it_value);
+	if (setitimer(ITIMER_REAL, &itv, NULL) == -1)
+		fatal("login grace time clear failed");
+	ssh_signal(SIGALRM, SIG_DFL);
+
 	/*
 	 * The unprivileged child now transfers the current keystate and exits.
 	 */

ready patch attempt

patch

sshd-auth likely remains stuck in a busy-poll loop. A diagnosis report and patch proposal were created locally.

state: readycreated: 2026-05-11 17:06 UTCvalidation: ready
Published session

Prompt

## Plan Pass

You are planning a fixer patch before any edits happen.

Read the evidence bundle at `./evidence.json`. The prepared workspace is `./workspace` and it was acquired via `debian-vcs-git`. The original pre-edit snapshot is available at `./source` if you need to inspect it. For interpreter processes, plan from the script/application entrypoint evidence first and include the runtime only as a second investigation target unless the evidence proves a runtime bug.

Validation expectation: try the project-level build/test entrypoint from the workspace root before reporting only a focused leaf compile. Detected candidate(s): `./configure && make`. If the project-level command fails because dependencies or generated files are missing, include the exact command and failure reason in `## Validation`, then run the narrowest relevant compile/test that is still reproducible from a clean checkout.

Upstream-style expectation: before planning or editing, check for contribution/style docs (`CONTRIBUTING`, `HACKING`, `README-hacking`, `README.md`, `docs/`, `dev-docs/`) and scan the touched subsystem for local helpers. If the project has wrappers for file IO, path-relative IO, process spawning, memory allocation, logging, locking, or platform compatibility, prefer those wrappers over generic libc/std APIs. Do not invent a reproducer or user-visible failure that is not in the evidence bundle; if the evidence is profiler-only or indirect, describe it as a targeted mitigation or stop with a diagnosis instead of presenting a speculative patch as a confirmed bug fix. In the plan and final validation, name any such helper, convention, or evidence limit you found, or say that no relevant local helper was found. Treat this as a `openssh` upstream patch, not just a Debian-local workaround. Inspect the relevant code, nearby callers, project contribution docs, and local helper/compat APIs, but do not edit files in this pass.

Return a short markdown plan with these exact sections:

## Problem
## Evidence Confidence
## Proposed Subject
## Patch Plan
## Risks
## Validation

Classify `## Evidence Confidence` as exactly one of `reproduced`, `observed`, or `inferred`. Use `inferred` only for a no-patch diagnosis/report plan unless you can name the extra evidence you will collect before editing; inferred source patches are blocked by Fixer because they are not pull-request-ready. For `observed` source-patch plans, plan to say in the final `## Issue Connection` that the failure was observed by Fixer and not independently reproduced. The plan must explain how the proposed code change addresses the observed issue evidence, call out any prior Fixer patch that should be improved or replaced, reject awkward control flow such as avoidable `goto` if there is a cleaner bounded alternative, name any local helper APIs or maintainer conventions the patch should follow, and keep the intended maintainer-facing explanation clear enough that someone unfamiliar with the local complaint wording can still follow the fix. In `## Validation`, name the reproducible configure/build/test entrypoint you will try from the workspace root before any focused leaf compile or smoke check, and include one bounded independent reproduction attempt for the collected failure signal when it is safe and cheap. Do not plan to claim `reproduced` unless that reproduction command or test can actually show the failure.

## Patch Pass

You are working on a bounded fixer proposal.

Read the evidence bundle at `./evidence.json`. The prepared workspace is `./workspace` and it was acquired via `debian-vcs-git`. Produce the smallest reasonable patch for the target repository, keep the change upstreamable, prefer the clearest control flow available, and do not keep avoidable `goto` when a simpler structure would read better. Before introducing new file, process, allocation, locking, networking, or platform APIs, inspect nearby code and project contribution docs for existing helpers or compatibility wrappers and use those local patterns unless you can explain why they do not fit. Validate from a reproducible workspace-root entrypoint before falling back to focused leaf commands; if a build or test cannot run, report the exact command, the exact blocker, and any narrower check you ran instead. During validation, also try one bounded independent reproduction of the collected failure signal when it is safe and cheap, such as a failing test, smoke command, perf/strace comparison, or before/after runtime check. Only use `reproduced` if that command or test actually reproduced the failure; otherwise keep `observed` and report the reproduction blocker. The final explanation must connect the observed issue evidence to the actual code change, not just paraphrase the diff. Write like a maintainer is going to read the patch mail cold: explain the bug in plain language, define subsystem-specific jargon the first time you need it, and make the causal story obvious. Explicitly classify evidence confidence as `reproduced`, `observed`, or `inferred`: `reproduced` means you reproduced the failure locally; `observed` means Fixer has direct crash/log/trace evidence but you did not independently reproduce it; `inferred` means the source patch is not pull-request-ready, so do not leave a source diff unless you first gather stronger observed/reproduced evidence; otherwise return a no-patch diagnosis/report. For any source-changing `observed` patch, say explicitly in `## Issue Connection` that the failure was observed by Fixer and not independently reproduced. If you introduce non-obvious state translation, index remapping, or backend split logic, add a short source comment that explains the invariant being preserved.

Start by explaining the likely root cause from the collected perf, strace, and /proc evidence. If you cannot land a safe patch, leave a diagnosis that is strong enough for an upstream bug report.

A previous Fixer patch attempt already exists for this issue. It was generated by Fixer `0.148.0`. Review that patch before changing code, improve it instead of starting blind, and clean up anything awkward or underexplained. In particular, remove avoidable `goto`, tighten the explanation of what the patch is doing, and make the resulting diff feel ready for upstream git review.
- Prior patch: `./prior-best.patch`
- Prior published session: `./prior-best-session.md`

Validation expectation: try the project-level build/test entrypoint from the workspace root before reporting only a focused leaf compile. Detected candidate(s): `./configure && make`. If the project-level command fails because dependencies or generated files are missing, include the exact command and failure reason in `## Validation`, then run the narrowest relevant compile/test that is still reproducible from a clean checkout.

Upstream-style expectation: before planning or editing, check for contribution/style docs (`CONTRIBUTING`, `HACKING`, `README-hacking`, `README.md`, `docs/`, `dev-docs/`) and scan the touched subsystem for local helpers. If the project has wrappers for file IO, path-relative IO, process spawning, memory allocation, logging, locking, or platform compatibility, prefer those wrappers over generic libc/std APIs. Do not invent a reproducer or user-visible failure that is not in the evidence bundle; if the evidence is profiler-only or indirect, describe it as a targeted mitigation or stop with a diagnosis instead of presenting a speculative patch as a confirmed bug fix. In the plan and final validation, name any such helper, convention, or evidence limit you found, or say that no relevant local helper was found. Treat this as a `openssh` upstream patch, not just a Debian-local workaround. 

Keep the change narrowly scoped and summarize validation clearly.

In every authoring pass, your final response must start with `Subject: <single-line git commit subject>` and then include these markdown sections exactly:

## Commit Message
A short upstream-friendly explanation of what changed and why. Write it in plain language that a maintainer can follow without local complaint context. If you use subsystem jargon, define it immediately.

## Evidence Confidence
Exactly one word: `reproduced`, `observed`, or `inferred`. Use `reproduced` only when you reproduced the failure locally with a command or test, and include that command/test in `## Validation`. Use `observed` when Fixer has direct crash/log/trace evidence but you did not independently reproduce it. If `## Git Add Paths` lists source files for an `observed` patch, `## Issue Connection` must explicitly say the failure was observed by Fixer and not independently reproduced. Use `inferred` for profiler/strace/indirect evidence; inferred responses may be no-patch diagnoses or reports, but inferred source patches are not pull-request-ready until stronger evidence is gathered.

## Issue Connection
Write this as maintainer-facing patch mail, not as local Fixer notes. Cover four things explicitly in readable sentences: the user-visible symptom or the exact collected signal, the code-level cause or the cautious inference from evidence, the specific change you made, and the expected effect. Do not invent a reproducer, command line, crash, or user-visible failure that is not present in the evidence bundle. If the evidence is direct-but-not-reproduced, say it was observed by Fixer and not independently reproduced. If the evidence is indirect and you did not gather stronger evidence, do not leave a source diff; write a no-patch diagnosis/report instead. Include an explicit effect sentence such as `The expected effect is ...`, `This should reduce ...`, or `This prevents ...` for source patches. If the logic is non-obvious in code, mention that you added a short explanatory comment.

## Git Add Paths
List the repo-relative paths that belong in the final patch, one per line. Use `None` only when you intentionally made no source changes. Include intentionally new files, and do not list generated build artifacts.

## Validation
List the checks you ran, or say clearly that you could not run them. Include the independent reproduction command/test and result when `## Evidence Confidence` is `reproduced`; if reproduction was attempted but blocked, name the exact blocker and keep confidence at `observed` or `inferred`.

Before editing, read the plan at `./plan-output.txt` and follow it unless the code proves part of it wrong. If you change course, say so explicitly in the final write-up instead of silently drifting from the plan.

## Review Pass 1

You are reviewing a freshly generated fixer patch.

Read the evidence bundle at `./evidence.json`. The prepared workspace is `./workspace` and it was acquired via `debian-vcs-git`. Review the first patch pass. The original pre-edit snapshot is available at `./source` for diffing. The workspace currently changes these repo-relative paths: sshd-auth.c. Verify that `## Git Add Paths` matches this exact set and that `## Issue Connection` explains every shipped functional file.

Upstream-style expectation: before planning or editing, check for contribution/style docs (`CONTRIBUTING`, `HACKING`, `README-hacking`, `README.md`, `docs/`, `dev-docs/`) and scan the touched subsystem for local helpers. If the project has wrappers for file IO, path-relative IO, process spawning, memory allocation, logging, locking, or platform compatibility, prefer those wrappers over generic libc/std APIs. Do not invent a reproducer or user-visible failure that is not in the evidence bundle; if the evidence is profiler-only or indirect, describe it as a targeted mitigation or stop with a diagnosis instead of presenting a speculative patch as a confirmed bug fix. In the plan and final validation, name any such helper, convention, or evidence limit you found, or say that no relevant local helper was found. Treat this as a `openssh` upstream patch, not just a Debian-local workaround.

Validation expectation: try the project-level build/test entrypoint from the workspace root before reporting only a focused leaf compile. Detected candidate(s): `./configure && make`, `make` and, if available, `make check`. If the project-level command fails because dependencies or generated files are missing, include the exact command and failure reason in `## Validation`, then run the narrowest relevant compile/test that is still reproducible from a clean checkout. The latest author response is at `./patch-output.txt`. Inspect the current code and changed paths like a strict code reviewer. Focus on correctness, regressions, maintainability, awkward control flow such as avoidable `goto`, missing validation, weak or non-gittable commit message text, and explanations that fail to connect the observed issue evidence to the code change. Also review the maintainer experience: the patch mail should be easy to accept upstream, the user-visible bug should be explained in plain language, subsystem-specific jargon should be defined when first used, and any non-obvious state translation or index remapping in code should have a short explanatory comment. Reject patches that omit `## Evidence Confidence`, use anything other than `reproduced`, `observed`, or `inferred`, or sound more certain than that evidence level allows. Reject patches that claim `reproduced` unless `## Validation` names the concrete reproduction command or test and its result. Reject patches that invent a reproducer, command line, crash, or user-visible failure not present in the evidence bundle; indirect profiler or strace evidence may justify a cautious mitigation, but the author must say it is indirect instead of presenting it as a confirmed upstream bug. Reject patches that introduce generic libc/std APIs when nearby code or project docs provide a local compat/helper API for the same job, unless the author explicitly justifies the exception. Reject validation that only reports a leaf object/syntax build when a project-level configure/build/test entrypoint exists and was not attempted; if a full build cannot run, the author must show the exact failed command and blocker.

Do not apply code changes in this pass.

Return a short markdown review report. The first non-empty line must be exactly one of:

RESULT: ok
RESULT: fix-needed

If you choose `RESULT: fix-needed`, add a `## Findings` section with concrete, actionable items.

Response

## Plan Pass

## Problem
`sshd-auth` was observed by Fixer in a suspected pre-auth busy-poll path, but the captured strace ends with `ECONNRESET` and process exit, so the evidence does not prove an infinite loop. A concrete upstream code gap remains: unlike `sshd-session.c`, split `sshd-auth.c` resets `SIGALRM` and enters KEX/authentication without arming the configured `LoginGraceTime` alarm.

## Evidence Confidence
observed

## Proposed Subject
`sshd-auth: enforce LoginGraceTime during pre-authentication`

## Patch Plan
Mirror the existing `sshd-session.c` login-grace timer in `sshd-auth.c`: add a local `grace_alarm_handler`, install it with `ssh_signal(SIGALRM, ...)`, arm `setitimer(ITIMER_REAL, ...)` before KEX/authentication, and clear it after successful authentication before keystate transfer.

Improve the prior Fixer patch rather than inventing a different fix: keep the same bounded linear control flow, avoid any `goto`, remove style issues such as trailing whitespace, and make the explanation cautious about the observed-but-not-reproduced trace.

Follow OpenSSH local conventions/helpers found in the subsystem: `ssh_signal`, `fatal`, `timerclear`, `arc4random_uniform`, `_exit(EXIT_LOGIN_GRACE)`, plus existing allocation/buffer conventions such as `xcalloc`/`sshbuf` where relevant. No relevant file-I/O or path helper is needed. Style docs found: `README.md`; no `CONTRIBUTING`, `HACKING`, `README-hacking`, `docs/`, or `dev-docs/` were found.

## Risks
The main risk is diverging from `sshd-session.c` behavior by arming the alarm too early or failing to clear it after authentication. The patch should stay close to the existing session implementation and avoid touching monitor IPC, packet loops, or generic poll handling.

Because the evidence is trace/profiler evidence and not a local reproduction, the final `## Issue Connection` must say the failure was observed by Fixer and not independently reproduced.

## Validation
First try the project-level entrypoint from the workspace root:

```sh
./configure && make
```

If that fails due to stale generated files or missing dependencies, report the exact failure, then run the narrowest reproducible focused build, likely:

```sh
make sshd-auth.o
```

Also attempt one bounded independent smoke check: run a temporary local `sshd` config with `LoginGraceTime 1`, connect and stall during pre-auth, and confirm the `sshd-auth` worker exits via the grace timeout. Do not claim `reproduced` unless that smoke check actually demonstrates the failure/fix signal.

## Patch Pass

Subject: sshd-auth: enforce LoginGraceTime during pre-authentication

## Commit Message
Fixer observed `sshd-auth`, the split helper that handles pre-authentication SSH key exchange and user authentication, in a short trace around sleep, monitor writes, and `ppoll`. The trace does not prove an infinite spin, but it does show the pre-auth helper in the area that should be bounded by `LoginGraceTime`.

`sshd-session.c` already arms that timer before pre-authentication. Mirror that bounded timer setup in `sshd-auth.c`, and clear it after authentication succeeds.

## Evidence Confidence
observed

## Issue Connection
Fixer observed an `sshd-auth: root [net]` process with profiler evidence in `sshd-auth`, a dominant syscall sequence of `clock_nanosleep`, `write`, and `ppoll`, `/proc` state sleeping in `unix_stream_read_generic`, and a captured strace ending with `ECONNRESET` and exit. This was observed by Fixer and not independently reproduced.

The cautious code-level cause is that split `sshd-auth.c` reset `SIGALRM` to the default action and then entered key exchange and authentication without arming the configured `LoginGraceTime` alarm. I improved the prior Fixer patch by keeping the same bounded linear control flow, cleaning up style, and adding only the timer setup/clear logic already used by the nearby session path.

The change uses existing OpenSSH conventions and helpers: `ssh_signal`, `setitimer`, `timerclear`, `arc4random_uniform`, `fatal`, and `_exit(EXIT_LOGIN_GRACE)`. `README.md` was the only contribution/style document found; no relevant local file-I/O, path, process-spawn, allocation, or locking helper was needed for this change. The expected effect is that slow or wedged `sshd-auth` pre-authentication workers are terminated by the configured login grace timeout instead of being allowed to remain in pre-authentication indefinitely.

## Git Add Paths
sshd-auth.c

## Validation
`./configure && make` from the workspace root failed first with:
`configure: error: ./m4/openssh.m4 newer than configure, run autoreconf`

Because this git checkout had stale generated-file timestamps, I then ran:
`touch configure && ./configure && make`

That completed successfully and built `sshd-auth`.

I also ran:
`git diff --check`

That completed with no whitespace/style errors.

Bounded independent runtime smoke was attempted with a temporary `sshd` config using `LoginGraceTime 1` and the built `sshd-session`/`sshd-auth` paths, but the environment blocked startup before any socket test:
`Missing privilege separation directory: /var/empty`

Confidence remains `observed`, not `reproduced`.

## Review Pass 1

RESULT: ok

No blocking findings.

The changed path set is exactly `sshd-auth.c`, and `## Git Add Paths` matches it. The issue connection explains the only shipped functional file and stays appropriately cautious: it says the Fixer trace was observed, not independently reproduced, and does not claim a confirmed infinite spin.

The patch follows the nearby `sshd-session.c` timer pattern and uses local OpenSSH conventions/helpers (`ssh_signal`, `setitimer`, `timerclear`, `arc4random_uniform`, `fatal`, `_exit(EXIT_LOGIN_GRACE)`). No avoidable `goto` or unrelated API churn was introduced.

Validation is acceptable for this pass: the author attempted `./configure && make`, reported the stale generated-file blocker, then completed `touch configure && ./configure && make`, and documented the runtime smoke blocker. I also confirmed `make check` is not available in this generated Makefile.

Diff

diff --git a/sshd-auth.c b/sshd-auth.c
index 502a342..07384ca 100644
--- a/sshd-auth.c
+++ b/sshd-auth.c
@@ -175,6 +175,17 @@ mm_is_monitor(void)
 	return 0;
 }
 
+/*
+ * Signal handler for the alarm after the login grace period has expired.
+ * As usual, this may only take signal-safe actions, even though it is
+ * terminal.
+ */
+static void
+grace_alarm_handler(int sig)
+{
+	_exit(EXIT_LOGIN_GRACE);
+}
+
 static void
 privsep_child_demote(void)
 {
@@ -445,6 +456,7 @@ main(int ac, char **av)
 	Authctxt *authctxt;
 	struct connection_info *connection_info = NULL;
 	sigset_t sigmask;
+	struct itimerval itv;
 	uint64_t timing_secret = 0;
 
 	closefrom(PRIVSEP_MIN_FREE_FD);
@@ -725,6 +737,27 @@ main(int ac, char **av)
 	ssh_signal(SIGQUIT, SIG_DFL);
 	ssh_signal(SIGCHLD, SIG_DFL);
 
+	/*
+	 * We don't want to listen forever unless the other side
+	 * successfully authenticates itself.  So we set up an alarm which is
+	 * cleared after successful authentication.  A limit of zero
+	 * indicates no limit. Note that we don't set the alarm in debugging
+	 * mode; it is just annoying to have the server exit just when you
+	 * are about to discover the bug.
+	 */
+	ssh_signal(SIGALRM, grace_alarm_handler);
+	if (!debug_flag && options.login_grace_time > 0) {
+		int ujitter = arc4random_uniform(4 * 1000000);
+
+		timerclear(&itv.it_interval);
+		itv.it_value.tv_sec = options.login_grace_time;
+		itv.it_value.tv_sec += ujitter / 1000000;
+		itv.it_value.tv_usec = ujitter % 1000000;
+
+		if (setitimer(ITIMER_REAL, &itv, NULL) == -1)
+			fatal("login grace time setitimer failed");
+	}
+
 	/* Prepare the channels layer */
 	channel_init_channels(ssh);
 	channel_set_af(ssh, options.address_family);
@@ -761,6 +794,16 @@ main(int ac, char **av)
 	do_ssh2_kex(ssh);
 	do_authentication2(ssh);
 
+	/*
+	 * Cancel the alarm we set to limit the time taken for
+	 * authentication.
+	 */
+	timerclear(&itv.it_interval);
+	timerclear(&itv.it_value);
+	if (setitimer(ITIMER_REAL, &itv, NULL) == -1)
+		fatal("login grace time clear failed");
+	ssh_signal(SIGALRM, SIG_DFL);
+
 	/*
 	 * The unprivileged child now transfers the current keystate and exits.
 	 */

ready patch attempt

patch

sshd-auth likely remains stuck in a busy-poll loop. A diagnosis report and patch proposal were created locally.

state: readycreated: 2026-05-11 05:08 UTCvalidation: ready
Published session

Prompt

## Plan Pass

You are planning a fixer patch before any edits happen.

Read the evidence bundle at `./evidence.json`. The prepared workspace is `./workspace` and it was acquired via `debian-source`. The original pre-edit snapshot is available at `./source` if you need to inspect it. For interpreter processes, plan from the script/application entrypoint evidence first and include the runtime only as a second investigation target unless the evidence proves a runtime bug.

Validation expectation: try the project-level build/test entrypoint from the workspace root before reporting only a focused leaf compile. Detected candidate(s): `./configure && make`. If the project-level command fails because dependencies or generated files are missing, include the exact command and failure reason in `## Validation`, then run the narrowest relevant compile/test that is still reproducible from a clean checkout.

Upstream-style expectation: before planning or editing, check for contribution/style docs (`CONTRIBUTING`, `HACKING`, `README-hacking`, `README.md`, `docs/`, `dev-docs/`) and scan the touched subsystem for local helpers. If the project has wrappers for file IO, path-relative IO, process spawning, memory allocation, logging, locking, or platform compatibility, prefer those wrappers over generic libc/std APIs. Do not invent a reproducer or user-visible failure that is not in the evidence bundle; if the evidence is profiler-only or indirect, describe it as a targeted mitigation or stop with a diagnosis instead of presenting a speculative patch as a confirmed bug fix. In the plan and final validation, name any such helper, convention, or evidence limit you found, or say that no relevant local helper was found. Treat this as a `openssh` upstream patch, not just a Debian-local workaround. Inspect the relevant code, nearby callers, project contribution docs, and local helper/compat APIs, but do not edit files in this pass.

Return a short markdown plan with these exact sections:

## Problem
## Evidence Confidence
## Proposed Subject
## Patch Plan
## Risks
## Validation

Classify `## Evidence Confidence` as exactly one of `reproduced`, `observed`, or `inferred`. Use `inferred` only for a no-patch diagnosis/report plan unless you can name the extra evidence you will collect before editing; inferred source patches are blocked by Fixer because they are not pull-request-ready. For `observed` source-patch plans, plan to say in the final `## Issue Connection` that the failure was observed by Fixer and not independently reproduced. The plan must explain how the proposed code change addresses the observed issue evidence, call out any prior Fixer patch that should be improved or replaced, reject awkward control flow such as avoidable `goto` if there is a cleaner bounded alternative, name any local helper APIs or maintainer conventions the patch should follow, and keep the intended maintainer-facing explanation clear enough that someone unfamiliar with the local complaint wording can still follow the fix. In `## Validation`, name the reproducible configure/build/test entrypoint you will try from the workspace root before any focused leaf compile or smoke check, and include one bounded independent reproduction attempt for the collected failure signal when it is safe and cheap. Do not plan to claim `reproduced` unless that reproduction command or test can actually show the failure.

## Patch Pass

You are working on a bounded fixer proposal.

Read the evidence bundle at `./evidence.json`. The prepared workspace is `./workspace` and it was acquired via `debian-source`. Produce the smallest reasonable patch for the target repository, keep the change upstreamable, prefer the clearest control flow available, and do not keep avoidable `goto` when a simpler structure would read better. Before introducing new file, process, allocation, locking, networking, or platform APIs, inspect nearby code and project contribution docs for existing helpers or compatibility wrappers and use those local patterns unless you can explain why they do not fit. Validate from a reproducible workspace-root entrypoint before falling back to focused leaf commands; if a build or test cannot run, report the exact command, the exact blocker, and any narrower check you ran instead. During validation, also try one bounded independent reproduction of the collected failure signal when it is safe and cheap, such as a failing test, smoke command, perf/strace comparison, or before/after runtime check. Only use `reproduced` if that command or test actually reproduced the failure; otherwise keep `observed` and report the reproduction blocker. The final explanation must connect the observed issue evidence to the actual code change, not just paraphrase the diff. Write like a maintainer is going to read the patch mail cold: explain the bug in plain language, define subsystem-specific jargon the first time you need it, and make the causal story obvious. Explicitly classify evidence confidence as `reproduced`, `observed`, or `inferred`: `reproduced` means you reproduced the failure locally; `observed` means Fixer has direct crash/log/trace evidence but you did not independently reproduce it; `inferred` means the source patch is not pull-request-ready, so do not leave a source diff unless you first gather stronger observed/reproduced evidence; otherwise return a no-patch diagnosis/report. For any source-changing `observed` patch, say explicitly in `## Issue Connection` that the failure was observed by Fixer and not independently reproduced. If you introduce non-obvious state translation, index remapping, or backend split logic, add a short source comment that explains the invariant being preserved.

Start by explaining the likely root cause from the collected perf, strace, and /proc evidence. If you cannot land a safe patch, leave a diagnosis that is strong enough for an upstream bug report.

Validation expectation: try the project-level build/test entrypoint from the workspace root before reporting only a focused leaf compile. Detected candidate(s): `./configure && make`. If the project-level command fails because dependencies or generated files are missing, include the exact command and failure reason in `## Validation`, then run the narrowest relevant compile/test that is still reproducible from a clean checkout.

Upstream-style expectation: before planning or editing, check for contribution/style docs (`CONTRIBUTING`, `HACKING`, `README-hacking`, `README.md`, `docs/`, `dev-docs/`) and scan the touched subsystem for local helpers. If the project has wrappers for file IO, path-relative IO, process spawning, memory allocation, logging, locking, or platform compatibility, prefer those wrappers over generic libc/std APIs. Do not invent a reproducer or user-visible failure that is not in the evidence bundle; if the evidence is profiler-only or indirect, describe it as a targeted mitigation or stop with a diagnosis instead of presenting a speculative patch as a confirmed bug fix. In the plan and final validation, name any such helper, convention, or evidence limit you found, or say that no relevant local helper was found. Treat this as a `openssh` upstream patch, not just a Debian-local workaround. 

Keep the change narrowly scoped and summarize validation clearly.

In every authoring pass, your final response must start with `Subject: <single-line git commit subject>` and then include these markdown sections exactly:

## Commit Message
A short upstream-friendly explanation of what changed and why. Write it in plain language that a maintainer can follow without local complaint context. If you use subsystem jargon, define it immediately.

## Evidence Confidence
Exactly one word: `reproduced`, `observed`, or `inferred`. Use `reproduced` only when you reproduced the failure locally with a command or test, and include that command/test in `## Validation`. Use `observed` when Fixer has direct crash/log/trace evidence but you did not independently reproduce it. If `## Git Add Paths` lists source files for an `observed` patch, `## Issue Connection` must explicitly say the failure was observed by Fixer and not independently reproduced. Use `inferred` for profiler/strace/indirect evidence; inferred responses may be no-patch diagnoses or reports, but inferred source patches are not pull-request-ready until stronger evidence is gathered.

## Issue Connection
Write this as maintainer-facing patch mail, not as local Fixer notes. Cover four things explicitly in readable sentences: the user-visible symptom or the exact collected signal, the code-level cause or the cautious inference from evidence, the specific change you made, and the expected effect. Do not invent a reproducer, command line, crash, or user-visible failure that is not present in the evidence bundle. If the evidence is direct-but-not-reproduced, say it was observed by Fixer and not independently reproduced. If the evidence is indirect and you did not gather stronger evidence, do not leave a source diff; write a no-patch diagnosis/report instead. Include an explicit effect sentence such as `The expected effect is ...`, `This should reduce ...`, or `This prevents ...` for source patches. If the logic is non-obvious in code, mention that you added a short explanatory comment.

## Git Add Paths
List the repo-relative paths that belong in the final patch, one per line. Use `None` only when you intentionally made no source changes. Include intentionally new files, and do not list generated build artifacts.

## Validation
List the checks you ran, or say clearly that you could not run them. Include the independent reproduction command/test and result when `## Evidence Confidence` is `reproduced`; if reproduction was attempted but blocked, name the exact blocker and keep confidence at `observed` or `inferred`.

Before editing, read the plan at `./plan-output.txt` and follow it unless the code proves part of it wrong. If you change course, say so explicitly in the final write-up instead of silently drifting from the plan.

## Review Pass 1

You are reviewing a freshly generated fixer patch.

Read the evidence bundle at `./evidence.json`. The prepared workspace is `./workspace` and it was acquired via `debian-source`. Review the first patch pass. The original pre-edit snapshot is available at `./source` for diffing. The workspace currently changes these repo-relative paths: sshd-auth.c. Verify that `## Git Add Paths` matches this exact set and that `## Issue Connection` explains every shipped functional file.

Upstream-style expectation: before planning or editing, check for contribution/style docs (`CONTRIBUTING`, `HACKING`, `README-hacking`, `README.md`, `docs/`, `dev-docs/`) and scan the touched subsystem for local helpers. If the project has wrappers for file IO, path-relative IO, process spawning, memory allocation, logging, locking, or platform compatibility, prefer those wrappers over generic libc/std APIs. Do not invent a reproducer or user-visible failure that is not in the evidence bundle; if the evidence is profiler-only or indirect, describe it as a targeted mitigation or stop with a diagnosis instead of presenting a speculative patch as a confirmed bug fix. In the plan and final validation, name any such helper, convention, or evidence limit you found, or say that no relevant local helper was found. Treat this as a `openssh` upstream patch, not just a Debian-local workaround.

Validation expectation: try the project-level build/test entrypoint from the workspace root before reporting only a focused leaf compile. Detected candidate(s): `./configure && make`, `make` and, if available, `make check`. If the project-level command fails because dependencies or generated files are missing, include the exact command and failure reason in `## Validation`, then run the narrowest relevant compile/test that is still reproducible from a clean checkout. The latest author response is at `./patch-output.txt`. Inspect the current code and changed paths like a strict code reviewer. Focus on correctness, regressions, maintainability, awkward control flow such as avoidable `goto`, missing validation, weak or non-gittable commit message text, and explanations that fail to connect the observed issue evidence to the code change. Also review the maintainer experience: the patch mail should be easy to accept upstream, the user-visible bug should be explained in plain language, subsystem-specific jargon should be defined when first used, and any non-obvious state translation or index remapping in code should have a short explanatory comment. Reject patches that omit `## Evidence Confidence`, use anything other than `reproduced`, `observed`, or `inferred`, or sound more certain than that evidence level allows. Reject patches that claim `reproduced` unless `## Validation` names the concrete reproduction command or test and its result. Reject patches that invent a reproducer, command line, crash, or user-visible failure not present in the evidence bundle; indirect profiler or strace evidence may justify a cautious mitigation, but the author must say it is indirect instead of presenting it as a confirmed upstream bug. Reject patches that introduce generic libc/std APIs when nearby code or project docs provide a local compat/helper API for the same job, unless the author explicitly justifies the exception. Reject validation that only reports a leaf object/syntax build when a project-level configure/build/test entrypoint exists and was not attempted; if a full build cannot run, the author must show the exact failed command and blocker.

Do not apply code changes in this pass.

Return a short markdown review report. The first non-empty line must be exactly one of:

RESULT: ok
RESULT: fix-needed

If you choose `RESULT: fix-needed`, add a `## Findings` section with concrete, actionable items.

Response

## Plan Pass

## Problem
`sshd-auth` was observed by Fixer as a pre-auth worker with a short hot path through `clock_nanosleep`, `write`, and `ppoll`. The captured strace ends with `ECONNRESET` and process exit, so this is not independently proven to be an infinite busy loop. A concrete code concern is that split `sshd-auth.c` does not mirror `sshd-session.c`’s `LoginGraceTime` alarm around pre-auth KEX/authentication, so stalled pre-auth workers may be less tightly bounded.

## Evidence Confidence
observed

## Proposed Subject
`sshd-auth: enforce LoginGraceTime during pre-authentication`

## Patch Plan
Add the same bounded login-grace timer pattern used by `sshd-session.c`: a local `grace_alarm_handler`, `ssh_signal(SIGALRM, ...)`, `setitimer(ITIMER_REAL, ...)` with the existing `arc4random_uniform` jitter convention, and timer cleanup after successful authentication.

Keep the change in `sshd-auth.c`, after config defaults are available and before KEX/authentication begins. Clear the timer before transferring keystate to the post-auth process. Use existing OpenSSH conventions/helpers: `ssh_signal`, `fatal`, `timerclear`, `setitimer`, `arc4random_uniform`, and direct `_exit(EXIT_LOGIN_GRACE)` from the signal handler. No relevant file IO/path/process-spawn helper is needed for this change. Avoid awkward `goto`; the setup/clear points are bounded and linear.

No prior Fixer patch was present in the workspace to replace or improve.

## Risks
The main risk is behavior drift from `sshd-session.c` if the alarm is installed too early or left armed after authentication. The patch should mirror the established session code closely and avoid touching monitor IPC (`mm_request_*`, `atomicio`) or packet-loop logic.

Because the evidence is profiler-only and the raw artifact path is unavailable in this workspace, the final issue connection must say the failure was observed by Fixer and not independently reproduced unless validation produces a matching stalled worker.

## Validation
First try the project entrypoint from the workspace root:

```sh
./configure && make
```

If that fails due to missing dependencies/generated files, report the exact command and failure reason, then run the narrowest reproducible compile such as:

```sh
make sshd-auth.o
```

Also run a bounded independent smoke attempt: start the built `sshd` with a temporary config using `LoginGraceTime 1`, connect locally with a client/socket that sends an SSH banner and then stalls, and confirm any `sshd-auth` pre-auth worker exits with the grace timeout rather than lingering.

## Patch Pass

Subject: sshd-auth: enforce LoginGraceTime during pre-authentication

## Commit Message
`sshd-auth` is the split pre-authentication helper that handles key exchange and user authentication before the session process takes over. Unlike the older combined `sshd-session` path, it reset `SIGALRM` to the default action and then entered pre-authentication without arming the configured `LoginGraceTime` timer.

Mirror the existing `sshd-session` timer pattern in `sshd-auth`: install a login-grace alarm before key exchange and authentication, and clear it after authentication succeeds. This keeps pre-authentication work bounded by the configured grace period.

## Evidence Confidence
observed

## Issue Connection
Fixer observed an `sshd-auth: root [net]` process with profiler and trace evidence around `clock_nanosleep`, `write`, and `ppoll`; `/proc` showed it sleeping in `unix_stream_read_generic`, and the captured strace ended in `ECONNRESET` followed by exit. This was observed by Fixer and not independently reproduced.

The evidence does not prove an infinite CPU spin. The code-level gap is that `sshd-auth.c` enters KEX, meaning SSH key exchange, and authentication without the `LoginGraceTime` alarm that `sshd-session.c` uses to bound unauthenticated connections. I followed the saved plan and added the same local timeout structure to `sshd-auth.c`, using existing OpenSSH conventions and helpers: `ssh_signal`, `setitimer`, `timerclear`, `arc4random_uniform`, and the existing signal-safe `_exit(EXIT_LOGIN_GRACE)` style. No new file IO, process-spawning, allocation, locking, networking, or platform API was introduced.

The expected effect is that slow or wedged `sshd-auth` pre-authentication workers are terminated by the configured login grace timeout instead of being allowed to remain in KEX/authentication indefinitely.

## Git Add Paths
sshd-auth.c

## Validation
`./configure && make` from the workspace root failed initially with:
`configure: error: ./configure.ac newer than configure, run autoreconf`

A direct focused compile also failed before configure generated headers:
`make sshd-auth.o`
blocked by `includes.h:19:10: fatal error: config.h: No such file or directory`

After refreshing only the `configure` timestamp to satisfy the source package’s stale timestamp check, `touch configure && ./configure && make` completed successfully. `make sshd-auth` also completed successfully afterward.

Bounded independent runtime reproduction was attempted with a local `sshd` smoke setup using temporary host keys and the built `sshd-session`/`sshd-auth` paths, but the sandbox blocked local socket creation:
`PermissionError: [Errno 1] Operation not permitted`

A non-network `sshd -t -f <temp config>` parse check was also blocked by the environment because `/var/empty` is missing:
`Missing privilege separation directory: /var/empty`

## Review Pass 1

RESULT: ok

No blocking findings.

`## Git Add Paths` matches the current changed file set exactly: `sshd-auth.c`.

The patch is narrowly scoped and follows the nearby `sshd-session.c` timer pattern using existing OpenSSH helpers/conventions: `ssh_signal`, `setitimer`, `timerclear`, `arc4random_uniform`, `fatal`, and signal-safe `_exit`. The write-up stays appropriately cautious: it says the Fixer trace was observed but not independently reproduced, and it does not claim the evidence proves an infinite CPU spin.

Validation is acceptable for this pass: the author reported the initial project-level `./configure && make` blocker, then got a full build through with `touch configure && ./configure && make`, and documented why the bounded runtime smoke check could not run in the sandbox. `make check` is not available in the generated Makefile (`No rule to make target 'check'`).

Diff

diff --git a/sshd-auth.c b/sshd-auth.c
index 502a342..07384ca 100644
--- a/sshd-auth.c
+++ b/sshd-auth.c
@@ -175,6 +175,17 @@ mm_is_monitor(void)
 	return 0;
 }
 
+/*
+ * Signal handler for the alarm after the login grace period has expired.
+ * As usual, this may only take signal-safe actions, even though it is
+ * terminal.
+ */
+static void
+grace_alarm_handler(int sig)
+{
+	_exit(EXIT_LOGIN_GRACE);
+}
+
 static void
 privsep_child_demote(void)
 {
@@ -445,6 +456,7 @@ main(int ac, char **av)
 	Authctxt *authctxt;
 	struct connection_info *connection_info = NULL;
 	sigset_t sigmask;
+	struct itimerval itv;
 	uint64_t timing_secret = 0;
 
 	closefrom(PRIVSEP_MIN_FREE_FD);
@@ -725,6 +737,27 @@ main(int ac, char **av)
 	ssh_signal(SIGQUIT, SIG_DFL);
 	ssh_signal(SIGCHLD, SIG_DFL);
 
+	/*
+	 * We don't want to listen forever unless the other side
+	 * successfully authenticates itself.  So we set up an alarm which is
+	 * cleared after successful authentication.  A limit of zero
+	 * indicates no limit. Note that we don't set the alarm in debugging
+	 * mode; it is just annoying to have the server exit just when you
+	 * are about to discover the bug.
+	 */
+	ssh_signal(SIGALRM, grace_alarm_handler);
+	if (!debug_flag && options.login_grace_time > 0) {
+		int ujitter = arc4random_uniform(4 * 1000000);
+
+		timerclear(&itv.it_interval);
+		itv.it_value.tv_sec = options.login_grace_time;
+		itv.it_value.tv_sec += ujitter / 1000000;
+		itv.it_value.tv_usec = ujitter % 1000000;
+
+		if (setitimer(ITIMER_REAL, &itv, NULL) == -1)
+			fatal("login grace time setitimer failed");
+	}
+
 	/* Prepare the channels layer */
 	channel_init_channels(ssh);
 	channel_set_af(ssh, options.address_family);
@@ -761,6 +794,16 @@ main(int ac, char **av)
 	do_ssh2_kex(ssh);
 	do_authentication2(ssh);
 
+	/*
+	 * Cancel the alarm we set to limit the time taken for
+	 * authentication.
+	 */
+	timerclear(&itv.it_interval);
+	timerclear(&itv.it_value);
+	if (setitimer(ITIMER_REAL, &itv, NULL) == -1)
+		fatal("login grace time clear failed");
+	ssh_signal(SIGALRM, SIG_DFL);
+
 	/*
 	 * The unprivileged child now transfers the current keystate and exits.
 	 */

ready patch attempt

patch

sshd-auth likely remains stuck in a busy-poll loop. A diagnosis report and patch proposal were created locally.

state: readycreated: 2026-05-11 05:08 UTCvalidation: ready
Published session

Prompt

## Plan Pass

You are planning a fixer patch before any edits happen.

Read the evidence bundle at `./evidence.json`. The prepared workspace is `./workspace` and it was acquired via `debian-source`. The original pre-edit snapshot is available at `./source` if you need to inspect it. For interpreter processes, plan from the script/application entrypoint evidence first and include the runtime only as a second investigation target unless the evidence proves a runtime bug.

Validation expectation: try the project-level build/test entrypoint from the workspace root before reporting only a focused leaf compile. Detected candidate(s): `./configure && make`. If the project-level command fails because dependencies or generated files are missing, include the exact command and failure reason in `## Validation`, then run the narrowest relevant compile/test that is still reproducible from a clean checkout.

Upstream-style expectation: before planning or editing, check for contribution/style docs (`CONTRIBUTING`, `HACKING`, `README-hacking`, `README.md`, `docs/`, `dev-docs/`) and scan the touched subsystem for local helpers. If the project has wrappers for file IO, path-relative IO, process spawning, memory allocation, logging, locking, or platform compatibility, prefer those wrappers over generic libc/std APIs. Do not invent a reproducer or user-visible failure that is not in the evidence bundle; if the evidence is profiler-only or indirect, describe it as a targeted mitigation or stop with a diagnosis instead of presenting a speculative patch as a confirmed bug fix. In the plan and final validation, name any such helper, convention, or evidence limit you found, or say that no relevant local helper was found. Treat this as a `openssh` upstream patch, not just a Debian-local workaround. Inspect the relevant code, nearby callers, project contribution docs, and local helper/compat APIs, but do not edit files in this pass.

Return a short markdown plan with these exact sections:

## Problem
## Evidence Confidence
## Proposed Subject
## Patch Plan
## Risks
## Validation

Classify `## Evidence Confidence` as exactly one of `reproduced`, `observed`, or `inferred`. Use `inferred` only for a no-patch diagnosis/report plan unless you can name the extra evidence you will collect before editing; inferred source patches are blocked by Fixer because they are not pull-request-ready. For `observed` source-patch plans, plan to say in the final `## Issue Connection` that the failure was observed by Fixer and not independently reproduced. The plan must explain how the proposed code change addresses the observed issue evidence, call out any prior Fixer patch that should be improved or replaced, reject awkward control flow such as avoidable `goto` if there is a cleaner bounded alternative, name any local helper APIs or maintainer conventions the patch should follow, and keep the intended maintainer-facing explanation clear enough that someone unfamiliar with the local complaint wording can still follow the fix. In `## Validation`, name the reproducible configure/build/test entrypoint you will try from the workspace root before any focused leaf compile or smoke check, and include one bounded independent reproduction attempt for the collected failure signal when it is safe and cheap. Do not plan to claim `reproduced` unless that reproduction command or test can actually show the failure.

## Patch Pass

You are working on a bounded fixer proposal.

Read the evidence bundle at `./evidence.json`. The prepared workspace is `./workspace` and it was acquired via `debian-source`. Produce the smallest reasonable patch for the target repository, keep the change upstreamable, prefer the clearest control flow available, and do not keep avoidable `goto` when a simpler structure would read better. Before introducing new file, process, allocation, locking, networking, or platform APIs, inspect nearby code and project contribution docs for existing helpers or compatibility wrappers and use those local patterns unless you can explain why they do not fit. Validate from a reproducible workspace-root entrypoint before falling back to focused leaf commands; if a build or test cannot run, report the exact command, the exact blocker, and any narrower check you ran instead. During validation, also try one bounded independent reproduction of the collected failure signal when it is safe and cheap, such as a failing test, smoke command, perf/strace comparison, or before/after runtime check. Only use `reproduced` if that command or test actually reproduced the failure; otherwise keep `observed` and report the reproduction blocker. The final explanation must connect the observed issue evidence to the actual code change, not just paraphrase the diff. Write like a maintainer is going to read the patch mail cold: explain the bug in plain language, define subsystem-specific jargon the first time you need it, and make the causal story obvious. Explicitly classify evidence confidence as `reproduced`, `observed`, or `inferred`: `reproduced` means you reproduced the failure locally; `observed` means Fixer has direct crash/log/trace evidence but you did not independently reproduce it; `inferred` means the source patch is not pull-request-ready, so do not leave a source diff unless you first gather stronger observed/reproduced evidence; otherwise return a no-patch diagnosis/report. For any source-changing `observed` patch, say explicitly in `## Issue Connection` that the failure was observed by Fixer and not independently reproduced. If you introduce non-obvious state translation, index remapping, or backend split logic, add a short source comment that explains the invariant being preserved.

Start by explaining the likely root cause from the collected perf, strace, and /proc evidence. If you cannot land a safe patch, leave a diagnosis that is strong enough for an upstream bug report.

Validation expectation: try the project-level build/test entrypoint from the workspace root before reporting only a focused leaf compile. Detected candidate(s): `./configure && make`. If the project-level command fails because dependencies or generated files are missing, include the exact command and failure reason in `## Validation`, then run the narrowest relevant compile/test that is still reproducible from a clean checkout.

Upstream-style expectation: before planning or editing, check for contribution/style docs (`CONTRIBUTING`, `HACKING`, `README-hacking`, `README.md`, `docs/`, `dev-docs/`) and scan the touched subsystem for local helpers. If the project has wrappers for file IO, path-relative IO, process spawning, memory allocation, logging, locking, or platform compatibility, prefer those wrappers over generic libc/std APIs. Do not invent a reproducer or user-visible failure that is not in the evidence bundle; if the evidence is profiler-only or indirect, describe it as a targeted mitigation or stop with a diagnosis instead of presenting a speculative patch as a confirmed bug fix. In the plan and final validation, name any such helper, convention, or evidence limit you found, or say that no relevant local helper was found. Treat this as a `openssh` upstream patch, not just a Debian-local workaround. 

Keep the change narrowly scoped and summarize validation clearly.

In every authoring pass, your final response must start with `Subject: <single-line git commit subject>` and then include these markdown sections exactly:

## Commit Message
A short upstream-friendly explanation of what changed and why. Write it in plain language that a maintainer can follow without local complaint context. If you use subsystem jargon, define it immediately.

## Evidence Confidence
Exactly one word: `reproduced`, `observed`, or `inferred`. Use `reproduced` only when you reproduced the failure locally with a command or test, and include that command/test in `## Validation`. Use `observed` when Fixer has direct crash/log/trace evidence but you did not independently reproduce it. If `## Git Add Paths` lists source files for an `observed` patch, `## Issue Connection` must explicitly say the failure was observed by Fixer and not independently reproduced. Use `inferred` for profiler/strace/indirect evidence; inferred responses may be no-patch diagnoses or reports, but inferred source patches are not pull-request-ready until stronger evidence is gathered.

## Issue Connection
Write this as maintainer-facing patch mail, not as local Fixer notes. Cover four things explicitly in readable sentences: the user-visible symptom or the exact collected signal, the code-level cause or the cautious inference from evidence, the specific change you made, and the expected effect. Do not invent a reproducer, command line, crash, or user-visible failure that is not present in the evidence bundle. If the evidence is direct-but-not-reproduced, say it was observed by Fixer and not independently reproduced. If the evidence is indirect and you did not gather stronger evidence, do not leave a source diff; write a no-patch diagnosis/report instead. Include an explicit effect sentence such as `The expected effect is ...`, `This should reduce ...`, or `This prevents ...` for source patches. If the logic is non-obvious in code, mention that you added a short explanatory comment.

## Git Add Paths
List the repo-relative paths that belong in the final patch, one per line. Use `None` only when you intentionally made no source changes. Include intentionally new files, and do not list generated build artifacts.

## Validation
List the checks you ran, or say clearly that you could not run them. Include the independent reproduction command/test and result when `## Evidence Confidence` is `reproduced`; if reproduction was attempted but blocked, name the exact blocker and keep confidence at `observed` or `inferred`.

Before editing, read the plan at `./plan-output.txt` and follow it unless the code proves part of it wrong. If you change course, say so explicitly in the final write-up instead of silently drifting from the plan.

## Review Pass 1

You are reviewing a freshly generated fixer patch.

Read the evidence bundle at `./evidence.json`. The prepared workspace is `./workspace` and it was acquired via `debian-source`. Review the first patch pass. The original pre-edit snapshot is available at `./source` for diffing. The workspace currently changes these repo-relative paths: sshd-auth.c. Verify that `## Git Add Paths` matches this exact set and that `## Issue Connection` explains every shipped functional file.

Upstream-style expectation: before planning or editing, check for contribution/style docs (`CONTRIBUTING`, `HACKING`, `README-hacking`, `README.md`, `docs/`, `dev-docs/`) and scan the touched subsystem for local helpers. If the project has wrappers for file IO, path-relative IO, process spawning, memory allocation, logging, locking, or platform compatibility, prefer those wrappers over generic libc/std APIs. Do not invent a reproducer or user-visible failure that is not in the evidence bundle; if the evidence is profiler-only or indirect, describe it as a targeted mitigation or stop with a diagnosis instead of presenting a speculative patch as a confirmed bug fix. In the plan and final validation, name any such helper, convention, or evidence limit you found, or say that no relevant local helper was found. Treat this as a `openssh` upstream patch, not just a Debian-local workaround.

Validation expectation: try the project-level build/test entrypoint from the workspace root before reporting only a focused leaf compile. Detected candidate(s): `./configure && make`, `make` and, if available, `make check`. If the project-level command fails because dependencies or generated files are missing, include the exact command and failure reason in `## Validation`, then run the narrowest relevant compile/test that is still reproducible from a clean checkout. The latest author response is at `./patch-output.txt`. Inspect the current code and changed paths like a strict code reviewer. Focus on correctness, regressions, maintainability, awkward control flow such as avoidable `goto`, missing validation, weak or non-gittable commit message text, and explanations that fail to connect the observed issue evidence to the code change. Also review the maintainer experience: the patch mail should be easy to accept upstream, the user-visible bug should be explained in plain language, subsystem-specific jargon should be defined when first used, and any non-obvious state translation or index remapping in code should have a short explanatory comment. Reject patches that omit `## Evidence Confidence`, use anything other than `reproduced`, `observed`, or `inferred`, or sound more certain than that evidence level allows. Reject patches that claim `reproduced` unless `## Validation` names the concrete reproduction command or test and its result. Reject patches that invent a reproducer, command line, crash, or user-visible failure not present in the evidence bundle; indirect profiler or strace evidence may justify a cautious mitigation, but the author must say it is indirect instead of presenting it as a confirmed upstream bug. Reject patches that introduce generic libc/std APIs when nearby code or project docs provide a local compat/helper API for the same job, unless the author explicitly justifies the exception. Reject validation that only reports a leaf object/syntax build when a project-level configure/build/test entrypoint exists and was not attempted; if a full build cannot run, the author must show the exact failed command and blocker.

Do not apply code changes in this pass.

Return a short markdown review report. The first non-empty line must be exactly one of:

RESULT: ok
RESULT: fix-needed

If you choose `RESULT: fix-needed`, add a `## Findings` section with concrete, actionable items.

Response

## Plan Pass

## Problem
`sshd-auth` was observed by Fixer as a pre-auth worker with a short hot path through `clock_nanosleep`, `write`, and `ppoll`. The captured strace ends with `ECONNRESET` and process exit, so this is not independently proven to be an infinite busy loop. A concrete code concern is that split `sshd-auth.c` does not mirror `sshd-session.c`’s `LoginGraceTime` alarm around pre-auth KEX/authentication, so stalled pre-auth workers may be less tightly bounded.

## Evidence Confidence
observed

## Proposed Subject
`sshd-auth: enforce LoginGraceTime during pre-authentication`

## Patch Plan
Add the same bounded login-grace timer pattern used by `sshd-session.c`: a local `grace_alarm_handler`, `ssh_signal(SIGALRM, ...)`, `setitimer(ITIMER_REAL, ...)` with the existing `arc4random_uniform` jitter convention, and timer cleanup after successful authentication.

Keep the change in `sshd-auth.c`, after config defaults are available and before KEX/authentication begins. Clear the timer before transferring keystate to the post-auth process. Use existing OpenSSH conventions/helpers: `ssh_signal`, `fatal`, `timerclear`, `setitimer`, `arc4random_uniform`, and direct `_exit(EXIT_LOGIN_GRACE)` from the signal handler. No relevant file IO/path/process-spawn helper is needed for this change. Avoid awkward `goto`; the setup/clear points are bounded and linear.

No prior Fixer patch was present in the workspace to replace or improve.

## Risks
The main risk is behavior drift from `sshd-session.c` if the alarm is installed too early or left armed after authentication. The patch should mirror the established session code closely and avoid touching monitor IPC (`mm_request_*`, `atomicio`) or packet-loop logic.

Because the evidence is profiler-only and the raw artifact path is unavailable in this workspace, the final issue connection must say the failure was observed by Fixer and not independently reproduced unless validation produces a matching stalled worker.

## Validation
First try the project entrypoint from the workspace root:

```sh
./configure && make
```

If that fails due to missing dependencies/generated files, report the exact command and failure reason, then run the narrowest reproducible compile such as:

```sh
make sshd-auth.o
```

Also run a bounded independent smoke attempt: start the built `sshd` with a temporary config using `LoginGraceTime 1`, connect locally with a client/socket that sends an SSH banner and then stalls, and confirm any `sshd-auth` pre-auth worker exits with the grace timeout rather than lingering.

## Patch Pass

Subject: sshd-auth: enforce LoginGraceTime during pre-authentication

## Commit Message
`sshd-auth` is the split pre-authentication helper that handles key exchange and user authentication before the session process takes over. Unlike the older combined `sshd-session` path, it reset `SIGALRM` to the default action and then entered pre-authentication without arming the configured `LoginGraceTime` timer.

Mirror the existing `sshd-session` timer pattern in `sshd-auth`: install a login-grace alarm before key exchange and authentication, and clear it after authentication succeeds. This keeps pre-authentication work bounded by the configured grace period.

## Evidence Confidence
observed

## Issue Connection
Fixer observed an `sshd-auth: root [net]` process with profiler and trace evidence around `clock_nanosleep`, `write`, and `ppoll`; `/proc` showed it sleeping in `unix_stream_read_generic`, and the captured strace ended in `ECONNRESET` followed by exit. This was observed by Fixer and not independently reproduced.

The evidence does not prove an infinite CPU spin. The code-level gap is that `sshd-auth.c` enters KEX, meaning SSH key exchange, and authentication without the `LoginGraceTime` alarm that `sshd-session.c` uses to bound unauthenticated connections. I followed the saved plan and added the same local timeout structure to `sshd-auth.c`, using existing OpenSSH conventions and helpers: `ssh_signal`, `setitimer`, `timerclear`, `arc4random_uniform`, and the existing signal-safe `_exit(EXIT_LOGIN_GRACE)` style. No new file IO, process-spawning, allocation, locking, networking, or platform API was introduced.

The expected effect is that slow or wedged `sshd-auth` pre-authentication workers are terminated by the configured login grace timeout instead of being allowed to remain in KEX/authentication indefinitely.

## Git Add Paths
sshd-auth.c

## Validation
`./configure && make` from the workspace root failed initially with:
`configure: error: ./configure.ac newer than configure, run autoreconf`

A direct focused compile also failed before configure generated headers:
`make sshd-auth.o`
blocked by `includes.h:19:10: fatal error: config.h: No such file or directory`

After refreshing only the `configure` timestamp to satisfy the source package’s stale timestamp check, `touch configure && ./configure && make` completed successfully. `make sshd-auth` also completed successfully afterward.

Bounded independent runtime reproduction was attempted with a local `sshd` smoke setup using temporary host keys and the built `sshd-session`/`sshd-auth` paths, but the sandbox blocked local socket creation:
`PermissionError: [Errno 1] Operation not permitted`

A non-network `sshd -t -f <temp config>` parse check was also blocked by the environment because `/var/empty` is missing:
`Missing privilege separation directory: /var/empty`

## Review Pass 1

RESULT: ok

No blocking findings.

`## Git Add Paths` matches the current changed file set exactly: `sshd-auth.c`.

The patch is narrowly scoped and follows the nearby `sshd-session.c` timer pattern using existing OpenSSH helpers/conventions: `ssh_signal`, `setitimer`, `timerclear`, `arc4random_uniform`, `fatal`, and signal-safe `_exit`. The write-up stays appropriately cautious: it says the Fixer trace was observed but not independently reproduced, and it does not claim the evidence proves an infinite CPU spin.

Validation is acceptable for this pass: the author reported the initial project-level `./configure && make` blocker, then got a full build through with `touch configure && ./configure && make`, and documented why the bounded runtime smoke check could not run in the sandbox. `make check` is not available in the generated Makefile (`No rule to make target 'check'`).

Diff

diff --git a/sshd-auth.c b/sshd-auth.c
index 502a342..07384ca 100644
--- a/sshd-auth.c
+++ b/sshd-auth.c
@@ -175,6 +175,17 @@ mm_is_monitor(void)
 	return 0;
 }
 
+/*
+ * Signal handler for the alarm after the login grace period has expired.
+ * As usual, this may only take signal-safe actions, even though it is
+ * terminal.
+ */
+static void
+grace_alarm_handler(int sig)
+{
+	_exit(EXIT_LOGIN_GRACE);
+}
+
 static void
 privsep_child_demote(void)
 {
@@ -445,6 +456,7 @@ main(int ac, char **av)
 	Authctxt *authctxt;
 	struct connection_info *connection_info = NULL;
 	sigset_t sigmask;
+	struct itimerval itv;
 	uint64_t timing_secret = 0;
 
 	closefrom(PRIVSEP_MIN_FREE_FD);
@@ -725,6 +737,27 @@ main(int ac, char **av)
 	ssh_signal(SIGQUIT, SIG_DFL);
 	ssh_signal(SIGCHLD, SIG_DFL);
 
+	/*
+	 * We don't want to listen forever unless the other side
+	 * successfully authenticates itself.  So we set up an alarm which is
+	 * cleared after successful authentication.  A limit of zero
+	 * indicates no limit. Note that we don't set the alarm in debugging
+	 * mode; it is just annoying to have the server exit just when you
+	 * are about to discover the bug.
+	 */
+	ssh_signal(SIGALRM, grace_alarm_handler);
+	if (!debug_flag && options.login_grace_time > 0) {
+		int ujitter = arc4random_uniform(4 * 1000000);
+
+		timerclear(&itv.it_interval);
+		itv.it_value.tv_sec = options.login_grace_time;
+		itv.it_value.tv_sec += ujitter / 1000000;
+		itv.it_value.tv_usec = ujitter % 1000000;
+
+		if (setitimer(ITIMER_REAL, &itv, NULL) == -1)
+			fatal("login grace time setitimer failed");
+	}
+
 	/* Prepare the channels layer */
 	channel_init_channels(ssh);
 	channel_set_af(ssh, options.address_family);
@@ -761,6 +794,16 @@ main(int ac, char **av)
 	do_ssh2_kex(ssh);
 	do_authentication2(ssh);
 
+	/*
+	 * Cancel the alarm we set to limit the time taken for
+	 * authentication.
+	 */
+	timerclear(&itv.it_interval);
+	timerclear(&itv.it_value);
+	if (setitimer(ITIMER_REAL, &itv, NULL) == -1)
+		fatal("login grace time clear failed");
+	ssh_signal(SIGALRM, SIG_DFL);
+
 	/*
 	 * The unprivileged child now transfers the current keystate and exits.
 	 */