diff options
author | Alexey Dobriyan <adobriyan@sw.ru> | 2007-09-19 01:46:27 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-09-19 14:24:17 -0400 |
commit | efc63c4fb0f95865907472d1c6bc0cfea9ee156b (patch) | |
tree | 197650d8698f62c4886305e859cfbbf16aada5fc /kernel/utsname.c | |
parent | 019ad4a0a60b09022945273848b5a686e39a78aa (diff) |
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>
Diffstat (limited to 'kernel/utsname.c')
-rw-r--r-- | kernel/utsname.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/kernel/utsname.c b/kernel/utsname.c index 9d8180a0f0d8..816d7b24fa03 100644 --- a/kernel/utsname.c +++ b/kernel/utsname.c | |||
@@ -28,7 +28,9 @@ static struct uts_namespace *clone_uts_ns(struct uts_namespace *old_ns) | |||
28 | if (!ns) | 28 | if (!ns) |
29 | return ERR_PTR(-ENOMEM); | 29 | return ERR_PTR(-ENOMEM); |
30 | 30 | ||
31 | down_read(&uts_sem); | ||
31 | memcpy(&ns->name, &old_ns->name, sizeof(ns->name)); | 32 | memcpy(&ns->name, &old_ns->name, sizeof(ns->name)); |
33 | up_read(&uts_sem); | ||
32 | kref_init(&ns->kref); | 34 | kref_init(&ns->kref); |
33 | return ns; | 35 | return ns; |
34 | } | 36 | } |