Commit Graph

36937 Commits

Author SHA1 Message Date
Neil Horman
ddfd561f3c Update man page to note limitations of callbacks for QUIC
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)
2025-02-17 11:27:33 -05:00
Neil Horman
6f38c59850 Fix memory leak in pre-allocated listeners
We have a chicken and egg problem.

Normally when we create a connection object in quic, we associate it
with a listener, and up the ref on the parent listener, which is fine.

However, now that we are pre-allocating user_ssl objects for incomming
connections we have a situation in which:
1) The pre-alocated connection object holds a ref on the listener
2) The application has no awareness of the quic connection object (and
   so can't free it)
3) The freeing of the listener object never calls into the quic stack,
   because its reference count may hold references from connections that
   haven't been accepted yet

We could require that applications register a function for the
new_pending_conn callback, and track/free these pending connections, but
that seems like alot of extra unneeded work to place on the application

Instead:
a) add a quic_conn_st flag named accepted
b) When pre-allocating connections, clear the flag in (a) and _dont_
   hold a reference to the parent listener
c) in SSL_accept_connection, set the accepted flag and reference the
listener
d) in ossl_quic_free drop the listener reference only if the accepted
flag is set
c) expressly free all user_ssl objects in ossl_quic_port_drop_incoming

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)
2025-02-17 11:27:33 -05:00
Neil Horman
55f3968a49 Add changes.md entry noting the limitations of recursive SSL calls
QUIC can't currently make recursive SSL calls, as it potentially results
in deadlock

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)
2025-02-17 11:27:33 -05:00
Neil Horman
7502df20bc rename new_pending_ssl to new_pending_conn
Make it clear its only announcing connections, not streams

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)
2025-02-17 11:27:33 -05:00
Neil Horman
1abc48fae8 Run Make update
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)
2025-02-17 11:27:33 -05:00
Neil Horman
016ddac4da Add docs for new callback registration
Add docs for SSL_CTX_set_new_pending_ssl_cb

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)
2025-02-17 11:27:33 -05:00
Neil Horman
a477b4ec16 Add a test to validate our new SSL_accept connection objects
Quick test to validate that:

a) our new pending SSL accept callback works
and
b) That our callback passed SSL objects match those that are returned
by SSL_accept_connection

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)
2025-02-17 11:27:33 -05:00
Neil Horman
a607146904 Add a callback to announce newly created ssl waiting acceptance
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)
2025-02-17 11:27:33 -05:00
Neil Horman
57f5af6f4c Return channel tls from ossl_quic_accept_connection
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)
2025-02-17 11:27:33 -05:00
Neil Horman
f193e0e9fb use internal callback to generate user ssl
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)
2025-02-17 11:27:33 -05:00
Neil Horman
dc04a11cca Add callback to get user ssl on channel creation
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)
2025-02-17 11:27:33 -05:00
Andrew Dinh
d79ef118db If server receives NEW_TOKEN frame, respond with PROTOCOL_VIOLATION
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26426)
2025-02-17 11:27:33 -05:00
Andrew Dinh
db1c857c07 Fix MARSHALLED_TOKEN_MAX_LEN
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26333)
2025-02-17 11:27:33 -05:00
Hugo Landau
3686d215fe QUIC FUTURE: Add concurrency architecture design document
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26025)
2025-02-17 11:27:33 -05:00
Neil Horman
15f859403e Fix sizing on variable in ossl-nghttp3-demo-server
On working on a rebase for the quic-server branch, I noted that the
rebase was failing on the http3 server.  It occurs because the new CI
ubuntu container appears to have FORTIFY_SOURCE enabled and trips over
the call to read here.  Specifically the compiler notes that in passing
an int into the read syscall (which accepts a size_t as the 3rd
argument), may interpret a negative value as a very large unsigned value
that exeeds the size allowed by a read call.

