Status: Accepted
Owner: jean.deruelle
Labels: Type-Defect Priority-Medium

New issue 163 by jean.deruelle: Continues Overflow in SSLStateMachine when unwrapping
https://code.google.com/p/jain-sip/issues/detail?id=163

NOTE: we have not been able to reproduce and as such we do not know if our suggested fix actually would work. For now, we really just want your input and let you guys be aware that there is an issue with how the engine is handling buffer overflows. So far, it has taken out one node in production but since this is on TLS, we do not have any pcaps.

Symptom: 100% CPU and TLS Port unresponsive. Log flooded with "Buffer overflow , must prepare the buffer again. Check for continious overflow here?"

A note on the log. In the version of the jain sip library we were running, this was logged on INFO but now seems to have changed to DEBUG. We obviously do not run with DEBUG log on in production.

The line where this comes from is in SSLStateMachine.unwrap(ByteBuffer src, ByteBuffer dst) and it really seems that the log line is a TODO since it actually says "Check for continious overflow here?". We suspect that this is what actually hit us. I.e., there were continuous overflows and that took the SSLStateMachine out of play and the machine too since it ended up in an infinite loop (just a theory based on the log message flooding and 100% CPU). A suggestion is to e.g. do:

1. Add a max overflow limit:

private static final int OVERFLOW_LIMIT = 10;

2. Have a counter for each instance of the state machine:

private int overflowCount = 0;

3. And then simply count:

if(result.getStatus().equals(Status.BUFFER_OVERFLOW)) {
if(logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
logger.logDebug("Buffer overflow , must prepare the buffer again. Check for continious overflow here?");
}
if (++this.overflowCount > OVERFLOW_LIMIT) {
throw new SSLException("SSL unwrap: too much overflow");
}
dst = channel.prepareAppDataBuffer();
continue;
} else {
this.overflowCount = 0;
}

or something...

Btw, just a suggestion as well:

result.getStatus().equals(Status.BUFFER_OVERFLOW)

could lead to a NPE if result.getStatus() would return null (bug or whatever)

Status.BUFFER_OVERFLOW.equals(result.getStats()) would never blow up.

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--

--- You received this message because you are subscribed to the Google Groups "mobicents-all-issues-changes" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to