Repository navigation
Fix rsapss.test port collisions with kernel-assigned ports - #12282
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
Port discovery relies on OpenSSL’s ACCEPT output, but address/port reporting and flushing remain unvalidated on accepted 1.1.1 and older 3.x releases, especially on macOS, since only current upstream source was inspected.
No open issues 🎉
What changed in this PR
This PR addresses port collisions in RSA-PSS interoperability tests by letting the kernel assign server ports, and enables single-threaded DTLS servers to report their assigned ports.
Changes:
- Replace random port selection and network polling with server-reported ports.
- Fail RSA-PSS cases without running the client if the server reports no port.
- Resolve ephemeral UDP ports in single-threaded builds and update DTLS test comments and skip messages.
| File | Description |
|---|---|
wolfssl/test.h |
Allow udp_accept to resolve assigned ports in single-threaded builds. |
scripts/rsapss.test |
Use kernel-assigned ports and wait for server port reports. |
scripts/dtlscid.test |
Remove thread requirements from comments and skip messages. |
scripts/dtls.test |
Remove thread requirements from comments and skip messages. |
Review effort: Balanced
|
|
@claude review |
There was a problem hiding this comment.
Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.
Additional findings (outside the current diff — GitHub can't attach inline comments there):
-
🟣
wolfssl/test.h— pre-existing: In single-threaded builds, a DTLS server started with-p 0 -Rthat loops (-rresume or-i) moves to a new port after the first connection. The client's next connect, sent to the reported port, then fails. udp_accept now resolves the port, butready->port = portstill sits inside#ifndef SINGLE_THREADED. So server.c:3477port = readySignal->portkeeps port at 0, and the next udp_accept binds a fresh ephemeral port. Fix: move theready->port = port(andready->ready = 1) stores outside theSINGLE_THREADEDguard in udp_accept and tcp_accept, and keep only the cond signalling guarded.Why this was flagged
Trigger: a SINGLE_THREADED build runs
examples/server/server -u -p 0 -R file -r(or with-i). The first udp_accept (test.h:1977-1987) resolves the ephemeral port and writes it to the ready file. But test.h:1993 skipsready->port = portin SINGLE_THREADED, and InitTcpReady left ready->port at 0. So server.c:3476-3477 leavesportat 0. For UDP, server.c:4060 closes the socket, and the next loop iteration calls udp_accept again with port 0 (server.c:3470). That binds a different ephemeral port and overwrites the ready file, while the client resumes against the first port and gets no answer. The base branch also rebinds here, but it never reported a real port in single-threaded builds, so this is a gap the partial fix leaves open (pre-existing). None of the scripts in this PR pass a looping server flag, so they do not hit it.Verification: pre-existing.
ready->port = port;(test.h:1999) still sits inside#ifndef SINGLE_THREADED(test.h:1994-2005). So in server.c:3476-3477 the port stays 0. On resume or the next loop, udp_accept runs again at server.c:3470 with port 0 and binds a different ephemeral port. On the base, SINGLE_THREADED never called getsockname, so even the first connection failed.
|
OpenSSL 1.1.1 ( |
udp_accept resolved a -p 0 bind with getsockname only without SINGLE_THREADED, so a single-threaded DTLS server wrote port 0 to its ready file. dtls.test and dtlscid.test skipped in those builds, and any script that starts every DTLS server with -p 0 -R fails there. The lookup does not depend on threads; keep only the TIRTOS exclusion, and drop the threading requirement from the comments and skip messages of dtls.test and dtlscid.test.
udp_accept and tcp_accept set ready->ready and ready->port only without SINGLE_THREADED, although the fields exist in every build and only the condition variable needs threads. The example server copies ready->port back when started with -p 0, so a single-threaded DTLS server looping with -r or -i kept port 0 and bound a new ephemeral port on every accept, and a client resuming to the reported port got no answer. WOLFSSL_COND is never defined with SINGLE_THREADED, so its guards alone keep the signalling out of those builds.
The script drew a random port from 49512-65535 for each of its cases and checked it with ss or netstat before starting the server. On macOS that range is the ephemeral port range, there is no bwrap to isolate the run, and the netstat check is a snapshot: an outbound connection from a test running in parallel can take the port before the server binds it. The Jenkins aarch64 macOS leg fails with "tcp bind failed: Address already in use" since the script landed. Start the wolfSSL server with -p 0 -R and read the bound port from the ready file, as resume.test and dtls.test do, and start s_server with -accept 0 and read the port from its ACCEPT line. Both also signal that the server is listening, so the netstat polling goes away. A case whose server never reports a port fails without running the client.
52e0624 to
452357c
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #12282
Scan targets checked: wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): scripts/dtls.test, scripts/dtlscid.test, scripts/rsapss.test
Coverage: 1 of 1 in-scope changed file(s) opened by the reviewer
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Max
The "PSS server, PSS client certificate" case fails on a Jenkins leg with OpenSSL 1.1.1: s_client signs its CertificateVerify with rsa_pss_pss_sha512, the first PSS scheme in the wolfSSL server's CertificateRequest, and its id-RSASSA-PSS key, which declares SHA-256, refuses with "digest not allowed". OpenSSL 1.1.1f picks rsa_pss_pss_sha256 for the same handshake, so the result depends on which 1.1.1 build the host has, and the version check lets every 1.1.1 through. Offer that client only rsa_pss_pss_sha256 for its own signature with -client_sigalgs, the one scheme the key allows.
Description
scripts/rsapss.testpicked random server ports from 49512-65535 and checked them with netstat. On macOS that is the ephemeral range and there is no bwrap, so parallel tests take the port first and the aarch64 macOS Jenkins leg fails withtcp bind failed: Address already in use. The servers now bind port 0 and report the port they got.Changes
-p 0 -R,s_serveruses-accept 0with the port read from itsACCEPTlinegenerate_portand the netstat readiness pollingrsa_pss_pss_sha256, the one scheme its key allows; some OpenSSL 1.1.1 builds otherwise sign with SHA-512udp_acceptresolves a-p 0port inSINGLE_THREADEDbuilds too, so single-threaded DTLS servers report their real portready->portin single-threaded builds so a looping-p 0server keeps its portTesting
scripts/rsapss.test, including the DTLS 1.2 cases in single-threaded buildsscripts/dtls.testandscripts/dtlscid.testnow run in single-threaded builds instead of skipping