Skip to content

Harden ACE removal networking and OpenSSL 3 compatibility#455

Merged
MadMaxMangos merged 19 commits into
masterfrom
fix/ace-removal-hardening
Jul 22, 2026
Merged

Harden ACE removal networking and OpenSSL 3 compatibility#455
MadMaxMangos merged 19 commits into
masterfrom
fix/ace-removal-hardening

Conversation

@MadMaxMangos

@MadMaxMangos MadMaxMangos commented Jul 22, 2026

Copy link
Copy Markdown
Member

Summary

Follow-up hardening for the ACE removal in #448 and #452.

OpenSSL

  • Require OpenSSL >=3.0.0,<4.0.0.
  • Document that OpenSSL 4 support is deferred until the 4.2 LTS transition.
  • Verify the linked runtime and loaded legacy provider use the expected major version.
  • Probe RC4 availability during startup so missing legacy-provider support fails immediately.
  • Propagate provider initialization failures from both daemons.

Networking

  • Drain final IOCP responses before closing the connection.
  • Make the close transition atomic and reject sends submitted after it.
  • Track all outstanding IOCP operations and drain their cancellation completions before destroying connection state or the completion port.
  • Restore Reactor teardown behaviour when worker registration rejects an accepted connection.
  • Populate the peer address before onConnect() in the io_uring backend.

WorldSession lifetime

  • Replace unlocked raw WorldSession access from network callbacks with move-only session leases.
  • Prevent session deletion while a network callback is using it.
  • Keep socket close callbacks non-blocking, avoiding self-deadlocks from Eluna or other close-capable callbacks.
  • Wait for active leases at the start of WorldSession destruction.

Regression coverage

Adds focused tests for:

  • OpenSSL provider/runtime compatibility and legacy cryptographic operations.
  • IOCP final-response draining and post-close send rejection.
  • IOCP shutdown with pending operations.
  • Reactor rejected-registration teardown.
  • io_uring peer-address callback ordering.
  • Concurrent session lease, detach, move, and deletion behaviour.

Testing

Windows RelWithDebInfo:

  • Clean CMake configure against OpenSSL 3.6.2.
  • Full build and install completed.
  • 3/3 CTest targets passed.
  • IOCP regression suite passed 10 repeated runs, covering 500 shutdown cycles.
  • Session lease tests passed 20 repeated runs.
  • AH service self-test passed.
  • realmd and mangosd both reached their listening states and shut down cleanly.
  • dumpbin confirmed both daemons depend only on libcrypto-3-x64.dll.
  • mangosd completed world initialization without reproducing the earlier cold-start slow-loop warning.

The Reactor and io_uring runtime cases are platform-gated and will run through the Linux CI matrix.

Dependency

This updates the src/realmd submodule to the companion realmd fix:

  • mangos/realmd PR:

This change is Reviewable

@MadMaxMangos

Copy link
Copy Markdown
Member Author

@claude review

@codacy-production

codacy-production Bot commented Jul 22, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 242 complexity · 2 duplication

Metric Results
Complexity 242
Duplication 2

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 28e62f9ec1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

void stopSubmissions()
{
std::lock_guard<std::mutex> lock(m_mutex);
m_acceptingSubmissions = false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reset the IOCP operation gate before restart

On Windows, once stop() calls this, m_acceptingSubmissions stays false forever because IocpServer::start() never reinitializes m_operations. If WorldSocketMgr::StopNetwork()/StartNetwork() or RaServer::Stop()/Start() reuses the same server object, the listener and worker threads come back up but every postAccept() returns at tryBegin(), so the port accepts no clients. Please reset the gate/count when starting a fresh listener.

Useful? React with 👍 / 👎.

Comment on lines +465 to +466
shouldClose = ctx->channel->closeRequested && !ctx->channel->sendShutdown &&
ctx->channel->out.empty();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Honor ISession::closed() in IOCP drains

For IOCP sessions that mark themselves closed by closed() after onConnect()/onData() and rely on the transport contract to flush then close, this condition never becomes true unless they also called the closer callback. The previous IOCP checks used session->closed(), and Reactor/io_uring still do, so Windows can leave those sessions open with a recv reposted instead of delivering EOF after final bytes. Include ctx->session->closed() in the drain-to-close decision or translate it to closeRequested.

Useful? React with 👍 / 👎.

Comment thread src/shared/Auth/OpenSSLProvider.cpp Outdated
return;
}

std::string const providerVersion = m_legacyProvider.Version();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate the default provider major too

When OPENSSL_MODULES points at a directory where the default provider comes from a different OpenSSL major but the legacy provider still matches the runtime, this check accepts startup because it only parses m_legacyProvider.Version(). The daemon then runs with a mixed default provider even though normal EVP algorithms come from that provider; query m_defaultProvider.Version() as well and require both provider majors to match the runtime before setting m_initialized.

Useful? React with 👍 / 👎.

Comment thread src/shared/Auth/OpenSSLProvider.cpp Outdated
Comment on lines +198 to +200
unsigned long const runtimeVersionNumber = OpenSSL_version_num();
unsigned const runtimeMajor = static_cast<unsigned>((runtimeVersionNumber >> 28) & 0x0f);
if (!parsedProviderMajor || providerMajor != runtimeMajor)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject non-3.x OpenSSL runtimes at startup

If a deployment resolves both the runtime library and provider modules from OpenSSL 4.x, providerMajor == runtimeMajor and startup succeeds even though the build-time CMake check only covered the discovered package and this change intends to run only with OpenSSL 3.x. Add an explicit runtimeMajor == 3 check before accepting the provider/runtime pair so a swapped runtime cannot bypass the <4.0.0 policy.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c2841ed130

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread CMakeLists.txt
option(DEBUG "Enable debug build (only on non IDEs)" OFF)
option(WITHOUT_GIT "Disable Git revision detection" OFF)
option(BUILD_AH_SERVICE "Build the out-of-process auction-house service" ON)
option(BUILD_TESTING "Build focused regression tests" OFF)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Run the new regression tests in CI

Because this new option defaults to OFF and neither the Windows nor Linux workflow configure commands pass -DBUILD_TESTING=ON or run ctest, the regression targets added in this change are skipped by normal PR CI. That leaves the IOCP/provider/lease coverage described by the patch unused unless a developer opts in locally; enable the option in CI or default it on when the required dependencies are present.

Useful? React with 👍 / 👎.

{
if (std::shared_ptr<WorldSocket> socket = m_OwningSocket.lock())
{
socket->DetachSessionAndWait();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Close the socket before making the session unauthenticated

When a WorldSession is destroyed while its socket is still open (for example a duplicate/login-loading removal or shutdown cleanup), this detaches the session before CloseSocket() runs later in the destructor. During the intervening logout work, WorldSocket::ProcessIncoming() sees no session and accepts a new CMSG_AUTH_SESSION on the same connection instead of rejecting it as a repeated auth, after which the destructor closes/detaches that newly published session. Mark the socket closed or close it before unpublishing the session while still waiting for active leases before freeing the object.

Useful? React with 👍 / 👎.

@AppVeyorBot

Copy link
Copy Markdown

@MadMaxMangos
MadMaxMangos merged commit 91dd674 into master Jul 22, 2026
8 checks passed
@MadMaxMangos
MadMaxMangos deleted the fix/ace-removal-hardening branch July 22, 2026 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants