Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add allow-plain server ports attribute #9574

Merged
merged 5 commits into from
Sep 19, 2023
Merged

Add allow-plain server ports attribute #9574

merged 5 commits into from
Sep 19, 2023

Conversation

shinrich
Copy link
Member

@shinrich shinrich commented Mar 31, 2023

Description on matching issue.

Includes autest and document update.

This closes #9573

@shinrich shinrich self-assigned this Mar 31, 2023
@bneradt bneradt added this to the 10.0.0 milestone Apr 3, 2023
@bneradt bneradt added the TLS label Apr 3, 2023
@maskit
Copy link
Member

maskit commented Apr 4, 2023

Will all the data received be re-read by UnixNetVC? I'm wondering what happens if TLS handshake fails at the very late stage of it. Will SNI actions be triggered? If yes, will everything done on SNI actions be reset on the plain connection?

If all the data will be re-read by UnixNetVC, parsing the "HTTP request" probably fails because the fake TLS data is invalid as an HTTP request format.

@@ -783,6 +786,9 @@ mptcp

Requires custom Linux kernel available at https://multipath-tcp.org.

allow-plain
For TLS ports, will fall back to non-TLS processing if the TLS handshake fails.
Copy link
Member

Choose a reason for hiding this comment

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

We may want to mention that this is for TLS over TCP (or ports configured with ssl), although plain QUIC connection does not exist in the first place. We could also say this is incompatible with quic like some other descriptors say.

Copy link
Member

@SolidWallOfCode SolidWallOfCode Jun 5, 2023

Choose a reason for hiding this comment

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

Fails for any reason, including say an expired certificate? Or does this require a protocol failure? Looking at the code it seems only a protocol error on the first read / packet will failover to plain text.

Copy link
Member Author

Choose a reason for hiding this comment

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

Allow-plain only kicks in of the first packet fails to be recognized as a valid client-hello. Once packets are exchanged in the TLS path, it is no reasonable to try an reinterpret as HTTP.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will add comments to the effect that allow-plain does not make sense for quic. Could also implement an incompatible check.

@bneradt
Copy link
Contributor

bneradt commented Apr 8, 2023

[approve ci fedora]

@ezelkow1
Copy link
Member

[approve ci centos]

@@ -33,7 +33,7 @@
class SSLNextProtocolAccept : public SessionAccept
{
public:
SSLNextProtocolAccept(Continuation *, bool);
SSLNextProtocolAccept(Continuation *, bool, bool);
Copy link
Member

Choose a reason for hiding this comment

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

We might want to look at aliased boolean or enum values for clarity.

@SolidWallOfCode
Copy link
Member

I also want to riff of @maskit and say the consistency checking in processing the server ports should be extended to generate an error if both quic and allow-plain are enabled on the same server port.

@shinrich
Copy link
Member Author

Will all the data received be re-read by UnixNetVC? I'm wondering what happens if TLS handshake fails at the very late stage of it. Will SNI actions be triggered? If yes, will everything done on SNI actions be reset on the plain connection?

The allow-plain will only kick in if there is a TLS parse failure on the first packet. No TLS-oriented hooks should be triggered.

@shinrich
Copy link
Member Author

Added a warning if both allow-plain and quic are specified. Warnings seemed to be how the other checks went.

@@ -587,6 +587,10 @@ SSLNetVConnection::net_read_io(NetHandler *nh, EThread *lthread)
if (!getSSLHandShakeComplete()) {
int err = 0;

// May get into logic that will clean up the current VC
// Increment the recursion to delay do_io_close cleaup.
this->recursion++;
Copy link
Member Author

Choose a reason for hiding this comment

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

Adding this recursion bump, other use after free ASAN error would trigger on the later if (this->handshakeReader) check because with addition of the _migrateSsl, the SSLNetVC object (this) may have been deleted.
By incrementing recursion and adding test_inline_close() on return, we ensure that the deletion of this does not occur until the end of the function.

Copy link
Member

@maskit maskit left a comment

Choose a reason for hiding this comment

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

Bumping recursion counter inside of nests in the middle of a function seems to be error prone.

if (ret == EVENT_RESTART) {
// VC migrated into a new object
// Just give up and go home. Events should trigger on the new vc
return;
Copy link
Member

Choose a reason for hiding this comment

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

Don't we need to decrement the recursion counter here?

If no, it's difficult to understand. Want a comment why we don't need it.
If yes, it's fragile. I don't like to use goto but we may need it use it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried the recursion counts then changed the return value. I think that just sending back a different return value will suffice. I'll back out the recursion could and verify that everything still works. And update the PR

Copy link
Member Author

Choose a reason for hiding this comment

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

And you are exactly right. Should be dropping the recursion count here too. Should use the scoped pattern to deal with the decrement if we really need to manipulate the recursion counter.

netvc->do_io_close();
if (netvc != nullptr) {
netvc->do_io_close();
} else { // Try making a unix netvc
Copy link
Member

Choose a reason for hiding this comment

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

do_io_close() is a virtual function, so I think we can simply call vio->vc_server->do_io_close() without casting.

// This wasn't really a TLS connection
// Trying to process it as a TCP connection
if (netvc == nullptr) {
UnixNetVConnection *plain_netvc = dynamic_cast<UnixNetVConnection *>(vio->vc_server);
Copy link
Member

Choose a reason for hiding this comment

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

send_plugin_event receives void *. If we don't check nullptr, we can simply pass vio->vc_serve without casting.

@shinrich shinrich merged commit 17d918a into master Sep 19, 2023
@shinrich shinrich deleted the allow-plain branch November 29, 2023 17:49
cmcfarlen pushed a commit to cmcfarlen/trafficserver that referenced this pull request Jun 3, 2024
* asf/master: (30 commits)
  add conveinience function to lookup name->IntType* (apache#10474)
  cmake: bigobj subdir has executables, not plugins (apache#10481)
  cmake: compile jsonrpc_protocol with -fPIC (apache#10478)
  Make sure new metrics are always considered (apache#10445)
  Refactor and rename restart metrics (apache#10472)
  Fix the SNI and HOST parsing properly (apache#10480)
  slice/Data.h: CID 1508924: Uninitialized scalar field (apache#10470)
  CID 1508882: initialize pointer (apache#10469)
  CID-1512726: Mute coverity, use explicit check for iterator use past end (apache#10467)
  Fix Coverity issue in inliner plugin. (apache#10442)
  Set the proper variable when find_package fails to find the package (apache#10468)
  CID1508860: double lock confusion (apache#10443)
  Stop using functions that are unavailable on the latest quiche (apache#10447)
  Add allow-plain server ports attribute (apache#9574)
  [Fuzzing] move build.sh in trafficserver (apache#10466)
  Some sort of "fix" to mute coverity. (apache#10451)
  CID-1512733: Fix coverity issue (apache#10452)
  Fix cmake autooptions (apache#10456)
  Cmake presets (apache#10457)
  This fixes CID 1518257 (apache#10404)
  ...
@maskit maskit mentioned this pull request Aug 15, 2024
91 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add allow-plain server port attribute
6 participants