Bug 253873 - [RHEL5] SIGTTIN may terminate read() with -ERESTARTSYS
[RHEL5] SIGTTIN may terminate read() with -ERESTARTSYS
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: kernel (Show other bugs)
5.0
All Linux
medium Severity medium
: ---
: ---
Assigned To: Aristeu Rozanski
Martin Jenner
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2007-08-22 11:06 EDT by Aristeu Rozanski
Modified: 2008-05-21 10:53 EDT (History)
2 users (show)

See Also:
Fixed In Version: RHBA-2008-0314
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-05-21 10:53:32 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
test case (790 bytes, text/x-csrc)
2007-08-22 11:06 EDT, Aristeu Rozanski
no flags Details
proposed patch (1.48 KB, patch)
2007-08-22 11:16 EDT, Aristeu Rozanski
no flags Details | Diff

  None (edit)
Description Aristeu Rozanski 2007-08-22 11:06:05 EDT
Description of problem:
This is the same problem found as in BZ#245343 (RHEL4)

quote:
Assuming the following case:

 - There is a multithread process.
 - One of non-main thread read() from tty.
 - That process belongs to background process group

Then read() returns by accident with invalid errno (ERESTARTSYS).

The cause of this problem is tty driver. On sending SIGTTIN,
tty driver tries to send the signal to main-thread's
task_struct and return -ERESTARTSYS for restarting read().
However, the driver doesn't set TIF_SIGPENDING of current.
Hence current doesn't handle signal and returns to
userspace with setting errno ERESTARTSYS.

Same problem might occur on "SIGTTOU and write()" case.

How reproducible:
Always

Step to Reproduce:

1. Run attached program on background.

$ ./mt-wrong-errno &

2. Move that process to foreground

$ fg

Actual Results:
read() returns with setting errno ERESTARTSYS by accident.
In addition, such errno should not be appeared on user
space.

Expected Result:
Wait user input on foreground.

Summary of actions taken to resolve issue:
None

Location of diagnostic data:
None

Hardware configuration:
None

Software:
None

Additional Info:
Community kernel has already fixed this problem since 2.6.22-rc4.
Patch is at:

http://lkml.org/lkml/2007/5/29/296

Original discussion is here:

http://www.mail-archive.com/linux-kernel@vger.kernel.org/msg162569.html

Business Impact:
We can't call read() from tty safety.

Other:
None
Comment 1 Aristeu Rozanski 2007-08-22 11:06:06 EDT
Created attachment 162068 [details]
test case
Comment 2 Aristeu Rozanski 2007-08-22 11:16:37 EDT
Created attachment 162069 [details]
proposed patch
Comment 3 Aristeu Rozanski 2007-08-22 15:25:50 EDT
Patch tested using provided test case, patched kernel works as expected.
Comment 4 RHEL Product and Program Management 2007-11-20 00:06:01 EST
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
release.
Comment 6 Don Zickus 2007-11-29 12:04:47 EST
in 2.6.18-58.el5
You can download this test kernel from http://people.redhat.com/dzickus/el5
Comment 9 errata-xmlrpc 2008-05-21 10:53:32 EDT
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.

http://rhn.redhat.com/errata/RHBA-2008-0314.html

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