]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
TLS: do not ignore readpaused flag in certain circumstances
authorArtem Boldariev <artem@boldariev.com>
Fri, 29 Jul 2022 16:33:25 +0000 (19:33 +0300)
committerArtem Boldariev <artem@boldariev.com>
Tue, 2 Aug 2022 14:31:15 +0000 (17:31 +0300)
In some circumstances generic TLS code could have resumed data reading
unexpectedly on the TCP layer code. Due to this, the behaviour of
isc_nm_pauseread() and isc_nm_resumeread() might have been
unexpected. This commit fixes that.

The bug does not seems to have real consequences in the existing code
due to the way the code is used. However, the bug could have lead to
unexpected behaviour and, at any rate, makes the TLS code behave
differently from the TCP code, with which it attempts to be as
compatible as possible.

(cherry picked from commit ec0647d546204a0e09aeaf0e2aabb37f1fb67dd0)

lib/isc/netmgr/tlsstream.c

index ef3f70fc420ef5bb06ecac47d2b50ffcfc05ca33..acfab53cbbf20bc2399b0019767e79a1d2e9e88d 100644 (file)
@@ -493,6 +493,13 @@ tls_do_bio(isc_nmsocket_t *sock, isc_region_t *received_data,
                                if (sock->statichandle == NULL) {
                                        finish = true;
                                        break;
+                               } else if (atomic_load(&sock->readpaused)) {
+                                       /*
+                                        * Reading has been paused from withing
+                                        * the context of read callback - stop
+                                        * processing incoming data.
+                                        */
+                                       break;
                                }
                        }
                }
@@ -543,11 +550,9 @@ tls_do_bio(isc_nmsocket_t *sock, isc_region_t *received_data,
                }
                return;
        case SSL_ERROR_WANT_READ:
-               if (tls_try_to_close_unused_socket(sock)) {
-                       return;
-               }
-
-               if (sock->outerhandle == NULL) {
+               if (tls_try_to_close_unused_socket(sock) ||
+                   sock->outerhandle == NULL || atomic_load(&sock->readpaused))
+               {
                        return;
                }