Open stormshield-gt opened 4 weeks ago
https://github.com/quinn-rs/quinn/pull/2027 gets this test passing.
I've rebased and split into 2 tests, one for the substract with overflow
error and one for the debug_assert
The freebsd job seems to failed because cmake
is not installed on the runner
The freebsd job seems to failed because
cmake
is not installed on the runner
Why does this PR change the build requirements? Can you change the job to install cmake
?
That's because rustls-post-quantum
is not optional and unconditionally brings aws-lc-rs
. Sadly, it's not possible to have an optional dev dependency currently in cargo
.
I used a "private" feature hack to work around this, like they do, for instance, in the reqwest
crate. Please let me know if you have a better solution.
I've discovered a new corner case with min_mtu
of 1433,
with the current feature setup (that avoids compiling aws-lc-rs
on freebsd and android), the command to test locally is
RUST_LOG=trace cargo t --test post_quantum -F __rustls-post-quantum-test -- --show-output
Edit:
Note that the MTU of the loopback must me changed locally to make this work (that's explain why the test pass in the CI)
sudo ifconfig lo mtu 1460
Fixed the new case in #2046.
Thanks again for the fixes, I can confirm it works also on my computer
This PR adds a test for post-quantum key exchange. For now the test is failing to demonstrate the presence of a bug (https://github.com/quinn-rs/quinn/actions/runs/11549717021/job/32143264498?pr=2020). I will then propose a fix.
Note that I added a commit that exposed the key exchange group, like this was done for cipher in https://github.com/quinn-rs/quinn/pull/2001
With post-quantum, the
key_share
extension of the TLS client hello gets really big (1222 bytes) so the client hello gets fragmented into 2 separated CRYPTO frames, each one into its own QUIC packet. A padding frame is added to the second packet and all packets are inside the same UDP datagram thanks to GSO.When the QUIC server endpoint tries to respond, it panics, giving this backtrace:
Backtrace
```sh $ RUST_LOG=trace cargo t --test post_quantum -F rustls-aws-lc-rs 2024-10-28T16:13:03.084803Z TRACE quinn_proto::endpoint: initial_dcid=c128d5678dc1a983c71117a67cc3a83c9a8af3cc 2024-10-28T16:13:03.086083Z TRACE quinn_proto::connection: wrote 1459 Initial CRYPTO bytes 2024-10-28T16:13:03.086432Z TRACE drive{id=0}:send{space=Initial pn=0}: quinn_proto::connection: CRYPTO: off 0 len 1141 2024-10-28T16:13:03.086685Z TRACE drive{id=0}:send{space=Initial pn=1}: quinn_proto::connection: CRYPTO: off 1141 len 318 2024-10-28T16:13:03.086744Z TRACE drive{id=0}:send{space=Initial pn=1}: quinn_proto::connection::packet_builder: PADDING * 822 2024-10-28T16:13:03.086825Z TRACE drive{id=0}: quinn_proto::connection: sending 2400 bytes in 2 datagrams 2024-10-28T16:13:03.087735Z TRACE first recv:frame{ty=CRYPTO}: quinn_proto::connection: consumed 1141 CRYPTO bytes 2024-10-28T16:13:03.087831Z TRACE quinn_proto::endpoint: new connection id=0 icid=c128d5678dc1a983c71117a67cc3a83c9a8af3cc 2024-10-28T16:13:03.087866Z TRACE quinn_proto::connection: got Initial packet (1200 bytes) from 127.0.0.1:40544 using id c128d5678dc1a983c71117a67cc3a83c9a8af3cc 2024-10-28T16:13:03.087949Z TRACE recv{space=Initial pn=1}:frame{ty=CRYPTO}: quinn_proto::connection: consumed 318 CRYPTO bytes 2024-10-28T16:13:03.089617Z TRACE recv{space=Initial pn=1}: quinn_proto::connection: Handshake keys ready 2024-10-28T16:13:03.089653Z TRACE recv{space=Initial pn=1}: quinn_proto::connection: wrote 1178 Initial CRYPTO bytes 2024-10-28T16:13:03.089743Z TRACE recv{space=Initial pn=1}: quinn_proto::connection: Data keys ready 2024-10-28T16:13:03.089816Z TRACE recv{space=Initial pn=1}: quinn_proto::connection: wrote 629 Handshake CRYPTO bytes 2024-10-28T16:13:03.089891Z TRACE recv{space=Initial pn=1}: quinn_proto::connection: negotiated max idle timeout Some(30s) 2024-10-28T16:13:03.090142Z TRACE drive{id=0}:send{space=Initial pn=0}: quinn_proto::connection: ACK ArrayRangeSet([0..2]), Delay = 2994us 2024-10-28T16:13:03.090182Z TRACE drive{id=0}:send{space=Initial pn=0}: quinn_proto::connection: CRYPTO: off 0 len 1178 thread 'post_quantum_key_exchange' panicked at quinn-proto/src/connection/mod.rs:612:29: attempt to subtract with overflow note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace thread 'post_quantum_key_exchange' panicked at quinn/src/mutex.rs:140:42: called `Result::unwrap()` on an `Err` value: PoisonError { .. } stack backtrace: 0: 0x55964c496ed5 - std::backtrace_rs::backtrace::libunwind::trace::h649ab3318d3445c5 at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5 1: 0x55964c496ed5 - std::backtrace_rs::backtrace::trace_unsynchronized::hf4bb60c3387150c3 at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x55964c496ed5 - std::sys::backtrace::_print_fmt::hd9186c800e44bd00 at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/sys/backtrace.rs:65:5 3: 0x55964c496ed5 -::run::he81b8555de3848bf at /home/tudyg/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/mod.rs:436:9 42: 0x55964bb2f0ea - tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}::h67355865ac7ff044 at /home/tudyg/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/current_thread/mod.rs:737:25 43: 0x55964bb2d219 - tokio::runtime::coop::with_budget::hcfe509cd221e2d2e at /home/tudyg/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/coop.rs:107:5 44: 0x55964bb2d219 - tokio::runtime::coop::budget::h1157c24e8030ad37 at /home/tudyg/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/coop.rs:73:5 45: 0x55964bb2d219 - tokio::runtime::scheduler::current_thread::Context::run_task::{{closure}}::h8a187be17915fcab at /home/tudyg/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/current_thread/mod.rs:359:43 46: 0x55964bb2c386 - tokio::runtime::scheduler::current_thread::Context::enter::h1a750fd5f5f51da5 at /home/tudyg/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/current_thread/mod.rs:423:19 47: 0x55964bb2d0b1 - tokio::runtime::scheduler::current_thread::Context::run_task::hcc705cdeebe3df4a at /home/tudyg/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/current_thread/mod.rs:359:23 48: 0x55964bb2e6d9 - tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::h12c671faad368d04 at /home/tudyg/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/current_thread/mod.rs:736:35 49: 0x55964bb2dcfb - tokio::runtime::scheduler::current_thread::CoreGuard::enter::{{closure}}::h4d6182df91698347 at /home/tudyg/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/current_thread/mod.rs:774:68 50: 0x55964bb1cada - tokio::runtime::context::scoped::Scoped::set::h3224de03dd35862b
at /home/tudyg/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/context/scoped.rs:40:9
51: 0x55964bb34b0a - tokio::runtime::context::set_scheduler::{{closure}}::he4ecebc37a0c497b
at /home/tudyg/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/context.rs:180:26
52: 0x55964bb3369a - std::thread::local::LocalKey::try_with::h570bfd39fc9175f0
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/thread/local.rs:283:12
53: 0x55964bb32ecc - std::thread::local::LocalKey::with::h4ff1f162be03a846
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/thread/local.rs:260:9
54: 0x55964bb34a51 - tokio::runtime::context::set_scheduler::hddffee65f0bb575c
at /home/tudyg/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/context.rs:180:9
55: 0x55964bb2da5e - tokio::runtime::scheduler::current_thread::CoreGuard::enter::h8ab569a2580ddb4c
at /home/tudyg/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/current_thread/mod.rs:774:27
56: 0x55964bb2ddd1 - tokio::runtime::scheduler::current_thread::CoreGuard::block_on::hc619ccb065e7ac06
at /home/tudyg/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/current_thread/mod.rs:683:19
57: 0x55964bb2b71d - tokio::runtime::scheduler::current_thread::CurrentThread::block_on::{{closure}}::h37be45487e23ae9d
at /home/tudyg/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/current_thread/mod.rs:191:28
58: 0x55964bb225e2 - tokio::runtime::context::runtime::enter_runtime::h6b03172742bcb0e2
at /home/tudyg/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/context/runtime.rs:65:16
59: 0x55964bb2aef7 - tokio::runtime::scheduler::current_thread::CurrentThread::block_on::h145cdf67039d50cc
at /home/tudyg/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/current_thread/mod.rs:179:9
60: 0x55964bb247bf - tokio::runtime::runtime::Runtime::block_on_inner::h777ffa61536f6544
at /home/tudyg/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/runtime.rs:361:47
61: 0x55964bb24931 - tokio::runtime::runtime::Runtime::block_on::h3482e1be9fb14261
at /home/tudyg/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/runtime.rs:335:13
62: 0x55964bb242b3 - post_quantum::post_quantum_key_exchange::h29479e385094357a
at /home/tudyg/dev/forks/quinn/quinn/tests/post_quantum.rs:62:5
63: 0x55964bb16947 - post_quantum::post_quantum_key_exchange::{{closure}}::hf918d448d564f164
at /home/tudyg/dev/forks/quinn/quinn/tests/post_quantum.rs:18:41
64: 0x55964bb31296 - core::ops::function::FnOnce::call_once::h1f16e787afaf06a5
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/ops/function.rs:250:5
65: 0x55964be0c59b - core::ops::function::FnOnce::call_once::h81f56a195fe4862e
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/ops/function.rs:250:5
66: 0x55964be0c59b - test::__rust_begin_short_backtrace::h919c79c8b896f9e2
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/test/src/lib.rs:624:18
67: 0x55964be0be45 - test::run_test_in_process::{{closure}}::h7b3d5751c5b4dd75
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/test/src/lib.rs:647:60
68: 0x55964be0be45 - as core::ops::function::FnOnce<()>>::call_once::hdabd61465e4dbd80
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panic/unwind_safe.rs:272:9
69: 0x55964be0be45 - std::panicking::try::do_call::hc813c79fd64b0a90
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:557:40
70: 0x55964be0be45 - std::panicking::try::h055c5de7e7bfc209
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:521:19
71: 0x55964be0be45 - std::panic::catch_unwind::h4265d6525195c807
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panic.rs:350:14
72: 0x55964be0be45 - test::run_test_in_process::he72c277a35f96567
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/test/src/lib.rs:647:27
73: 0x55964be0be45 - test::run_test::{{closure}}::h974e632522c0fbcf
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/test/src/lib.rs:568:43
74: 0x55964bdd3e34 - test::run_test::{{closure}}::hdc2c89ce8b601dda
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/test/src/lib.rs:598:41
75: 0x55964bdd3e34 - std::sys::backtrace::__rust_begin_short_backtrace::h342cb8e53aeb2076
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/sys/backtrace.rs:152:18
76: 0x55964bdd7562 - std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}::h67b1b5c1709ad95b
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/thread/mod.rs:538:17
77: 0x55964bdd7562 - as core::ops::function::FnOnce<()>>::call_once::hd8c7a030ea8b7676
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panic/unwind_safe.rs:272:9
78: 0x55964bdd7562 - std::panicking::try::do_call::h512c2ab2c15b7d31
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:557:40
79: 0x55964bdd7562 - std::panicking::try::h5c2903f8937bc868
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:521:19
80: 0x55964bdd7562 - std::panic::catch_unwind::h242c80217c2dbece
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panic.rs:350:14
81: 0x55964bdd7562 - std::thread::Builder::spawn_unchecked_::{{closure}}::h6cb4494ebdd8caf7
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/thread/mod.rs:537:30
82: 0x55964bdd7562 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h42193b008049ba94
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/ops/function.rs:250:5
83: 0x55964c49d2db - as core::ops::function::FnOnce>::call_once::ha1963004222e7822
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/alloc/src/boxed.rs:2070:9
84: 0x55964c49d2db - as core::ops::function::FnOnce>::call_once::h1086ced1f7c494c2
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/alloc/src/boxed.rs:2070:9
85: 0x55964c49d2db - std::sys::pal::unix::thread::Thread::new::thread_start::ha8af9c992ef0b208
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/sys/pal/unix/thread.rs:108:17
86: 0x7f8734fad609 - start_thread
at /build/glibc-LcI20x/glibc-2.31/nptl/pthread_create.c:477:8
87: 0x7f8734d7d353 - clone
at /build/glibc-LcI20x/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95
88: 0x0 -
thread 'post_quantum_key_exchange' panicked at library/core/src/panicking.rs:229:5:
panic in a destructor during cleanup
thread caused non-unwinding panic. aborting.
error: test failed, to rerun pass `-p quinn --test post_quantum`
```