Re: bind() allowed to non-local addresses

From: Matt Peterson (mpeterson@calderasystems.com)
Date: Fri Oct 20 2000 - 17:44:10 EST


Eric Lammerts wrote:
>
> On Fri, 20 Oct 2000, Matt Peterson wrote:
> > Are you also suggesting that every other program that expects bind() to
> > fail with EADDRNOTAVAIL are broken too? Just for fun, I greped all
> > sources of software shipped in Caldera's distributions for instances of
> > where a check is made for EADDRNOTAVAIL after a call to bind(). Guess
> > what else besides Java is probably "broken" ...
> >
> > - lpng
> > - bind 8.2
> > - automount
> > - cvs
> > - dhcpd
> > - KDE
> > - UCL mbone
> > - ncftp
> > - netatalk
> > - nfsd
> > - rexec
> > - pppd
> > - sendmail
> > - xchat
>
> Just for fun I looked at the sources of cvs, ncftp, netatalk, rexec
> and pppd. Guess what? None of them check for EADDRNOTAVAIL after a
> call to bind().

I stand corrected. I double checked and not all of the above check
EADDRNOTAVAIL after a bind(). My grep script was only smart enough to
check for calls to bind() and EADDRNOTAVAIL . It turns out that
EADDRNOTAVAIL is also a commonly checked return code to the
ioctl(SIOCDIFADDR) which is not an issue because it probably does not
follow the bind() code path through the kernel.

> Cvs and pppd don't even call bind()!
>
> Get your facts straight, please.

cvs-1.10.8/vms/rcmd.c:64: rs = bind(s, (struct sockaddr *)&local_isa,
sizeof(local_isa));
cvs-1.10.8/vms/rcmd.c:79: rs = bind(s, (struct sockaddr *)&local_isa,
sizeof(local_isa));

The cvs code does call bind, but you are right, it does not check rs for
EADDRNOTAVAIL. pppd uses the ioctl() mentioned above. My apologies.

I do not have time to go through an analize code to see if the success
of bind when the interface is not known would cause any problems. My
guess is that it would not because before binding the interface is
looked up via ioctl() or gethostbyname(). Also as mentioned earlier in
this thread, INADDR_ANY is also commonly used.

The point I probably failed in making is that (right or wrong) many
developers (because of tradition, documentation and various specs)
expect bind() on a non-local address to fail. This is certainly the
case with Sun and many authors of Sockets interface documentation.

Anyway, I am through discussing the issue. We will probably use the
sysctl solution posted by David Miller earlier in the thread with
default bind() behavior reverted.

-- 
Matthew Peterson
Sr. Software Engineer
Caldera Systems, Inc
mpeterson@caldera.com

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Oct 23 2000 - 21:00:17 EST