Re: Bug in set/gethostname.

Linus Torvalds (torvalds@transmeta.com)
Sun, 17 May 1998 14:00:37 -0700 (PDT)


On Sun, 17 May 1998, Alan Cox wrote:
>
> Both single and SMP sethostname/gethostname have a problem. If you get a page
> fault during the copy in a gethostname can return a corrupt nodename. If it
> has overwritten the previous 0 byte you can get a lot of crap in theory
> but I've never seen it do that
>
> If you do two sethostnames and one of them sleeps you can get a mixed up
> or shortened hostname.
>
> sethostname/sys_newuname/sys_gethostname/sys_setdomainname need a reader/writer
> lock on them.

Alan, why?

It's not a security risk, and it's not a real problem as far as I can see.
It's something you can only see if you write a completely unrealistic
program, and even when you see it the worst that happens is that you get a
crap return to a crap program.

Crap programs are _supposed_ to return crap.

End even then you actually have to be root to get the bad behaviour. If
you're root, you can do some _really_ bad things, so I don't see the point
in changing this, adding code that sounds completely unnecessary unless
you give a real-world example.

Usually you set the hostname once, at bootup. Or maybe you're doing system
administration and playing around with it, but when you do so you'd better
be fairly quiescent anyway and restart all your networking deamons etc
after having done so - so we're talking about something that isn't done on
a whim.

In short, give a better reason, because as it stands, this "bug" is not a
bug, but just a case of "let's not add code to take care of a case we
shouldn't care about anyway". It's a "bug" in the same sense as it's a
"bug" that root can write to /dev/kmem and make the system unstable.

Linus

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