From 8829c028d357831238fac708204f868be97e526b Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Mon, 20 Jun 2022 14:58:06 -0600 Subject: [PATCH] Add debug printfs when send/recv return EAGAIN or EINTR. These are not actually errors but can help gain insight into what is going on and, in the case of EAGAIN, whether or not there may be a kernel resource starvation problem. --- src/exec_intercept.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/exec_intercept.c b/src/exec_intercept.c index 3f7064aea..659f457e0 100644 --- a/src/exec_intercept.c +++ b/src/exec_intercept.c @@ -560,8 +560,12 @@ intercept_read(int fd, struct intercept_closure *closure) case false: goto done; default: - if (errno == EINTR || errno == EAGAIN) + if (errno == EINTR || errno == EAGAIN) { debug_return_bool(true); + sudo_debug_printf( + SUDO_DEBUG_WARN|SUDO_DEBUG_ERRNO|SUDO_DEBUG_LINENO, + "reading intercept token"); + } sudo_warn("recv"); goto done; } @@ -574,8 +578,12 @@ intercept_read(int fd, struct intercept_closure *closure) nread = recv(fd, &req_len, sizeof(req_len), 0); if (nread != sizeof(req_len)) { if (nread == -1) { - if (errno == EINTR || errno == EAGAIN) + if (errno == EINTR || errno == EAGAIN) { + sudo_debug_printf( + SUDO_DEBUG_WARN|SUDO_DEBUG_ERRNO|SUDO_DEBUG_LINENO, + "reading intercept message size"); debug_return_bool(true); + } sudo_warn("recv"); } goto done; @@ -605,8 +613,12 @@ intercept_read(int fd, struct intercept_closure *closure) /* EOF, other side must have exited. */ goto done; case -1: - if (errno == EINTR || errno == EAGAIN) + if (errno == EINTR || errno == EAGAIN) { + sudo_debug_printf( + SUDO_DEBUG_WARN|SUDO_DEBUG_ERRNO|SUDO_DEBUG_LINENO, + "reading intercept message"); debug_return_bool(true); + } sudo_warn("recv"); goto done; default: @@ -835,8 +847,12 @@ intercept_write(int fd, struct intercept_closure *closure) nwritten = send(fd, closure->buf + closure->off, closure->len - closure->off, 0); if (nwritten == -1) { - if (errno == EINTR || errno == EAGAIN) + if (errno == EINTR || errno == EAGAIN) { + sudo_debug_printf( + SUDO_DEBUG_WARN|SUDO_DEBUG_ERRNO|SUDO_DEBUG_LINENO, + "writing intercept message"); debug_return_bool(true); + } sudo_warn("send"); goto done; }