Fix it by converting the size variable to a size_t to ensure that the
signing is correct

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26368)
2025-02-17 11:27:33 -05:00
Alexandr Nedvedicky
0b15147a37 Implement SSL_new_from_listener()
SSL_new_from_listner() creates QUIC connection object (QCSO)
from listener. Caller can use the object retuned from
SSL_new_from_listener() to connect to remote QUIC server.
The QCSO created here shares engine/port with listener.

the change is covered by `test_ssl_new_from_listener()` in
test/quicapitest.c

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26138)
2025-02-17 11:27:33 -05:00
Jean-Frederic Clere
6bae611c99 Make quic interop tests pass with the demo server
Included are also multiple style fixes.

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26193)
2025-02-17 11:27:33 -05:00
Andrew Dinh
e9aa0b6c0e IPv6 support for quic interop
Modify the QUIC HQ interop server/client to support both IPv4 and IPv6.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26194)
2025-02-17 11:27:33 -05:00
Neil Horman
fcd8f8f7dd Disable address validation for throughput test
The multiplexing test using quiche as a client seems to get confused
when server address validation is enabled.  specifically it writes the
wrong keys into its keylog file, causing the test to fail when tshark
can't decode the tls connection that is established.  Fix it by
disabling address validation for the multiplexing/transfer test

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26198)
2025-02-17 11:27:33 -05:00
Neil Horman
a99c76d94c Do read retries in quic hq-interop server
Normally the throughput test in the interop harness requests several
hundred very small files, resulting in lots of small stream packets from
the client, which are nominally read in a single read operation (as they
typically fit into a single stream frame), and the server was written to
expect that.  However, its still possible, if a stream frame is packed
to the end of a datagram, that only part of its content is carried,
finished in a subsequent stream packet, which leads to a short read.

Augment the server to properly handle SSL_read transient failures so
that such an occurance is handled properly.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26198)
2025-02-17 11:27:33 -05:00
Neil Horman
eabdcadefa Fix SSL_read error handling in http3 demo server
The SSL_read error handling misses the ZERO_RETURN clause which is
non-fatal, correct that.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26180)
2025-02-17 11:27:33 -05:00
Neil Horman
861a322400 Correct copying of the url value
When setting up the url value we copy data from memory regions that
overlap, it leads to bogus output, correct that.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26180)
2025-02-17 11:27:33 -05:00
Neil Horman
66e1e60a61 Preserve fileprefix accross reuse in http3 demo server
The fileprefix that we serve content from needs to be preserved accross
h3ssl reuse.  Make sure we restore it after zeroing the struct.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26180)
2025-02-17 11:27:33 -05:00
Neil Horman
9570ecfc69 Add http3 test to the interop container
Set fileprefix for interop container on http3 server test

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26180)
2025-02-17 11:27:33 -05:00
Andrew Dinh
f851d8dfcc Encrypt the address validation token
Store an EVP_CIPHER_CTX context with an ephemeral key set in port
and use it to encrypt/decrypt the validation token.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26165)
2025-02-17 11:27:33 -05:00
Neil Horman
f42036822e removing debug code from quic_impl
I had experimented with starting the ssl handshake during accept, and
forgot to remove it

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26178)
2025-02-17 11:27:33 -05:00
Neil Horman
6d25809cd0 Fix typo
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26178)
2025-02-17 11:27:33 -05:00
Neil Horman
d11c5b78af augment CI to run ampilficationlimit tests
NOTE: Do this for the server test as well after rebase when http3
commits get merged

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26178)
2025-02-17 11:27:33 -05:00
Neil Horman
86c3c16c3b modify docker endpoint to not do address validation on transfer test
quic interop uses the transfer test as part of the amplificationlimit
test, and as such we can't do address validation with retry frames
there, as the test requires it

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26178)
2025-02-17 11:27:33 -05:00
Neil Horman
d1c3bb2f74 Add tracking of receive credit for unvalidated connections
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26178)
2025-02-17 11:27:33 -05:00
Neil Horman
eaa1a143ae Add unvalidated credit tracking to packetizer
Add data to track how much unvalidated credit we are sending and
receiving until such time as we are validated.  Validated conditions
are:

