Red Hat Bugzilla – Bug 253873
[RHEL5] SIGTTIN may terminate read() with -ERESTARTSYS
Last modified: 2008-05-21 10:53:32 EDT
Description of problem:
This is the same problem found as in BZ#245343 (RHEL4)
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.
Step to Reproduce:
1. Run attached program on background.
$ ./mt-wrong-errno &
2. Move that process to foreground
read() returns with setting errno ERESTARTSYS by accident.
In addition, such errno should not be appeared on user
Wait user input on foreground.
Summary of actions taken to resolve issue:
Location of diagnostic data:
Community kernel has already fixed this problem since 2.6.22-rc4.
Patch is at:
Original discussion is here:
We can't call read() from tty safety.
Created attachment 162068 [details]
Created attachment 162069 [details]
Patch tested using provided test case, patched kernel works as expected.
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
You can download this test kernel from http://people.redhat.com/dzickus/el5
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.