Bug 168434 - RHEL4: login's timeout can fail - needs to call siginterrupt(SIGALRM,1)
Summary: RHEL4: login's timeout can fail - needs to call siginterrupt(SIGALRM,1)
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: util-linux
Version: 4.0
Hardware: All
OS: Linux
Target Milestone: ---
: ---
Assignee: Karel Zak
QA Contact: Ben Levenson
Depends On:
Blocks: 168429
TreeView+ depends on / blocked
Reported: 2005-09-15 21:59 UTC by Jason Vas Dias
Modified: 2007-11-30 22:07 UTC (History)
0 users

Clone Of:
Last Closed: 2006-03-07 18:04:32 UTC

Attachments (Terms of Use)

External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2006:0061 qe-ready SHIPPED_LIVE util-linux bug fix update 2006-03-06 05:00:00 UTC

Description Jason Vas Dias 2005-09-15 21:59:03 UTC
Description of problem:

Login tries to set a timeout in main(), login.c, @ line 334:

    signal(SIGALRM, timedout);
    alarm((unsigned int)timeout);
    signal(SIGQUIT, SIG_IGN);
    signal(SIGINT, SIG_IGN);

If any restartable system call is entered, such system calls can block 
indefinitely and will NOT be interrupted by the SIGALRM .

Login needs to call:

In order for restartable system calls to be interrupted.

This problem turned out to be one root cause of mgetty bug 167830, where 
the login program was run for a terminal for which it did not have read
or write permission (another problem).

In that case, login hung until manually killed by the administrator in its
tcsetattr(...) call at login.c, line 460:	
   /* Kill processes left on this tty */

This may possibly be a kernel bug - instead of returning EIO / EPERM, the
kernel continously sends an infinite number of SIGTTOU signals to the process .

An 80MB strace log file was generated, consisting of >1,000,000 repetitions
of :
4964  11:00:18 ioctl(0, SNDCTL_TMR_CONTINUE or TCSETSF, {c_iflags=0x106,
c_oflags=0x1805, c_cflags=0x800000be, c_lflags=0x3b, c_line=0,
= ? ERESTARTSYS (To be restarted)
4964  11:00:18 --- SIGTTOU (Stopped (tty output)) @ 0 (0) ---
4964  11:00:18 --- SIGTTOU (Stopped (tty output)) @ 0 (0) ---

Login's alarm signal handler DOES get the SIGALRM after the 60 second timeout,
and timedout() is called; but then timedout2 calls ioctl(0, TCSETA, &ti), which
also blocks, because the ioctl(0, TCSETSF...) of tcsetattr is in progress, and
the exit() call of timedout2 is never reached, and the tcsetattr call is

This whole situation could be avoided by calling :
immediately after the 
    signal(SIGALRM, timedout)

I can reproduce this problem at will on Rawhide and RHEL-4 .
Version-Release number of selected component (if applicable):
ALL - util-linux-2.13-0.3.pre2 (Rawhide)
      util-linux-2.12a (RHEL-4)

How reproducible:

Steps to Reproduce:
Cause login to be enter any restartable system call which then blocks.

For instance: if login is exec'd with its stdin/stdout directed to a 
terminal for which it does not have read/write access, the tcsetattr
call will be restarted indefinitely.

Actual results:
Login hangs indefinitely

Expected results:
Any blocking system call should be interrupted by the login timeout.
Login should exit with an error.

Additional info:

mgetty configuration to reproduce this problem available upon request.

Comment 1 Karel Zak 2005-10-03 14:31:28 UTC
Jason, thanks for perfect description of problem! (also bug #168436)

It will be fixed it in FC5, FC4 and added to RHEL proposed list.

Comment 7 Red Hat Bugzilla 2006-03-07 18:04:32 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.


Note You need to log in before you can comment on or make changes to this bug.