Bug 456 - bindresvport() may ports reserved by other services...
Summary: bindresvport() may ports reserved by other services...
Status: REOPENED
Alias: None
Product: glibc
Classification: Unclassified
Component: network (show other bugs)
Version: 2.3.3
: P2 normal
Target Milestone: ---
Assignee: GOTO Masanori
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-17 09:39 UTC by Mattias.glibc
Modified: 2016-09-05 15:32 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
Project(s) to access:
ssh public key:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mattias.glibc 2004-10-17 09:39:28 UTC
I got problem with the rndc command from BIND, the problem was that named
coulnd't allocate (listen to) port 953 as sepecified in /etc/services. It turned
out that rpc.rquotad had started to use port 953. So, I wondered why is
rpc.rquotad using port 953, when it is reserved in /etc/services to rndc?

It turned out that rpc.rquotad found its rpc protocol in /etc/rpc, with the
following line:
rquotad    100011  rquotaprog quota rquota

But nither of rquotad, rquotaporg quota or rquota existed in /etc/services, so
rpc.rquotad called:
svctcp_create(RPC_ANYSOCK, 0,0)

svctcp_create will then in turn create a new socket and bind that port using
bindresvport(sock, &addr).

bindresvport will then bind the port according to it's magic.

But unfortinally bindresvport's magic doesnt take /etc/services into account, so
 in my case bindresvport selected port 953, resulting in named failing to
allocate it's control port rndc.

Shouldn't bindresvport instead of just limiting its portrange from 600 <= port <
1024 to at least check the port with getservbyport and ensure that the port
isn't allready allocated by another service.

I would gladly help to implement a frendlier bindresvport().

Regards
  Mattias Grönlund
Comment 1 GOTO Masanori 2004-10-19 14:57:18 UTC
This kind of discussion is often come up and finally we find it's design problem:
http://sources.redhat.com/ml/libc-alpha/2002-11/msg00302.html
http://bugzilla.redhat.com/bugzilla/long_list.cgi?buglist=103401

Comment 2 Florian Weimer 2016-04-06 11:14:36 UTC
Users run into this often enough so that w have to fix this.