This service will be undergoing maintenance at 00:00 UTC, 2017-10-23 It is expected to last about 30 minutes
Bug 134025 - Inefficient and possibly unsafe closing of file descriptors
Inefficient and possibly unsafe closing of file descriptors
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: nfs-utils (Show other bugs)
3
All Linux
medium Severity medium
: ---
: ---
Assigned To: Steve Dickson
Ben Levenson
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-09-28 21:23 EDT by Ulrich Drepper
Modified: 2007-11-30 17:10 EST (History)
0 users

See Also:
Fixed In Version: 1.0.6-37
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-10-14 22:32:26 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Replace brute force close loop (5.22 KB, patch)
2004-09-28 21:25 EDT, Ulrich Drepper
no flags Details | Diff
Updated patch (5.88 KB, patch)
2004-09-29 04:24 EDT, Ulrich Drepper
no flags Details | Diff
One more addition (6.11 KB, patch)
2004-09-29 04:38 EDT, Ulrich Drepper
no flags Details | Diff
One more addition to the patch (7.27 KB, patch)
2004-09-29 04:54 EDT, Ulrich Drepper
no flags Details | Diff

  None (edit)
Description Ulrich Drepper 2004-09-28 21:23:17 EDT
Description of problem:
Various daemons in nfs-utils close all file descriptors before
starting work.  This happens in a very inefficient way.  All iterate
over all possible descriptor values and make a close(2) call.  Image
what happens if the file descriptor limit is high?

There is no reason for this, programs can learn exactly which
descriptors are used from the /proc/self/fd directory.

Version-Release number of selected component (if applicable):
nfs-utils-1.0.6-34

How reproducible:
always

Steps to Reproduce:
1. strace /usr/sbin/rpc.mountd
2.
3.
  
Actual results:
tons of failing close syscalls

Expected results:
no failing syscall

Additional info:
I'll attach a patch.
Comment 1 Ulrich Drepper 2004-09-28 21:25:46 EDT
Created attachment 104479 [details]
Replace brute force close loop
Comment 2 Ulrich Drepper 2004-09-29 04:24:12 EDT
Created attachment 104492 [details]
Updated patch

Updated patch fixing the problem of closing the pipe.

Also replace signal(3) calls with sigaction calls.  This is more portable and
the blocking mask includes all three signals for which the signal handler is
registered.  Otherwise it could be possible to get a SIGINT, SIGTERM, and
SIGHUP signal all in a row, one handler interrupting the other.  If the handler
one day does what it is supposed to do according to the context this might be
fatal.
Comment 3 Ulrich Drepper 2004-09-29 04:38:56 EDT
Created attachment 104493 [details]
One more addition

One additional change.	Three programs contain code like this

  close(N); dup2(fd, N);

where N is the same in both function calls.  This is completely unnecessary
since dup2() implicitly closes the descriptor for its second parameter.  The
close() calls can be removed.
Comment 4 Ulrich Drepper 2004-09-29 04:54:28 EDT
Created attachment 104497 [details]
One more addition to the patch

Yet more signal -> sigaction transformations.  Again, all signals must be
blocked since otherwise they could interrupt each other.
Comment 5 Steve Dickson 2004-10-01 07:02:09 EDT
fixed in nfs-utils-1.0.6-37
Comment 6 Ulrich Drepper 2004-10-14 22:32:26 EDT
Verified.

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