Project

General

Profile

Actions

Bug #12934

closed

sockfs rights test should close unneeded descriptors

Added by Jason King over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
tests
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Bite-size
Tags:
Gerrit CR:

Description

The sockfs rights test will fail if when invoked, more than fds 0, 1, 2 exist (such as an agent running the tests that forgets to close them during fork+exec):

[root@zfs-test ~]# ./rights.32 4>&2
    !!!: client descriptors = 1(0x1) (expected 0(0))
     + : FAIL send 1, recv 1
    !!!: client descriptors = 1(0x1) (expected 0(0))
     + : FAIL send 10, recv 10
    !!!: client descriptors = 1(0x1) (expected 0(0))
     + : FAIL send 2, recv 1
    !!!: client descriptors = 1(0x1) (expected 0(0))
     + : FAIL send 2, recv 1, buffer 5
    !!!: client descriptors = 1(0x1) (expected 0(0))
     + : FAIL send 2, recv 1, buffer 6
    !!!: client descriptors = 1(0x1) (expected 0(0))
     + : FAIL send 2, recv 1, buffer 7
    !!!: client descriptors = 1(0x1) (expected 0(0))
     + : FAIL send 2, recv 0, hdronly
    !!!: client descriptors = 1(0x1) (expected 0(0))
     + : FAIL send 2, recv 0, hdr - 1
    !!!: client descriptors = 1(0x1) (expected 0(0))
     + : FAIL send 2, recv 0, hdr - 5
    !!!: client descriptors = 1(0x1) (expected 0(0))
     + : FAIL send 1, recv 1, pre 8
    !!!: client descriptors = 1(0x1) (expected 0(0))
     + : FAIL send 1, recv 1, pre 7
    !!!: client descriptors = 1(0x1) (expected 0(0))
     + : FAIL send 1, recv 1, pre 6
    !!!: client descriptors = 1(0x1) (expected 0(0))
     + : FAIL send 1, recv 1, pre 5
    !!!: client descriptors = 1(0x1) (expected 0(0))
     + : FAIL send 2, recv 1, pre 8
    !!!: client descriptors = 1(0x1) (expected 0(0))
     + : FAIL send 2, recv 1, pre 7
    !!!: client descriptors = 1(0x1) (expected 0(0))
     + : FAIL send 2, recv 1, pre 6
    !!!: client descriptors = 1(0x1) (expected 0(0))
     + : FAIL send 2, recv 1, pre 5
    !!!: client descriptors = 1(0x1) (expected 0(0))
     + : FAIL send 2, recv 1, pre 4
    !!!: client descriptors = 1(0x1) (expected 0(0))
     + : FAIL send 2, recv 1, pre 3
    !!!: client descriptors = 1(0x1) (expected 0(0))
     + : FAIL send 2, recv 1, pre 2
    !!!: client descriptors = 1(0x1) (expected 0(0))
     + : FAIL send 2, recv 1, pre 1
    !!!: client descriptors = 1(0x1) (expected 0(0))
     + : FAIL send 2, recv 1, pre 8, buffer 5
    !!!: client descriptors = 1(0x1) (expected 0(0))
     + : FAIL send 2, recv 1, pre 8, buffer 6
    !!!: client descriptors = 1(0x1) (expected 0(0))
     + : FAIL send 2, recv 1, pre 8, buffer 7
    !!!: client descriptors = 1(0x1) (expected 0(0))
     + : FAIL send 10, recv 1, pre 8

The fix is trivial -- just add closefrom(STDERR_FILENO + 1) at the start of the program.

Actions #1

Updated by Jason King over 1 year ago

With the fix, both versions now pass even when called with extra fds open:

./rights.32 4>&2
     + : PASS send 1, recv 1
     + : PASS send 10, recv 10
     + : PASS send 2, recv 1
     + : PASS send 2, recv 1, buffer 5
     + : PASS send 2, recv 1, buffer 6
     + : PASS send 2, recv 1, buffer 7
     + : PASS send 2, recv 0, hdronly
     + : PASS send 2, recv 0, hdr - 1
     + : PASS send 2, recv 0, hdr - 5
     + : PASS send 1, recv 1, pre 8
     + : PASS send 1, recv 1, pre 7
     + : PASS send 1, recv 1, pre 6
     + : PASS send 1, recv 1, pre 5
     + : PASS send 2, recv 1, pre 8
     + : PASS send 2, recv 1, pre 7
     + : PASS send 2, recv 1, pre 6
     + : PASS send 2, recv 1, pre 5
     + : PASS send 2, recv 1, pre 4
     + : PASS send 2, recv 1, pre 3
     + : PASS send 2, recv 1, pre 2
     + : PASS send 2, recv 1, pre 1
     + : PASS send 2, recv 1, pre 8, buffer 5
     + : PASS send 2, recv 1, pre 8, buffer 6
     + : PASS send 2, recv 1, pre 8, buffer 7
     + : PASS send 10, recv 1, pre 8
[root@zfs-test ~]# ./rights.64 4>&2
     + : PASS send 1, recv 1
     + : PASS send 10, recv 10
     + : PASS send 2, recv 1
     + : PASS send 2, recv 1, buffer 5
     + : PASS send 2, recv 1, buffer 6
     + : PASS send 2, recv 1, buffer 7
     + : PASS send 2, recv 0, hdronly
     + : PASS send 2, recv 0, hdr - 1
     + : PASS send 2, recv 0, hdr - 5
     + : PASS send 1, recv 1, pre 8
     + : PASS send 1, recv 1, pre 7
     + : PASS send 1, recv 1, pre 6
     + : PASS send 1, recv 1, pre 5
     + : PASS send 2, recv 1, pre 8
     + : PASS send 2, recv 1, pre 7
     + : PASS send 2, recv 1, pre 6
     + : PASS send 2, recv 1, pre 5
     + : PASS send 2, recv 1, pre 4
     + : PASS send 2, recv 1, pre 3
     + : PASS send 2, recv 1, pre 2
     + : PASS send 2, recv 1, pre 1
     + : PASS send 2, recv 1, pre 8, buffer 5
     + : PASS send 2, recv 1, pre 8, buffer 6
     + : PASS send 2, recv 1, pre 8, buffer 7
     + : PASS send 10, recv 1, pre 8
Actions #2

Updated by Electric Monk over 1 year ago

  • Gerrit CR set to 781
Actions #3

Updated by Electric Monk over 1 year ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

git commit 480497bc2ff96b447dc09403a6c187a1593ac1ec

commit  480497bc2ff96b447dc09403a6c187a1593ac1ec
Author: Jason King <jason.king@joyent.com>
Date:   2020-07-08T22:13:41.000Z

    12934 sockfs rights test should close unneeded descriptors
    Reviewed by: Dan McDonald <danmcd@joyent.com>
    Reviewed by: Robert Mustacchi <rm@fingolfin.org>
    Approved by: Richard Lowe <richlowe@richlowe.net>

Actions

Also available in: Atom PDF