tlshd: Clean up logic in tlshd_start_tls_handshake()
Chuck Lever
maintainerPATCH 1/1 tlshd: Clean up logic in tlshd_start_tls_handshake()
From: Chuck Lever <[email protected]>
gnutls_handshake() is supposed to return only a GNUTLS_E value, and the session_status field is supposed to contain only a positive errno.
GNUTLS_E_PREMATURE_TERMINATION is -110. It turns out that on x86, -ETIMEDOUT is also -110. Make sure the correct symbolic constants and auditing functions are utilized.
--- src/tlshd/handshake.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
src/tlshd/handshake.c +5 -5
@@ -90,19 +90,19 @@ void tlshd_start_tls_handshake(gnutls_session_t session, }while (ret <0 && !gnutls_error_is_fatal (ret));tlshd_set_nagle (session, saved);if (ret <0 ) { -/* Any errors here should default to blocking access: */ +/* By default, a handshake error is permanent */ parms->session_status =EACCES ;switch (ret) {case GNUTLS_E_CERTIFICATE_ERROR :case GNUTLS_E_CERTIFICATE_VERIFICATION_ERROR :tlshd_log_cert_verification_error (session);break ; -case -ETIMEDOUT : -tlshd_log_gnutls_error (ret); - parms->session_status = -ret; +case GNUTLS_E_PREMATURE_TERMINATION : +tlshd_log_error ("Handshake timeout, retrying" ); + parms->session_status =ETIMEDOUT ;break ;default : -tlshd_log_notice ("tlshd_start_tls_handshake unhandled error %d, returning EACCES\n" , ret); +tlshd_log_gnutls_error (ret); }return ; }
Signature · 1 line
2.51.0
Quoted 6 lines · Chuck Lever
From: Chuck Lever <[email protected]>
gnutls_handshake()is supposed to return only aGNUTLS_Evalue, and thesession_statusfield is supposed to contain only a positive errno.
Quoted 6 lines
GNUTLS_E_PREMATURE_TERMINATIONis -110. It turns out that on x86,-ETIMEDOUTis also -110. Make sure the correct symbolic constants and auditing functions are utilized.Fixes b010190cfed2 ("tlshd: Pass ETIMEDOUT from gnutls to kernel")Signed-off-by Chuck Lever <[email protected]>
Its better!
Ben
Quoted 21 lines · Chuck Lever
From: Chuck Lever <[email protected]>
gnutls_handshake()is supposed to return only aGNUTLS_Evalue, and thesession_statusfield is supposed to contain only a positive errno.
GNUTLS_E_PREMATURE_TERMINATIONis -110. It turns out that on x86,-ETIMEDOUTis also -110. Make sure the correct symbolic constants and auditing functions are utilized.Fixes b010190cfed2 ("tlshd: Pass ETIMEDOUT from gnutls to kernel")Signed-off-by Chuck Lever <[email protected]>--- src/tlshd/handshake.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)src/tlshd/handshake.c +0
-0
src/tlshd/handshake.c void tlshd_start_tls_handshake(gnutls_session_t session, · line 93
Quoted 5 lines
src/tlshd/handshake.c +1
-1@@ -90,19 +90,19 @@ void tlshd_start_tls_handshake(gnutls_session_t session, }while (ret <0 && !gnutls_error_is_fatal (ret));tlshd_set_nagle (session, saved);if (ret <0 ) { -/* Any errors here should default to blocking access: */ +/* By default, a handshake error is permanent */
I had forgotten that session_status is initially EIO, so my new comment makes less sense than what is there now. Will drop the comment change.
Quoted 19 lines
src/tlshd/handshake.c +4
-4parms->session_status =EACCES ;switch (ret) {case GNUTLS_E_CERTIFICATE_ERROR :case GNUTLS_E_CERTIFICATE_VERIFICATION_ERROR :tlshd_log_cert_verification_error (session);break ; -case -ETIMEDOUT : -tlshd_log_gnutls_error (ret); - parms->session_status = -ret; +case GNUTLS_E_PREMATURE_TERMINATION : +tlshd_log_error ("Handshake timeout, retrying" ); + parms->session_status =ETIMEDOUT ;break ;default : -tlshd_log_notice ("tlshd_start_tls_handshake unhandled error %d, returning EACCES\n" , ret); +tlshd_log_gnutls_error (ret); }return ; }
Signature · 1 line
Chuck Lever