Bug 253873

Summary: [RHEL5] SIGTTIN may terminate read() with -ERESTARTSYS
Product: Red Hat Enterprise Linux 5 Reporter: Aristeu Rozanski <arozansk>
Component: kernelAssignee: Aristeu Rozanski <arozansk>
Status: CLOSED ERRATA QA Contact: Martin Jenner <mjenner>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.0CC: dzickus, roland
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: RHBA-2008-0314 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-05-21 14:53:32 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
test case
none
proposed patch none

Description Aristeu Rozanski 2007-08-22 15:06:05 UTC
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 15:06:06 UTC
Created attachment 162068 [details]
test case

Comment 2 Aristeu Rozanski 2007-08-22 15:16:37 UTC
Created attachment 162069 [details]
proposed patch

Comment 3 Aristeu Rozanski 2007-08-22 19:25:50 UTC
Patch tested using provided test case, patched kernel works as expected.


Comment 4 RHEL Program Management 2007-11-20 05:06:01 UTC
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 17:04:47 UTC
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 14:53: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.

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