mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 03:36:19 +00:00
Fix UTS corruption during clone(CLONE_NEWUTS)
struct utsname is copied from master one without any exclusion. Here is sample output from one proggie doing sethostname("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); sethostname("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); and another clone(,, CLONE_NEWUTS, ...) uname() hostname = 'aaaaaaaaaaaaaaaaaaaaaaaaabbbbb' hostname = 'bbbaaaaaaaaaaaaaaaaaaaaaaaaaaa' hostname = 'aaaaaaaabbbbbbbbbbbbbbbbbbbbbb' hostname = 'aaaaaaaaaaaaaaaaaaaaaaaaaabbbb' hostname = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaabb' hostname = 'aaabbbbbbbbbbbbbbbbbbbbbbbbbbb' hostname = 'bbbbbbbbbbbbbbbbaaaaaaaaaaaaaa' Hostname is sometimes corrupted. Yes, even _the_ simplest namespace activity had bug in it. :-( Signed-off-by: Alexey Dobriyan <adobriyan@sw.ru> Acked-by: Serge Hallyn <serue@us.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
019ad4a0a6
commit
efc63c4fb0
1 changed files with 2 additions and 0 deletions
|
@ -28,7 +28,9 @@ static struct uts_namespace *clone_uts_ns(struct uts_namespace *old_ns)
|
||||||
if (!ns)
|
if (!ns)
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
|
down_read(&uts_sem);
|
||||||
memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
|
memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
|
||||||
|
up_read(&uts_sem);
|
||||||
kref_init(&ns->kref);
|
kref_init(&ns->kref);
|
||||||
return ns;
|
return ns;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue