-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
High CPU usage when TLS client sends TLS Record data exceeding length 17408 #6072
Comments
…icate Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Branch jetty-9.4.x-6072-ssl-cpuspin created. |
Per TLS/1.1 spec ... https://tools.ietf.org/html/rfc4346#section-6.2.2
2^14 + 1024 = 17408 We are working out why we are not failing when encountering the example TLS Frame with spec invalid excessive length. |
…408. Avoid spinning if the input buffer is full. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
…408. Avoid spinning if the input buffer is full. Signed-off-by: Simone Bordet <simone.bordet@gmail.com> Co-authored-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
…408. Avoid spinning if the input buffer is full. Signed-off-by: Simone Bordet <simone.bordet@gmail.com> Co-authored-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
I think
|
@xiezhaokun we don't want to use larger buffers if it's not necessary. If the first buffer we read is legit and really the TLS data does not fit it, we will read the TLS data in 2 reads and then the TLS implementation should adjust to use larger buffers. We want to avoid spinning in case of invalid TLS data that fills the whole buffer. |
…408. Updates after review. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
…408. Updates after review. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
…408. Avoid spinning if the input buffer is full. Signed-off-by: Simone Bordet <simone.bordet@gmail.com> Co-authored-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
…408. Updates after review. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
…408. Avoid spinning if the input buffer is full. Signed-off-by: Simone Bordet <simone.bordet@gmail.com> Co-authored-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
…408. Updates after review. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
In openjdk8u272 , SSLEngineImpl#readRecord method, when packet length > Record.maxRecordSize && length <= Record.maxLargeRecordSize , it will expand buffer size. But In jetty, I did not find where to expand the _encryptedInput.
|
@xiezhaokun We currently do not expand the buffers beyond the sizes provided by SSLSession::getApplicationBufferSize and SSLSession::getPacketBufferSize So for now, we just want to fix the 100% CPU issue. Then in a later release we need to understand why a frame might be larger than the max buffer size suggested by the session, and if we wish to support that or not. Do you know why a frame larger than the max size in the session should be accepted? |
Here's some values from constants within the JVM itself. sun.security.ssl.SSLRecord
In order for |
The public int getPacketBufferSize() {
sessionLock.lock();
try {
// Use the bigger packet size calculated from maximumPacketSize
// and negotiatedMaxFragLen.
int packetSize = 0;
if (negotiatedMaxFragLen > 0) {
packetSize = cipherSuite.calculatePacketSize(
negotiatedMaxFragLen, protocolVersion,
protocolVersion.isDTLS);
}
if (maximumPacketSize > 0) {
return (maximumPacketSize > packetSize) ?
maximumPacketSize : packetSize;
}
if (packetSize != 0) {
return packetSize;
}
if (protocolVersion.isDTLS) {
return DTLSRecord.maxRecordSize;
} else {
return acceptLargeFragments ?
SSLRecord.maxLargeRecordSize : SSLRecord.maxRecordSize;
}
} finally {
sessionLock.unlock();
}
} SSLSessionImpl session =
new SSLSessionImpl(shc, CipherSuite.C_NULL);
session.setMaximumPacketSize(shc.sslConfig.maximumPacketSize); |
@xiezhaokun I'm not sure I understand your point? |
The "maximumPacketSize" was set to "shc.sslConfig.maximumPacketSize (16709) " when send ServerHello message. So the function "getPacketBufferSize" can not return "SSLRecord.maxLargeRecordSize" when the config item "-Djsse.SSLEngine.acceptLargeFragments=true". |
Need to backport to 9.3 |
Signed-off-by: Olivier Lamy <oliver.lamy@gmail.com>
Signed-off-by: Olivier Lamy <oliver.lamy@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Co-authored-by: Olivier Lamy <oliver.lamy@gmail.com> Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
…-tls-fix Issue #6072 - backport of minimum fix for jetty-9.3.x
@lachlan-roberts yes, this is complete in my mind. |
Jetty version
9.4.36.v20210114
Java version
openjdk 8u272
OS type/version
linux
Description
When using a socket to send data with a size greater than 17408, an endless loop will occur in the jetty server.
The following demo can reproduce this problem:
The text was updated successfully, but these errors were encountered: