summaryrefslogtreecommitdiffstats
path: root/support/nfs/mydaemon.c
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2015-09-16 11:18:02 -0400
committerSteve Dickson <steved@redhat.com>2015-09-16 11:21:41 -0400
commit3a5732152c60f8cefaa804db0b81e424e96ee657 (patch)
tree34086c0510dfdefc2f14e08e2718ddffb81b438c /support/nfs/mydaemon.c
parent78240c41be17bd20d5fb5b70b6f470d8e779adee (diff)
downloadnfs-utils-3a5732152c60f8cefaa804db0b81e424e96ee657.tar.gz
nfs-utils-3a5732152c60f8cefaa804db0b81e424e96ee657.tar.xz
nfs-utils-3a5732152c60f8cefaa804db0b81e424e96ee657.zip
statd: statd_get_socket() should return open fds
Tastky <tastky@gmail.com> reports: > There appears to be a bug in nfs-utils exposed by musl, which > makes rpc.statd loop with: > > my_svc_run() - select: Bad file descriptor OpenGroup says getservbyport(3) is supposed to return NULL when no entry exists for the specified port. But musl's getservbyport(3) never returns NULL (likely a bug). Thus statd_get_socket() tries bindresvport(3) 100 times, then gives up and returns the last socket it created. This should work fine, but there's a bug in the retry loop: Rich Felker <dalias@libc.org> says: > The logic bug is the count-down loop that closes all the temp > sockets. In the case where the loop terminates via break, it > leaves the last one open and only closes the extras. But in the > case where where the loop terminates via the end condition in the > for statement, the close loop closes all the sockets _including_ > the one it intends to use. (emphasis mine). The closed socket fd is then passed to select(2). See also: http://www.openwall.com/lists/musl/2015/08 The fix is to perform the loop termination test before adding sockfd to the set of fds to be closed. As additional clean ups, remove the use of the variable-length stack array, and switch to variable names that better document the purpose of this logic. Reported-by: Tastky <tastky@gmail.com> Fixes: eb8229338f06 ("rpc.statd: Fix socket binding loop.") Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'support/nfs/mydaemon.c')
0 files changed, 0 insertions, 0 deletions