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

Fix race when handling delegating tasks in ReferenceCountedOpenSslEngine #12149

Merged
merged 1 commit into from Mar 8, 2022

Conversation

normanmaurer
Copy link
Member

Motivation:

Due incorrect handling of delegating tasks in ReferenceCountedOpenSslEngine it was possible to observe handshake timeouts / failures.

Modification:

  • Only reset needsTask variable after we actually ran the task.
  • Add missing synchronized as otherwise we might end up calling native code concurrently which is not safe.
  • Change how we excute delegating tasks in our SSLEngineTest. This change would result in timeouts / failures before the fix.

Result:

Fixes #12139

Motivation:

Due incorrect handling of delegating tasks in ReferenceCountedOpenSslEngine it was possible to observe handshake timeouts / failures.

Modification:

- Only reset needsTask variable after we actually ran the task.
- Add missing synchronized as otherwise we might end up calling native code concurrently which is not safe.
- Change how we excute delegating tasks in our SSLEngineTest. This change would result in timeouts / failures before the fix.

Result:

Fixes #12139
@normanmaurer
Copy link
Member Author

@chrisvest I opened a PR against 4.1 and main to proof that for both cases all works.

@normanmaurer normanmaurer added this to the 4.1.75.Final milestone Mar 8, 2022
@chrisvest chrisvest merged commit 1df38d2 into 4.1 Mar 8, 2022
@chrisvest chrisvest deleted the task_reset branch March 8, 2022 21:24
@@ -1475,19 +1469,22 @@ public void run() {
public void run(final Runnable runnable) {
if (isDestroyed()) {
// The engine was destroyed in the meantime, just return.
runnable.run();
Copy link
Contributor

@johnou johnou Mar 8, 2022

Choose a reason for hiding this comment

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

@normanmaurer intentionally not running the runnable in this refactor if the engine is destroyed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes as the SSL object is already destroyed

raidyue pushed a commit to raidyue/netty that referenced this pull request Jul 8, 2022
…ine (netty#12149)

Motivation:

Due incorrect handling of delegating tasks in ReferenceCountedOpenSslEngine it was possible to observe handshake timeouts / failures.

Modification:

- Only reset needsTask variable after we actually ran the task.
- Add missing synchronized as otherwise we might end up calling native code concurrently which is not safe.
- Change how we excute delegating tasks in our SSLEngineTest. This change would result in timeouts / failures before the fix.

Result:

Fixes netty#12139
franz1981 pushed a commit to franz1981/netty that referenced this pull request Aug 22, 2022
…ine (netty#12149)

Motivation:

Due incorrect handling of delegating tasks in ReferenceCountedOpenSslEngine it was possible to observe handshake timeouts / failures.

Modification:

- Only reset needsTask variable after we actually ran the task.
- Add missing synchronized as otherwise we might end up calling native code concurrently which is not safe.
- Change how we excute delegating tasks in our SSLEngineTest. This change would result in timeouts / failures before the fix.

Result:

Fixes netty#12139
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Delegated tasks issue in ReferenceCountedOpenSslEngine
3 participants