You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
2.0 KiB

  1. From 2fcd544272a5498ffa49544e9f06b51bc93e55d1 Mon Sep 17 00:00:00 2001
  2. From: Olivier Houchard <ohouchard@haproxy.com>
  3. Date: Tue, 13 Feb 2018 15:17:23 +0100
  4. Subject: [PATCH] BUG/MEDIUM: ssl: Don't always treat SSL_ERROR_SYSCALL as
  5. unrecovarable.
  6. Bart Geesink reported some random errors appearing under the form of
  7. termination flags SD in the logs for connections involving SSL traffic
  8. to reach the servers.
  9. Tomek Gacek and Mateusz Malek finally narrowed down the problem to commit
  10. c2aae74 ("MEDIUM: ssl: Handle early data with OpenSSL 1.1.1"). It happens
  11. that the special case of SSL_ERROR_SYSCALL isn't handled anymore since
  12. this commit.
  13. SSL_read() might return <= 0, and SSL_get_erro() return SSL_ERROR_SYSCALL,
  14. without meaning the connection is gone. Before flagging the connection
  15. as in error, check the errno value.
  16. This should be backported to 1.8.
  17. (cherry picked from commit 7e2e505006feb8f3b4a7f9e0ac5e89b5a8c4895e)
  18. Signed-off-by: Willy Tarreau <w@1wt.eu>
  19. ---
  20. src/ssl_sock.c | 9 ++++++++-
  21. 1 file changed, 8 insertions(+), 1 deletion(-)
  22. diff --git a/src/ssl_sock.c b/src/ssl_sock.c
  23. index aecf3dd..f118724 100644
  24. --- a/src/ssl_sock.c
  25. +++ b/src/ssl_sock.c
  26. @@ -5437,6 +5437,12 @@ static int ssl_sock_to_buf(struct connection *conn, struct buffer *buf, int coun
  27. break;
  28. } else if (ret == SSL_ERROR_ZERO_RETURN)
  29. goto read0;
  30. + /* For SSL_ERROR_SYSCALL, make sure the error is
  31. + * unrecoverable before flagging the connection as
  32. + * in error.
  33. + */
  34. + if (ret == SSL_ERROR_SYSCALL && (!errno || errno == EAGAIN))
  35. + goto clear_ssl_error;
  36. /* otherwise it's a real error */
  37. goto out_error;
  38. }
  39. @@ -5451,11 +5457,12 @@ static int ssl_sock_to_buf(struct connection *conn, struct buffer *buf, int coun
  40. conn_sock_read0(conn);
  41. goto leave;
  42. out_error:
  43. + conn->flags |= CO_FL_ERROR;
  44. +clear_ssl_error:
  45. /* Clear openssl global errors stack */
  46. ssl_sock_dump_errors(conn);
  47. ERR_clear_error();
  48. - conn->flags |= CO_FL_ERROR;
  49. goto leave;
  50. }
  51. --
  52. 1.7.10.4