GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Support read-only input buffers in SslHandler by lhotari · Pull Request #14079 · netty/netty

Conversation

@lhotari

@lhotari lhotari commented May 24, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Motivation:

JDK SSLEngine unwrap (& wrap) fails on read-only input ByteBuffer.

  • https://mail.openjdk.org/pipermail/security-dev/2022-March/029478.html
  • related JDK bug reports
    • https://bugs.openjdk.org/browse/JDK-8283577
    • https://bugs.openjdk.org/browse/JDK-8285603.
  • It seems that this is fixed since Java jdk-19+23.

Modification:

  • add wantsMutableBuffer to SslEngineType and set this to true for the JDK SslEngineType
    • Although JDK >= 19 supports read-only buffers, always check for read-only buffers and make copies when the JDK SslEngineType is used.
  • make changes to SslHandlerCoalescingBufferQueue to always return a copy if the buffer to return is read-only
  • add changes to SslHandler.wrap to handle the case where a read-only nio buffer might have been included in a composite buffer. In that case copying is needed at that stage if wantsMutableBuffer is true.

Result:

Fixes #14069
other PRs relevant in fixing #14069 are #14072, #14071, #14076 and #14078

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@lhotari lhotari mentioned this pull request May 24, 2024
SslHandler doesn't support a use case where the input ByteBuf is shared across multiple threads #14069
Closed
@lhotari
lhotari force-pushed the lh-support-copying-readonly-input-buffer branch from 4495aaa to cd3f8a9 Compare May 25, 2024 08:47
@lhotari lhotari changed the title [WIP] Make a copy of a read-only buffer before passing to SSLEngine.wrap Support read-only input buffers in SslHandler May 25, 2024
@lhotari
lhotari marked this pull request as ready for review May 25, 2024 08:58
@lhotari
lhotari force-pushed the lh-support-copying-readonly-input-buffer branch from cd3f8a9 to 28e4a78 Compare May 25, 2024 08:58
lhotari
lhotari commented May 25, 2024
View reviewed changes
Comment thread handler/src/main/java/io/netty/handler/ssl/SslHandler.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@lhotari
lhotari force-pushed the lh-support-copying-readonly-input-buffer branch from 28e4a78 to fb5cb0d Compare May 25, 2024 09:01
normanmaurer
normanmaurer requested changes May 27, 2024
View reviewed changes
Comment thread handler/src/main/java/io/netty/handler/ssl/SslHandler.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread handler/src/main/java/io/netty/handler/ssl/SslHandlerCoalescingBufferQueue.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer normanmaurer added this to the 4.1.111.Final milestone May 27, 2024
lhotari added 2 commits May 27, 2024 10:31
@lhotari
Add support for read-only buffers in SslHandler
9955ed0
@lhotari
Add integration tests for read-only buffers
be948fa
@lhotari
lhotari force-pushed the lh-support-copying-readonly-input-buffer branch from f41248a to be948fa Compare May 27, 2024 07:59
@lhotari

lhotari commented May 27, 2024

Copy link
Copy Markdown
Contributor Author

I added an integration test in be948fa and couldn't reproduce any issues even when the changes weren't present.

The JDK issues are about unwrap. I was assuming that this would also apply to wrap. That doesn't seem to be the case.
It looks like the unwrap mutatation issue was handled by #12213.

For supporting the read-only input buffers use case, it looks like PRs #14072, #14071, #14076 and #14078 are sufficient.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lhotari lhotari closed this May 27, 2024
@normanmaurer

normanmaurer commented May 27, 2024

Copy link
Copy Markdown
Member

@lhotari cool... Thanks for the update.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@normanmaurer normanmaurer normanmaurer requested changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

4.1.111.Final

Development

Successfully merging this pull request may close these issues.

SslHandler doesn't support a use case where the input ByteBuf is shared across multiple threads

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@lhotari @normanmaurer
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.