Bug 864371 - 3.7.0 kernel dup3 (fd, fd) doesn't fail
Summary: 3.7.0 kernel dup3 (fd, fd) doesn't fail
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: kernel
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Kernel Maintainer List
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-10-09 09:18 UTC by Richard W.M. Jones
Modified: 2016-04-26 13:29 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of: 864325
Environment:
Last Closed: 2013-03-19 15:02:46 UTC
Type: Bug
Embargoed:


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

Description Richard W.M. Jones 2012-10-09 09:18:01 UTC
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:

  http://austingroupbugs.net/view.php?id=411

says:

  "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):

3.7.0-0.rc0.git2.4.fc19.x86_64

How reproducible:

100%

Comment 1 Richard W.M. Jones 2012-10-09 09:18:21 UTC
Upstream bug report:
http://marc.info/?l=linux-fsdevel&m=134977414011004&w=2

Comment 2 Richard W.M. Jones 2012-10-09 09:24:54 UTC
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 17:08:33 UTC
This patch was apparently accepted upstream:
http://marc.info/?l=linux-fsdevel&m=134979287120445&w=2


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