Discussion:
[1003.1(2013)/Issue7+TC1 0000835]: file descriptor allocation by pipe() unclear
Austin Group Bug Tracker
2014-04-24 11:50:40 UTC
Permalink
The following issue has been SUBMITTED.
======================================================================
http://austingroupbugs.net/view.php?id=835
======================================================================
Reported By: geoffclare
Assigned To:
======================================================================
Project: 1003.1(2013)/Issue7+TC1
Issue ID: 835
Category: System Interfaces
Type: Clarification Requested
Severity: Objection
Priority: normal
Status: New
Name: Geoff Clare
Organization: The Open Group
User Reference:
Section: pipe
Page Number: 1413
Line Number: 46643
Interp Status: ---
Final Accepted Text:
======================================================================
Date Submitted: 2014-04-24 11:50 UTC
Last Modified: 2014-04-24 11:50 UTC
======================================================================
Summary: file descriptor allocation by pipe() unclear
Description:
As discussed in the teleconference of 10th April 2014, it is unclear
whether the statement, "Their integer values shall be the two lowest
available at the time of the pipe() call" in the description of pipe()
implies that both file descriptors must be allocated in a single
atomic operation. The consensus was that this is not intended; each fd
allocation is atomic, but the two allocations performed by pipe()
could be performed before and after another allocation (or closure) in
a different thread or a signal handler.

A more general problem is that the usual "lowest available" text
used in the descriptions of several functions could be interpreted as
meaning that two calls made at precisely the same time from different
threads both allocate the same file descriptor, since it was the lowest
available at the time when the two calls were made.

Desired Action:
Add a new section 2.13 on page 546:<blockquote><b>2.13 File Descriptor
Allocation</b>