1) A retry token is sent, received, and validated
2) a handshake is completed on the connection

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26178)
2025-02-17 11:27:33 -05:00
Neil Horman
b441d20a2f Add a warning that disabling server validation is not recommended
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26114)
2025-02-17 11:27:33 -05:00
Neil Horman
f443b4048d Clarify that this validation only relates to retry packets
Disabling server address validation here only relates to new connections
that arrive without a token.  Future connections using tokens provided
by the server via NEW_TOKEN frames will still be validated

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26114)
2025-02-17 11:27:33 -05:00
Neil Horman
78f7141c12 Disable server address validation on interop handshake test
The handshake test in the interop suite requires that no server address
validation be preformed, so disable it for this test

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26114)
2025-02-17 11:27:33 -05:00
Neil Horman
60762be09b Add a public flag to disable address validation on listeners
Now that we have the infrastructure to skip address validation, add a
public flag to SSL_new_listener and SSL_new_listener_from to allow the
skipping of address validation on selected quic listener SSL objects

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26114)
2025-02-17 11:27:33 -05:00
Neil Horman
0746d4628e Add quic port flag to turn off address validation
Give us the infrastrucute to skip addr validation on the server

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26114)
2025-02-17 11:27:33 -05:00
Neil Horman
207892d022 Enhance port binding to allow connections without odcid
If we opt not to do server address validation, we have no odcid
and therefore never reserved a local cid

We need to follow the initial code path to generate one

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26114)
2025-02-17 11:27:33 -05:00
Jean-Frederic Clere
9fc0d25b09 SSL_free() does check for != NULL (thanks Sashan)
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)
2025-02-17 11:27:33 -05:00
Jean-Frederic Clere
b8e462c8e3 Fixes according Sashan review.
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)
2025-02-17 11:27:33 -05:00
Jean-Frederic Clere
887f6c06a1 port the 2 improvement suggested by @nhorman to help to run the
quic-interop-runner.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)
2025-02-17 11:27:33 -05:00
Jean-Frederic Clere
53ceb451b6 Arrange the code following the reviews.
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)
2025-02-17 11:27:33 -05:00
Jean-Frederic Clere
43ccd96da6 Fix small things from the review.
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)
2025-02-17 11:27:33 -05:00
Jean-Frederic Clere
ecf6701907 Add <sys/socket.h> for OpenBSD.
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)
2025-02-17 11:27:33 -05:00
Jean-Frederic Clere
fe2a51bfda typo in comment.
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)
2025-02-17 11:27:33 -05:00
Jean-Frederic Clere
1b11d7cf67 Arrange the remove_id() logic to be able to remove multiple stream.
create a new h3conn in read_from_ssl_ids() when we have a new
connection.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)
2025-02-17 11:27:33 -05:00
Jean-Frederic Clere
7492a44391 Arrange macox errors.
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)
2025-02-17 11:27:33 -05:00
Jean-Frederic Clere
a50a6efd07 make check style happy.
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)
2025-02-17 11:27:33 -05:00
Jean-Frederic Clere
511c37b88c Arrange the logic:
SSL_poll() without SSL_POLL_FLAG_NO_HANDLE_EVENT ticks for each stream
we have in SSL_poll() that prevents the server logic to get all events
Use SSL_poll() with SSL_POLL_FLAG_NO_HANDLE_EVENT and
SSL_handle_events() prevents the problem.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)
2025-02-17 11:27:33 -05:00
Jean-Frederic Clere
6ba49e30d8 read_from_ssl_ids() before wait_for_activity if something was received
before and the first time we are in the loop.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)
2025-02-17 11:27:33 -05:00
Jean-Frederic Clere
fe3e4bbb4f Arrange poll logic and get it working with chrome.
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)
2025-02-17 11:27:33 -05:00