Package: openssh-server
Version: 1:10.0p1-7+deb13u4
Severity: important
Tags: upstream patch fixed-upstream

Dear Maintainer,

On trixie, the pre-authentication child `sshd-auth` is killed by its seccomp 
sandbox with SIGSYS whenever the process is frozen and thawed while it waits in 
a restartable system call.
On thaw the kernel resumes the interrupted wait through `restart_syscall(2)` 
(x86_64 syscall 219), which the preauth seccomp filter in 10.0p1 does not allow.

This happens routinely on Proxmox VE, which freezes an LXC container (cgroup 
freezer) for a moment to take a ZFS snapshot for storage replication or a 
snapshot-mode backup.
Any SSH connection still in pre-auth at that moment is killed.

What the logs show, from one occurrence on an unprivileged Debian 13 LXC 
container on Proxmox VE 9 (kernel 7.0.14-30-pve):

Proxmox replication log:

    19:48:02 121-0: freeze guest filesystem
    19:48:02 121-0: create snapshot '__replicate_121-0_...' on 
local-zfs:subvol-121-disk-0
    19:48:02 121-0: thaw guest filesystem

Host kernel, same second:

    audit: type=1326 ... subj=lxc-121_... comm="sshd-auth" 
exe="/usr/lib/openssh/sshd-auth" sig=31 arch=c000003e syscall=219 compat=0 ...

sshd in the container:

    sshd-session[...]: error: mm_reap: preauth child terminated by signal 31
    sshd[...]: Session process ... unpriv child crash for connection from 
<client> to <server>
    sshd[...]: drop connection #0 from [<client>]:56714 on [<server>]:22 
penalty: caused crash

The second effect makes the bug worse than one lost connection.
sshd's PerSourcePenalties counts the sandbox kill as a crash caused by the 
client (`crash:90` by default), so for 90 seconds every new connection from 
that client address is dropped before key exchange.
The client sees `kex_exchange_identification: read: Connection reset by peer`, 
although it did nothing wrong.
On a host that is reached by automation from one address (configuration 
management, backups, monitoring), one routine snapshot locks that automation 
out.

Reproduction (we saw it through Proxmox's own replication; these steps follow 
from the mechanism and were not run by hand):

1. On Proxmox VE 9, create an LXC container from the Debian 13 template with 
openssh-server 1:10.0p1-7+deb13u4.
2. From a client, open SSH connections in a loop, for example `while :; do ssh 
-o BatchMode=yes root@<container> true; done`.
3. On the host, freeze and thaw the container: `lxc-freeze -n <vmid>; sleep 1; 
lxc-unfreeze -n <vmid>`, or run `pvesr run --id <vmid>-0` for a replication 
job, or `vzdump <vmid> --mode snapshot`.
4. The host's kernel log shows `comm="sshd-auth" sig=31 syscall=219`, the 
container's journal shows `preauth child terminated by signal 31`, and the 
client is refused for 90 s afterwards.

The same should happen with any SIGSTOP/SIGCONT of `sshd-auth` while it waits 
in poll or nanosleep, or with a CRIU checkpoint and restore.

Upstream fix: openssh-portable commit 26b1363c7c ("allow restart_syscall(2) in 
seccomp sandbox", bz4036, 2026-10-18), released in 10.6p2 and already in 
unstable as 1:10.6p2-1.
It is a three-line addition to the preauth filter in `sandbox-seccomp-filter.c`.
Upstream's hunk does not apply to the trixie source as it is (its context 
lines, `__NR_uname` and `__NR_setsockopt`, came later), so here it is rebased 
onto 1:10.0p1-7+deb13u4, with the same three lines in the list's alphabetical 
order:

    --- a/sandbox-seccomp-filter.c
    +++ b/sandbox-seccomp-filter.c
    @@ -377,6 +377,9 @@
     #ifdef __NR_read
        SC_ALLOW(__NR_read),
     #endif
    +#ifdef __NR_restart_syscall
    +   SC_ALLOW(__NR_restart_syscall),
    +#endif
     #ifdef __NR_rt_sigprocmask
        SC_ALLOW(__NR_rt_sigprocmask),
     #endif

Neither trixie nor trixie-backports (1:10.3p1-1~bpo13+1) has it, and the 
unstable package cannot be installed on trixie (it needs libc6 >= 2.42).
Please consider it for a trixie stable update.

This is a concrete case of #991936: the filter's default action is to kill the 
process on any syscall it does not list, so a normal kernel path such as a 
syscall restart after a freeze kills `sshd-auth`.

Workaround for affected users: exempt trusted client networks from the crash 
penalty with `PerSourcePenaltyExemptList <network>` in the global section of 
sshd_config.
That stops the lockout, but the connection caught by the freeze is still lost.

Greg Humphreys
--- a/sandbox-seccomp-filter.c
+++ b/sandbox-seccomp-filter.c
@@ -377,6 +377,9 @@
 #ifdef __NR_read
 	SC_ALLOW(__NR_read),
 #endif
+#ifdef __NR_restart_syscall
+	SC_ALLOW(__NR_restart_syscall),
+#endif
 #ifdef __NR_rt_sigprocmask
 	SC_ALLOW(__NR_rt_sigprocmask),
 #endif

Reply via email to