All functions that open one or more file descriptors shall, unless
specified otherwise, atomically allocate the lowest numbered available
(that is, not already open in the calling process) file descriptor at the
time of each allocation. Where a single function allocates two file
descriptors (for example <i>pipe</i>() or <i>socketpair</i>()), the
allocations may be independent and therefore applications should not expect
them to have adjacent values or depend on which has the higher
value.</blockquote>
At page 563 line 19500 section accept after:<blockquote>... and allocate a
new file descriptor for that socket.</blockquote>
add:<blockquote>The file descriptor shall be allocated as described in
[xref to new section 2.13].</blockquote>
At page 813 line 27229 section fcntl change:<blockquote>Return a new file
descriptor which shall be the lowest numbered available (that is, not
already open) file descriptor greater than or equal to the third argument,
<i>arg</i>, taken as an integer of type <b>int</b>.</blockquote>
to:<blockquote>Return a new file descriptor which shall be allocated as
described in [xref to new section 2.13] except that it shall be the lowest
numbered available file descriptor greater than or equal to the third
argument, <i>arg</i>, taken as an integer of type <b>int</b>.</blockquote>
At page 1391 line 45951 section open change:<blockquote>... return a file
descriptor for the named file that is the lowest file descriptor not
currently open for that process.</blockquote>
to:<blockquote>... return a file descriptor for the named file, allocated
as described in [xref to new section 2.13].</blockquote>
At page 1394 line 46084 section open change:<blockquote>representing the
lowest numbered unused file descriptor</blockquote>
to:<blockquote>representing the file descriptor</blockquote>
At page 1413 line 46643 section pipe change:<blockquote>Their integer
values shall be the two lowest available at the time of the <i>pipe</i>()
call.</blockquote>
to:<blockquote>The file descriptors shall be allocated as described in
[xref to new section 2.13].</blockquote>
At page 1413 line 46657 section pipe change:<blockquote>... otherwise, -1
shall be returned and <i>errno</i> set to indicate the error.</blockquote>
to:<blockquote>... otherwise, -1 shall be returned and <i>errno</i> set to
indicate the error, and no file descriptors shall be
allocated.</blockquote>
At page 1433 line 47270 section posix_openpt change:<blockquote>The file
descriptor is used by other I/O functions that refer to that
pseudo-terminal.</blockquote>
to:<blockquote>The file descriptor shall be allocated as described in [xref
to new section 2.13] and can be used by other I/O functions that refer to
that pseudo-terminal.</blockquote>
At page 1433 line 47281 section posix_openpt change:<blockquote>... shall
open a master pseudo-terminal device and return a non-negative integer
representing the lowest numbered unused file descriptor.</blockquote>
to:<blockquote>... shall open a file descriptor for a master
pseudo-terminal device and return a non-negative integer representing the
file descriptor.</blockquote>
At page 1528 line 49729 section posix_typed_mem_open change:<blockquote>The
file descriptor is used by other functions to refer to that typed memory
object.</blockquote>
to:<blockquote>The file descriptor shall be allocated as described in [xref
to new section 2.13] and can be used by other functions to refer to that
typed memory object.</blockquote>
At page 1529 line 49773 section posix_typed_mem_open change:<blockquote>...
return a file descriptor for the typed memory object that is the lowest
numbered file descriptor not currently open for that process.</blockquote>
to:<blockquote>... return a file descriptor for the typed memory
object.</blockquote>
At page 1529 line 49788 section posix_typed_mem_open change:<blockquote>...
return a non-negative integer representing the lowest numbered unused file
descriptor.</blockquote>
to:<blockquote>... return a non-negative integer representing the file
descriptor.</blockquote>
At page 1913 line 61308 section shm_open change:<blockquote>The file
descriptor is used by other functions to refer to that shared memory
object.</blockquote>
to:<blockquote>The file descriptor shall be allocated as described in [xref
to new section 2.13] and can be used by other functions to refer to that
shared memory object.</blockquote>
At page 1913 line 61319 section shm_open change:<blockquote>... return a
file descriptor for the shared memory object that is the lowest numbered
file descriptor not currently open for that process.</blockquote>
to:<blockquote>... return a file descriptor for the shared memory
object.</blockquote>
At page 1914 line 61358 section shm_open change:<blockquote>... return a
non-negative integer representing the lowest numbered unused file
descriptor.</blockquote>
to:<blockquote>... return a non-negative integer representing the file
descriptor.</blockquote>
At page 1983 line 63518 section socket after:<blockquote>... return a file
descriptor that can be used in later function calls that operate on
sockets.</blockquote>
add:<blockquote>The file descriptor shall be allocated as described in
[xref to new section 2.13].</blockquote>
At page 1985 line 63592 section socketpair after:<blockquote>The file
descriptors used in referencing the created sockets shall be returned in
<i>socket_vector</i>[0] and <i>socket_vector</i>[1].</blockquote>
add:<blockquote>The file descriptors shall be allocated as described in
[xref to new section 2.13].</blockquote>
At page 1985 line 63619 section socketpair change:<blockquote>...
otherwise, -1 shall be returned and <i>errno</i> set to indicate the
error.</blockquote>
to:<blockquote>... otherwise, -1 shall be returned and <i>errno</i> set to
indicate the error, and no file descriptors shall be
allocated.</blockquote>
Cross-volume change to XRAT...
Add a new section B.2.13 on page 3649:<blockquote>Functions such as
<i>pipe</i>() and <i>socketpair</i>() which allocate two file descriptors
are permitted to perform the two allocations independently. This means
that other threads or signal handlers may perform operations on file
descriptors in between the two allocations and this can result in the two
file descriptors not having adjacent values or in the second allocation
producing a lower value than the first.</blockquote>
======================================================================

Issue History
Date Modified Username Field Change
======================================================================
2014-04-24 11:50 geoffclare New Issue
2014-04-24 11:50 geoffclare Name => Geoff Clare
2014-04-24 11:50 geoffclare Organization => The Open Group
2014-04-24 11:50 geoffclare Section => pipe
2014-04-24 11:50 geoffclare Page Number => 1413
2014-04-24 11:50 geoffclare Line Number => 46643
2014-04-24 11:50 geoffclare Interp Status => ---
======================================================================
Austin Group Bug Tracker
2014-04-24 15:13:02 UTC
Permalink
A NOTE has been added to this issue.
======================================================================
http://austingroupbugs.net/view.php?id=835
======================================================================
Reported By: geoffclare
Assigned To:
======================================================================
Project: 1003.1(2013)/Issue7+TC1
Issue ID: 835
Category: System Interfaces
Type: Clarification Requested
Severity: Objection
Priority: normal
Status: New
Name: Geoff Clare
Organization: The Open Group
User Reference:
Section: pipe
Page Number: 1413
Line Number: 46643
Interp Status: ---
Final Accepted Text:
======================================================================
Date Submitted: 2014-04-24 11:50 UTC
Last Modified: 2014-04-24 15:13 UTC
======================================================================
Summary: file descriptor allocation by pipe() unclear
======================================================================

