[sudo-workers] sudo waits on poll forever after SIGCHILD

Radovan Sroka rsroka at redhat.com
Thu Jun 28 02:48:53 MDT 2018


Hi Todd,

When using sudo-io with sudo to log the input ("Defaults log_input" in
/etc/sudoers),
"sudo" may hang from time to time.
In such case, the admin needs to "kill -9" the sudo command.

while true; do date; sudo -n -- systemctl --no-pager list-unit-files; done

# pstree -a -p 2884
bash,2884
  └─sudo,17948 -n -- systemctl --no-pager list-unit-files
      └─(sudo,17949)

# ps -eaf | grep sudo
root     17948  2884  0 17:34 pts/0    00:00:00 sudo -n -- systemctl
--no-pager list-unit-files
root     17949 17948  0 17:34 ?        00:00:00 [sudo] <defunct>
root     17963  2503  0 17:34 pts/2    00:00:00 grep --color=auto sudo

Strace log was generated from sudo-1.8.19p2(centos) but it is
reproducible on the newest
fedora as well.


Strace of bad run:
...
rt_sigprocmask(SIG_BLOCK, [INT QUIT TSTP TTIN TTOU], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
poll([{fd=3, events=POLLIN}, {fd=12, events=POLLIN}, {fd=9,
events=POLLOUT}, {fd=10, events=POLLIN}, {fd=9, events=POLLIN}], 5,
-1) = 1 ([{fd=12, revents=POLLIN}])
recvfrom(12, "\2\0\0\0\0\0\0\0", 8, MSG_WAITALL, NULL, NULL) = 8
fcntl(9, F_GETFL)                       = 0x8802 (flags
O_RDWR|O_NONBLOCK|O_LARGEFILE)
fcntl(9, F_SETFL, O_RDWR|O_LARGEFILE)   = 0
poll([{fd=10, events=POLLIN}, {fd=9, events=POLLOUT}], 2, 0) = 0 (Timeout)
poll([{fd=9, events=POLLOUT}], 1, -1)   = ? ERESTART_RESTARTBLOCK
(Interrupted by signal)
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=16586,
si_uid=0, si_status=1, si_utime=0, si_stime=0} ---
write(4, "\21", 1)                      = 1
rt_sigreturn({mask=[]})                 = -1 EINTR (Interrupted system call)
poll([{fd=9, events=POLLOUT}], 1, -1)   = 1 ([{fd=9, revents=POLLOUT}])
write(9, "ss-lookup.target                "..., 2251) = 2251
poll([{fd=10, events=POLLIN}], 1, -1

<--------------- End

Strace of ok run:
....
rt_sigprocmask(SIG_BLOCK, [INT QUIT TSTP TTIN TTOU], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
poll([{fd=3, events=POLLIN}, {fd=12, events=POLLIN}, {fd=14,
events=POLLIN}, {fd=9, events=POLLOUT}, {fd=9, events=POLLIN}, {fd=10,
events=POLLIN}], 6, -1) = 1 ([{fd=9, revents=POLLOUT}])
write(9, "                static  \r\ngetty."..., 3134) = 3134
poll([{fd=3, events=POLLIN}, {fd=12, events=POLLIN}, {fd=14,
events=POLLIN}, {fd=-1}, {fd=9, events=POLLIN}, {fd=10,
events=POLLIN}], 6, -1) = 3 ([{fd=12, revents=POLLIN|POLLHUP}, {fd=14,
revents=POLLHUP}, {fd=10, revents=POLLIN}])
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=17223,
si_uid=0, si_status=1, si_utime=0, si_stime=0} ---
write(4, "\21", 1)                      = 1
rt_sigreturn({mask=[]})                 = 3
recvfrom(12, "\2\0\0\0\0\0\0\0", 8, MSG_WAITALL, NULL, NULL) = 8
read(14, "", 65536)                     = 0
close(14)                               = 0
read(10, "\r\nsystemd-readahead-done.timer  "..., 65536) = 207
....


It looks like it happens when SIGCHILD arrives during poll.

-- 
--
---------------------------------------------------------

Radovan Sroka
Associate Software Engineer | Security Technologies | Red hat, Inc.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: log-ko
Type: application/octet-stream
Size: 71233 bytes
Desc: not available
URL: <http://www.sudo.ws/pipermail/sudo-workers/attachments/20180628/fd5f8302/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: log-ok
Type: application/octet-stream
Size: 81196 bytes
Desc: not available
URL: <http://www.sudo.ws/pipermail/sudo-workers/attachments/20180628/fd5f8302/attachment-0003.obj>


More information about the sudo-workers mailing list