Bug 63468 - ttylock / ttyunlock occassionally incorrectly return error
Summary: ttylock / ttyunlock occassionally incorrectly return error
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: lockdev   
(Show other bugs)
Version: 7.3
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Jeff Johnson
QA Contact: Brian Brock
: 62394 (view as bug list)
Depends On:
TreeView+ depends on / blocked
Reported: 2002-04-14 11:27 UTC by greg hosler
Modified: 2007-04-18 16:41 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2002-04-18 13:43:37 UTC
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 11:28 UTC, greg hosler
no flags Details
new SRPM with patch (41.85 KB, application/octet-stream)
2002-04-18 13:41 UTC, greg hosler
no flags Details

Description greg hosler 2002-04-14 11:27:35 UTC
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 11:28:25 UTC
Created attachment 53787 [details]
sample program which demonstrates failure

Comment 2 Trond Eivind Glomsrxd 2002-04-16 18:39:14 UTC
(assigned it to JBJ as he was the one adding baudboy)

Comment 3 greg hosler 2002-04-18 13:41:01 UTC
Created attachment 54324 [details]
new SRPM with patch

Comment 4 greg hosler 2002-04-18 13:41:35 UTC
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 13:43:32 UTC
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 19:44:25 UTC
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 15:16:12 UTC
*** 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.