]> git.99rst.org Git - openwrt-packages.git/blob
22274d36692e963f43aca735a6a471b0c10d4771
[openwrt-packages.git] /
1 From f7fa1d461aa71bbc8a6c23fdcfc305f2e52ce5dd Mon Sep 17 00:00:00 2001
2 From: Christopher Faulet <cfaulet@haproxy.com>
3 Date: Mon, 19 Feb 2018 14:25:15 +0100
4 Subject: [PATCH] BUG/MEDIUM: ssl: Shutdown the connection for reading on
5 SSL_ERROR_SYSCALL
6
7 When SSL_read returns SSL_ERROR_SYSCALL and errno is unset or set to EAGAIN, the
8 connection must be shut down for reading. Else, the connection loops infinitly,
9 consuming all the CPU.
10
11 The bug was introduced in the commit 7e2e50500 ("BUG/MEDIUM: ssl: Don't always
12 treat SSL_ERROR_SYSCALL as unrecovarable."). This patch must be backported in
13 1.8 too.
14
15 (cherry picked from commit 4ac77a98cda3d0f9b1d9de7bbbda2c91357f0767)
16 Signed-off-by: Willy Tarreau <w@1wt.eu>
17 ---
18 src/ssl_sock.c | 14 ++++++++------
19 1 file changed, 8 insertions(+), 6 deletions(-)
20
21 diff --git a/src/ssl_sock.c b/src/ssl_sock.c
22 index f118724..a065bbb 100644
23 --- a/src/ssl_sock.c
24 +++ b/src/ssl_sock.c
25 @@ -5437,10 +5437,9 @@ static int ssl_sock_to_buf(struct connection *conn, struct buffer *buf, int coun
26 break;
27 } else if (ret == SSL_ERROR_ZERO_RETURN)
28 goto read0;
29 - /* For SSL_ERROR_SYSCALL, make sure the error is
30 - * unrecoverable before flagging the connection as
31 - * in error.
32 - */
33 + /* For SSL_ERROR_SYSCALL, make sure to clear the error
34 + * stack before shutting down the connection for
35 + * reading. */
36 if (ret == SSL_ERROR_SYSCALL && (!errno || errno == EAGAIN))
37 goto clear_ssl_error;
38 /* otherwise it's a real error */
39 @@ -5453,16 +5452,19 @@ static int ssl_sock_to_buf(struct connection *conn, struct buffer *buf, int coun
40 conn_cond_update_sock_polling(conn);
41 return done;
42
43 + clear_ssl_error:
44 + /* Clear openssl global errors stack */
45 + ssl_sock_dump_errors(conn);
46 + ERR_clear_error();
47 read0:
48 conn_sock_read0(conn);
49 goto leave;
50 +
51 out_error:
52 conn->flags |= CO_FL_ERROR;
53 -clear_ssl_error:
54 /* Clear openssl global errors stack */
55 ssl_sock_dump_errors(conn);
56 ERR_clear_error();
57 -
58 goto leave;
59 }
60
61 --
62 1.7.10.4
63
git clone https://git.99rst.org/PROJECT