Bug 864371 - 3.7.0 kernel dup3 (fd, fd) doesn't fail
3.7.0 kernel dup3 (fd, fd) doesn't fail
Product: Fedora
Classification: Fedora
Component: kernel (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Kernel Maintainer List
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2012-10-09 05:18 EDT by Richard W.M. Jones
Modified: 2016-04-26 09:29 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 864325
Last Closed: 2013-03-19 11:02:46 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
dup3.c (test case) (423 bytes, text/x-csrc)
2012-10-09 05:24 EDT, Richard W.M. Jones
no flags Details

  None (edit)
Description Richard W.M. Jones 2012-10-09 05:18:01 EDT
Description of problem:

A second problem we noticed from the gnulib test is that this
assertion fails with the latest upstream kernel:

      /* Assigning to self is invalid.  */
      errno = 0;
      ASSERT (dup3 (fd, fd, o_flags) == -1);   <--- fails
      ASSERT (errno == EINVAL);

dup3 is not currently specified by POSIX, so technically it is fine
for dup3 on Linux to do anything it likes.

*However* the proposal for dup3 in POSIX:



  "The dup3( ) function shall be equivalent to the dup2( ) function if
  the flag argument is 0, except that it shall be an error if fildes
  is equal to fildes2."

So it's probably a good idea for Linux not to regress here.

(Thanks Jim Meyering for finding the link)

Version-Release number of selected component (if applicable):


How reproducible:

Comment 1 Richard W.M. Jones 2012-10-09 05:18:21 EDT
Upstream bug report:
Comment 2 Richard W.M. Jones 2012-10-09 05:24:54 EDT
Created attachment 624011 [details]
dup3.c (test case)

Test case.

$ gcc /tmp/dup3.c -o /tmp/dup3
$ /tmp/dup3 
dup3 (fd, fd, 0) didn't fail!
Comment 3 Richard W.M. Jones 2012-10-09 13:08:33 EDT
This patch was apparently accepted upstream:

Note You need to log in before you can comment on or make changes to this bug.