[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <19f34abd0809130025x4901c749u987bc2cd30a1586e@mail.gmail.com>
Date: Sat, 13 Sep 2008 09:25:48 +0200
From: "Vegard Nossum" <vegard.nossum@...il.com>
To: "Andrew Morton" <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org
Subject: Re: [RFC][PATCH] utsname: completely overwrite prior information
On Sat, Sep 13, 2008 at 12:11 AM, Andrew Morton
<akpm@...ux-foundation.org> wrote:
> fair enuf. Did you check allthe other fields in 'struct new_utsname'?
As far as I can tell, only nodename (hostname) and domainname may be
changed by userspace.
>
>> index 038a7bc..78b4515 100644
>> --- a/kernel/sys.c
>> +++ b/kernel/sys.c
>> @@ -1352,7 +1352,8 @@ asmlinkage long sys_sethostname(char __user *name, int len)
>> errno = -EFAULT;
>> if (!copy_from_user(tmp, name, len)) {
>> memcpy(utsname()->nodename, tmp, len);
>> - utsname()->nodename[len] = 0;
>> + memset(utsname()->nodename + len, 0,
>> + sizeof(utsname()->nodename) - len);
>
> We could do the memset before the memcpy. It's more work, but less
> text. Whatever.
Whatever :-)
> While we're there, the code generation in there is a bit sloppy. How's
> this look?
>
>
> From: Andrew Morton <akpm@...ux-foundation.org>
>
> utsname() is quite expensive to calculate. Cache it in a local.
>
> text data bss dec hex filename
> before: 11136 720 16 11872 2e60 kernel/sys.o
> after: 11096 720 16 11832 2e38 kernel/sys.o
>
> Cc: Vegard Nossum <vegard.nossum@...il.com>
> Cc: "Eric W. Biederman" <ebiederm@...ssion.com>
> Cc: "Serge E. Hallyn" <serue@...ibm.com>
> Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
I agree with this change. FWIW: Acked-by: Vegard Nossum
<vegard.nossum@...il.com>
There seems to be a few more places throughout the kernel which
needlessly call utsname() more than once. I will keep it in mind.
Thanks,
Vegard
--
"The animistic metaphor of the bug that maliciously sneaked in while
the programmer was not looking is intellectually dishonest as it
disguises that the error is the programmer's own creation."
-- E. W. Dijkstra, EWD1036
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists