[git commit] telnetd: fix bad interaction with vhangup() from login

Denys Vlasenko vda.linux at googlemail.com
Sun Jan 6 18:06:01 UTC 2019


commit: https://git.busybox.net/busybox/commit/?id=39b18196f89a6f595d47c2a9c3a62c50d413c054
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 networking/telnetd.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/networking/telnetd.c b/networking/telnetd.c
index a6bafa21d..caef15181 100644
--- a/networking/telnetd.c
+++ b/networking/telnetd.c
@@ -865,11 +865,25 @@ int telnetd_main(int argc UNUSED_PARAM, char **argv)
  skip3:
 		if (/*ts->size2 < BUFSIZE &&*/ FD_ISSET(ts->ptyfd, &rdfdset)) {
 			/* Read from pty to buffer 2 */
+			int eio = 0;
+ read_pty:
 			count = MIN(BUFSIZE - ts->rdidx2, BUFSIZE - ts->size2);
 			count = safe_read(ts->ptyfd, TS_BUF2(ts) + ts->rdidx2, count);
 			if (count <= 0) {
-				if (count < 0 && errno == EAGAIN)
-					goto skip4;
+				if (count < 0) {
+					if (errno == EAGAIN)
+						goto skip4;
+					/* login process might call vhangup(),
+					 * which causes intermittent EIOs on read above
+					 * (observed on kernel 4.12.0). Try up to 10 ms.
+					 */
+					if (errno == EIO && eio < 10) {
+						eio++;
+						//bb_error_msg("EIO pty %u", eio);
+						usleep(1000);
+						goto read_pty;
+					}
+				}
 				goto kill_session;
 			}
 			ts->size2 += count;


More information about the busybox-cvs mailing list