Bug 63468 - ttylock / ttyunlock occassionally incorrectly return error
ttylock / ttyunlock occassionally incorrectly return error
Product: Red Hat Linux
Classification: Retired
Component: lockdev (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jeff Johnson
Brian Brock
: 62394 (view as bug list)
Depends On:
  Show dependency treegraph
Reported: 2002-04-14 07:27 EDT by greg hosler
Modified: 2007-04-18 12:41 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2002-04-18 09:43:37 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
sample program which demonstrates failure (341 bytes, text/plain)
2002-04-14 07:28 EDT, greg hosler
no flags Details
new SRPM with patch (41.85 KB, application/octet-stream)
2002-04-18 09:41 EDT, greg hosler
no flags Details

  None (edit)
Description greg hosler 2002-04-14 07:27:35 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9) Gecko/20020401

Description of problem:
the ttylock/ttyunlock routines of baudboy.h will incorrectly
return an error occassionally. Specifically, if the fork/execv, and the
subsequent execution of lockdev happen, and lockdev exits _BEFORE_ the waitpid
call of baudboy's "doit()", then the waitpid() will see a -1 return, with an
error code of ECHILD.

The end result is that the caller (that called ttylock/ttyunlock) will see a
false error return when infact the ttylock/ttyunlock succeeded.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
attached is a simple c program which loops and does ttylock() / ttyunlock() will
occassionally fail.

to compile:    cc -o foo foo.c
then, as root: chown uucp.uucp foo; chmod 6555 foo
then as normal user: ./foo


Actual Results:  generally several times out of the 10,000 loop lockdev will
finish and exit BEFORE the waitpid is started, and then waitpid will see an
error of -1 (with errno of ECHILD).

Expected Results:  false errors should not occur

Additional info:
Comment 1 greg hosler 2002-04-14 07:28:25 EDT
Created attachment 53787 [details]
sample program which demonstrates failure
Comment 2 Trond Eivind Glomsrxd 2002-04-16 14:39:14 EDT
(assigned it to JBJ as he was the one adding baudboy)
Comment 3 greg hosler 2002-04-18 09:41:01 EDT
Created attachment 54324 [details]
new SRPM with patch
Comment 4 greg hosler 2002-04-18 09:41:35 EDT
The problem is that under some scheduling conditions, it is possible for
the fork/execv and exec'd process to run to completion before the fork()
returns. Whenever that happens, the return status is lost (because the
installed signal handler sets SIGCHLD to SIG_IGN).

The attached fix corrects ths problem by installing a signal handler with the
intent purpose of catching the return status BEFORE the fork(), and then waits
around for the return status (which might be ready when the fork completes).
Comment 5 greg hosler 2002-04-18 09:43:32 EDT
Note: this is the same problem as 62394, but I couldn't get anyone to
look at 62394 so I refiled it under lockdev (after tracking the bug to lockdev).
Comment 6 Jeff Johnson 2002-06-05 15:44:25 EDT
Your signal patch should be in lockdev-1.0.0-19.
Thanks again for doing the heavy lifting.
Comment 7 greg hosler 2002-08-05 11:16:12 EDT
*** Bug 62394 has been marked as a duplicate of this bug. ***

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