Skip to content

TS-4309: Simplify read/write loops to address upload/download speed p… - #629

Closed
shinrich wants to merge 1 commit into
apache:masterfrom
shinrich:ts-4309-2
Closed

shinrich wants to merge 1 commit into
apache:masterfrom
shinrich:ts-4309-2

Conversation

@shinrich

Copy link
Copy Markdown
Member

…roblems.

May also help with ASAN crash reported in TS-4424.

Warning("Cannot add new block");
break;
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe these code will read SSL data until meet EAGAIN. How to handle a SSL flood attack ? a fast socket keeps sending and keeps call SSLReadBuffer and add_block() there no chance to return to NetHandler::manNetEvent() to processing next NetVC.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Looking at the non-ssl version, it is tracking a max to read. We should do something similar in the ssl-case.

oknet added a commit to oknet/trafficserver that referenced this pull request May 31, 2016
ogoodman pushed a commit to ogoodman/trafficserver that referenced this pull request Aug 20, 2016
shinrich added a commit to shinrich/trafficserver that referenced this pull request Jan 9, 2018
ywkaras pushed a commit to ywkaras/trafficserver that referenced this pull request Jul 7, 2022
In TsSharedMutex.h, make error reporting thread-safe. (apache#8636)
ezelkow1 pushed a commit to ezelkow1/trafficserver that referenced this pull request Oct 19, 2026
mTLS on resumed sessions tried to rebuild the client certificate's chain,
which cannot be done: a resumed handshake never asks for a certificate
again, and a serialized session carries the leaf but not the
intermediates that verified it. Every client certificate issued by an
intermediate CA therefore failed on resumption while its fresh
handshakes kept succeeding.

Stop re-deriving trust and instead make a session ineligible to return
under any policy other than the one that verified it, by hashing the
verification scope (server name, verify mode and depth, and the trust
anchors in force) into the session id context both TLS libraries compare
before admitting a resumption. An out-of-scope session is a cache miss
and completes a full handshake under the policy in force now.

Backport of apache#629. Differences from master, all forced by this branch:

* TLSBasicSupport.h includes P_SSLUtils.h here, where master includes
  SSLTypes.h, so the digest type is defined in P_SSLUtils.h instead.
  SSLConfigParams reaches it without including TLSBasicSupport.h, which
  would be a cycle.
* TLSSNISupport::get_sni_server_name() is added as a public accessor;
  only the protected _get_sni_server_name() existed.
* swoc::file::load() and ts::transform_lower() do not exist here, so
  ts::file::load() and ink_strlcpy() plus LowerCaseStr() are used.
* The OpenSSL ClientHello callback is gated on TS_USE_HELLO_CB and
  returns SSL_CLIENT_HELLO_*, and BoringSSL has its own callback rather
  than master's lambda.
* The tests use ssl_multicert.config, proxy.config.ssl.TLSv1_3 rather
  than its v10 .enabled spelling, and traffic_manager plus
  When.FileContains() for reloads, there being no Test.AddConfigReload().

tls_resume_cert_partition is deliberately not backported. It asserts
that a no-SNI session does not resume against a different
dest_ip-selected certificate, which does not hold on this branch: both
connections are served the first entry's certificate whatever the
destination address, so the test cannot distinguish the behavior it
targets. It tests an ambient property rather than this fix, which is why
its absence leaves the fix covered.

Two existing tests change with the behavior. Their cross-scope sessions
are now declined before the handshake completes, so the post-handshake
rejection they asserted is no longer reached and the client is refused
with a certificate_required alert instead of a reset. They now assert
that handshake evidence, and that the post-handshake guard is not
reached.

Co-Authored-By: Claude Opus 5 <[email protected]>
ezelkow1 pushed a commit to ezelkow1/trafficserver that referenced this pull request Oct 19, 2026
mTLS on resumed sessions tried to rebuild the client certificate's chain,
which cannot be done: a resumed handshake never asks for a certificate
again, and a serialized session carries the leaf but not the
intermediates that verified it. Every client certificate issued by an
intermediate CA therefore failed on resumption while its fresh
handshakes kept succeeding.

Stop re-deriving trust and instead make a session ineligible to return
under any policy other than the one that verified it, by hashing the
verification scope (server name, verify mode and depth, and the trust
anchors in force) into the session id context both TLS libraries compare
before admitting a resumption. An out-of-scope session is a cache miss
and completes a full handshake under the policy in force now.

Backport of apache#629. Differences from master, all forced by this branch:

* TLSBasicSupport.h includes P_SSLUtils.h here, where master includes
  SSLTypes.h, so the digest type is defined in P_SSLUtils.h instead.
  SSLConfigParams reaches it without including TLSBasicSupport.h, which
  would be a cycle.
* TLSSNISupport::get_sni_server_name() is added as a public accessor;
  only the protected _get_sni_server_name() existed.
* swoc::file::load() and ts::transform_lower() do not exist here, so
  ts::file::load() and ink_strlcpy() plus LowerCaseStr() are used.
* The OpenSSL ClientHello callback is gated on TS_USE_HELLO_CB and
  returns SSL_CLIENT_HELLO_*, and BoringSSL has its own callback rather
  than master's lambda.
* The tests use ssl_multicert.config, proxy.config.ssl.TLSv1_3 rather
  than its v10 .enabled spelling, and traffic_manager plus
  When.FileContains() for reloads, there being no Test.AddConfigReload().

tls_resume_cert_partition is deliberately not backported. It asserts
that a no-SNI session does not resume against a different
dest_ip-selected certificate, which does not hold on this branch: both
connections are served the first entry's certificate whatever the
destination address, so the test cannot distinguish the behavior it
targets. It tests an ambient property rather than this fix, which is why
its absence leaves the fix covered.

Two existing tests change with the behavior. Their cross-scope sessions
are now declined before the handshake completes, so the post-handshake
rejection they asserted is no longer reached and the client is refused
with a certificate_required alert instead of a reset. They now assert
that handshake evidence, and that the post-handshake guard is not
reached.

Co-Authored-By: Claude Opus 5 <[email protected]>
ezelkow1 pushed a commit that referenced this pull request Oct 19, 2026
mTLS on resumed sessions tried to rebuild the client certificate's chain,
which cannot be done: a resumed handshake never asks for a certificate
again, and a serialized session carries the leaf but not the
intermediates that verified it. Every client certificate issued by an
intermediate CA therefore failed on resumption while its fresh
handshakes kept succeeding.

Stop re-deriving trust and instead make a session ineligible to return
under any policy other than the one that verified it, by hashing the
verification scope (server name, verify mode and depth, and the trust
anchors in force) into the session id context both TLS libraries compare
before admitting a resumption. An out-of-scope session is a cache miss
and completes a full handshake under the policy in force now.

Backport of #629. Differences from master, all forced by this branch:

* TLSBasicSupport.h includes P_SSLUtils.h here, where master includes
  SSLTypes.h, so the digest type is defined in P_SSLUtils.h instead.
  SSLConfigParams reaches it without including TLSBasicSupport.h, which
  would be a cycle.
* TLSSNISupport::get_sni_server_name() is added as a public accessor;
  only the protected _get_sni_server_name() existed.
* swoc::file::load() and ts::transform_lower() do not exist here, so
  ts::file::load() and ink_strlcpy() plus LowerCaseStr() are used.
* The OpenSSL ClientHello callback is gated on TS_USE_HELLO_CB and
  returns SSL_CLIENT_HELLO_*, and BoringSSL has its own callback rather
  than master's lambda.
* The tests use ssl_multicert.config, proxy.config.ssl.TLSv1_3 rather
  than its v10 .enabled spelling, and traffic_manager plus
  When.FileContains() for reloads, there being no Test.AddConfigReload().

tls_resume_cert_partition is deliberately not backported. It asserts
that a no-SNI session does not resume against a different
dest_ip-selected certificate, which does not hold on this branch: both
connections are served the first entry's certificate whatever the
destination address, so the test cannot distinguish the behavior it
targets. It tests an ambient property rather than this fix, which is why
its absence leaves the fix covered.

Two existing tests change with the behavior. Their cross-scope sessions
are now declined before the handshake completes, so the post-handshake
rejection they asserted is no longer reached and the client is refused
with a certificate_required alert instead of a reset. They now assert
that handshake evidence, and that the post-handshake guard is not
reached.

Co-Authored-By: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants