Re: Bug in set/gethostname.

Alan Cox (alan@lxorguk.ukuu.org.uk)
Sun, 17 May 1998 23:20:07 +0100 (BST)


> > Usually you set the hostname once, at bootup.
>
> I use dynamic PPP, and have /bin/hostname called from /etc/ppp/ip-up to
> set a hostname that matches the dynamically assigned IP address. I've
> never noticed the name getting corrupted.

The odds are very very low. Its just it can occur. The fact doing something
similar to what you are doing has taken 5 years to catch me says that. Also
its rare that the name would be split over two pages. If its in a single page
then the fortunate layout of sethostname saves your butt as you will get
either the old or new name, since the copy_from_user won't fault during a
copy of the hostname but only until the first byte appears. In that case
once the copy begins there is no further race on a single CPU host. On
a dual CPU host there is still a race but its a matter of clocks wide.

Alan

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu