Bug 1330661

Summary: Add some error codes to clone manpage
Product: Red Hat Enterprise Linux 7 Reporter: Ben Woodard <woodard>
Component: man-pages-overridesAssignee: Nikola Forró <nforro>
Status: CLOSED ERRATA QA Contact: Iveta Wiedermann <isenfeld>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.3CC: jkejda, ovasik, tgummels, woodard
Target Milestone: rcKeywords: ManPageChange, Patch
Target Release: 7.3   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: man-pages-overrides-7.3.1-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1330663 (view as bug list) Environment:
Last Closed: 2016-11-04 07:31:54 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1274917, 1330663, 1349850, 1364088    

Description Ben Woodard 2016-04-26 16:46:56 UTC
Description of problem:
the clone syscall can return with some error codes that are not documented in the man page. In particular:

  ERESTARTSYS = 512 (To be restarted if SA_RESTART is set)
    Most common type of signal-interrupted syscall exit code.  The
    system call will be restarted with the same arguments if
    SA_RESTART is set; otherwise, it will fail with EINTR.

  ERESTARTNOINTR = 513 (To be restarted)
    Rare. For example, fork() returns this if interrupted.
    SA_RESTART is ignored (assumed set): the restart is
    unconditional.

  ERESTARTNOHAND = 514  (To be restarted if no handler)
    pause(), rt_sigsuspend() etc use this code.  SA_RESTART is
    ignored (assumed not set): syscall won't restart (will return
    EINTR instead) even after signal with SA_RESTART set. However,
    after SIG_IGN or SIG_DFL signal it will restart (thus the name
    "restart only if has no handler").

  ERESTART_RESTARTBLOCK = 516 (Interrupted by signal)
    Syscalls like nanosleep(), poll() which can't be restarted with
    their original arguments use this code. Kernel will execute
    restart_syscall() instead, which changes arguments before
    restarting syscall.  SA_RESTART is ignored (assumed not set)
    similarly to ERESTARTNOHAND. (Kernel can't honor SA_RESTART
    since restart data is saved in "restart block" in task struct,
    and if signal handler uses a syscall which in turn saves
    another such restart block, old data is lost and restart
    becomes impossible)


Version-Release number of selected component (if applicable):
This is true for all man pages right up until the latest version in Fedora.

Comment 2 Nikola Forró 2016-04-27 09:59:48 UTC
Hello Ben,

are you sure that clone syscall can return these error codes?

Quoting include/linux/errno.h [1]:

These should never be seen by user programs.  To return one of ERESTART*
codes, signal_pending() MUST be set.  Note that ptrace can observe these
at syscall exit tracing, but they will never be left for the debugged user
process to see.

So if you are seeing these error codes in strace output, it doesn't mean that they can actually be seen from userspace application.

Regards,
Nikola

[1] https://github.com/torvalds/linux/blob/master/include/linux/errno.h

Comment 4 Nikola Forró 2016-05-03 11:59:21 UTC
OK, since from these ERESTART* error codes clone syscall can return only ERESTARTNOINTR, I think something like this could be added to the man page:

ERESTARTNOINTR (since Linux 2.6.17)
    System call was interrupted by a signal and will be restarted.
    (This can be seen only during a trace.)


The same should be probably added to the fork(2) man page.
What do you think, Ben?

Comment 5 Ben Woodard 2016-05-03 17:39:54 UTC
I just conferred with the customer and they have not seen any of the other error codes in practice and so we think that your suggested addition would be sufficient.

Comment 6 Nikola Forró 2016-05-10 09:10:01 UTC
Upstream patch:
http://www.spinics.net/lists/linux-man/msg10249.html

Comment 15 errata-xmlrpc 2016-11-04 07:31:54 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-2485.html