----------------------------------------------------------------------
(0002232) eblake (manager) - 2014-04-24 15:13
http://austingroupbugs.net/view.php?id=835#c2232
----------------------------------------------------------------------
Use of SCM_RIGHTS with recvmsg() is another instance of allocating file
descriptors; but the standard is currently woefully silent on proper use of
SCM_RIGHTS, so it's probably worth a separate bug for enhancing the
documentation of requirements of fd passing over SOL_SOCKET connections.

Issue History
Date Modified Username Field Change
======================================================================
2014-04-24 11:50 geoffclare New Issue
2014-04-24 11:50 geoffclare Name => Geoff Clare
2014-04-24 11:50 geoffclare Organization => The Open Group
2014-04-24 11:50 geoffclare Section => pipe
2014-04-24 11:50 geoffclare Page Number => 1413
2014-04-24 11:50 geoffclare Line Number => 46643
2014-04-24 11:50 geoffclare Interp Status => ---
2014-04-24 15:13 eblake Note Added: 0002232
======================================================================
Austin Group Bug Tracker
2014-04-24 15:24:03 UTC
Permalink
The following issue has been RESOLVED.
======================================================================
http://austingroupbugs.net/view.php?id=835
======================================================================
Reported By: geoffclare
Assigned To:
======================================================================
Project: 1003.1(2013)/Issue7+TC1
Issue ID: 835
Category: System Interfaces
Type: Clarification Requested
Severity: Objection
Priority: normal
Status: Resolved
Name: Geoff Clare
Organization: The Open Group
User Reference:
Section: pipe
Page Number: 1413
Line Number: 46643
Interp Status: ---
Final Accepted Text:
Resolution: Accepted
Fixed in Version:
======================================================================
Date Submitted: 2014-04-24 11:50 UTC
Last Modified: 2014-04-24 15:24 UTC
======================================================================
Summary: file descriptor allocation by pipe() unclear
======================================================================

Issue History
Date Modified Username Field Change
======================================================================
2014-04-24 11:50 geoffclare New Issue
2014-04-24 11:50 geoffclare Name => Geoff Clare
2014-04-24 11:50 geoffclare Organization => The Open Group
2014-04-24 11:50 geoffclare Section => pipe
2014-04-24 11:50 geoffclare Page Number => 1413
2014-04-24 11:50 geoffclare Line Number => 46643
2014-04-24 11:50 geoffclare Interp Status => ---
2014-04-24 15:13 eblake Note Added: 0002232
2014-04-24 15:23 eblake Tag Attached: tc2-2008
2014-04-24 15:24 Don Cragun Status New => Resolved
2014-04-24 15:24 Don Cragun Resolution Open => Accepted
======================================================================
Austin Group Bug Tracker
2014-04-25 08:28:14 UTC
Permalink
The following issue has been set as RELATED TO issue 0000837.
======================================================================
http://austingroupbugs.net/view.php?id=835
======================================================================
Reported By: geoffclare
Assigned To:
======================================================================
Project: 1003.1(2013)/Issue7+TC1
Issue ID: 835
Category: System Interfaces
Type: Clarification Requested
Severity: Objection
Priority: normal
Status: Resolved
Name: Geoff Clare
Organization: The Open Group
User Reference:
Section: pipe
Page Number: 1413
Line Number: 46643
Interp Status: ---
Final Accepted Text:
Resolution: Accepted
Fixed in Version:
======================================================================
Date Submitted: 2014-04-24 11:50 UTC
Last Modified: 2014-04-24 15:24 UTC
======================================================================
Summary: file descriptor allocation by pipe() unclear
======================================================================
Relationships ID Summary
----------------------------------------------------------------------
related to 0000837 renumber section 2.13 to be 2.6 in Issue 8
======================================================================

Issue History
Date Modified Username Field Change
======================================================================
2014-04-24 11:50 geoffclare New Issue
2014-04-24 11:50 geoffclare Name => Geoff Clare
2014-04-24 11:50 geoffclare Organization => The Open Group
2014-04-24 11:50 geoffclare Section => pipe
2014-04-24 11:50 geoffclare Page Number => 1413
2014-04-24 11:50 geoffclare Line Number => 46643
2014-04-24 11:50 geoffclare Interp Status => ---
2014-04-24 15:13 eblake Note Added: 0002232
2014-04-24 15:23 eblake Tag Attached: tc2-2008
2014-04-24 15:24 Don Cragun Status New => Resolved
2014-04-24 15:24 Don Cragun Resolution Open => Accepted
2014-04-25 08:28 geoffclare Relationship added related to 0000837
======================================================================
Loading...