Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Description of problem:
The next version of POSIX will require that if close(fd) returns -1 with errno set to EINTR, because the close operation was interrupted by a signal and can be resumed, then fd must be kept open. For all other errno values (such as EIO), the current kernel behavior of closing fd in addition to reporting the error is appropriate. I have not audited the kernel to find out if any of the file system drivers can ever return EINTR back to the kernel, but if they can, then the kernel has a bug for blindly closing fd during close().
Version-Release number of selected component (if applicable):
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=fs/open.c;h=77becc04114908fae2a45f655ed22996264723ad;hb=HEAD#l1063
How reproducible:
Steps to Reproduce:
1. determine if any file system can fail with EINTR (perhaps a long-running NFS situation, where a signal can return control to the user prior to the close completing)
2.
3.
Actual results:
if the kernel blindly closes fd and then returns EINTR failure, the application will assume according to POSIX that it can re-attempt close(fd), but the kernel may have opened another unrelated file to fd in the meantime, and the second close will do the wrong thing
Expected results:
Either the kernel must never fail close() with EINTR, or on EINTR failure (and just EINTR), the kernel must guarantee that fd stays open to the same file.
Additional info:
http://austingroupbugs.net/view.php?id=529#c1107
Update - the POSIX folks are still debating things, but the discussion has now shifted over to the notion of requiring that close() _never_ fails with EINTR, and must always close the fd for all other errors, and with a suggestion of mapping EINTR -> EINPROGRESS in kernels that used to fail with EINTR but closed the fd. Furthermore, there is a suggestion to add posix_close(int fd, int flag), with a flag POSIX_CLOSE_RESTART, in order to obtain the restart semantics of keeping fd open if things fail with EINTR, but while still permitting an implementation that never fails with EINTR to effectively ignore the POSIX_CLOSE_RESTART flag. That is, it may be possible to completely comply with the POSIX proposal by patching just glibc, although adding a working posix_close(int fd, int flag) to the kernel as a new syscall might have other benefits.
This isn't a behavior that we can change without persuading upstream to take it.
If the POSIX people are looking at this still, I would suggest we close it until it gets resolved.