mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Vegard Nossum" <vegard.nossum@gmail.com>
To: "Andrew Morton" <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH] utsname: completely overwrite prior information
Date: Sat, 13 Sep 2008 09:25:48 +0200	[thread overview]
Message-ID: <19f34abd0809130025x4901c749u987bc2cd30a1586e@mail.gmail.com> (raw)
In-Reply-To: <20080912151129.1c8d38f8.akpm@linux-foundation.org>

On Sat, Sep 13, 2008 at 12:11 AM, Andrew Morton
<akpm@linux-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@linux-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@gmail.com>
> Cc: "Eric W. Biederman" <ebiederm@xmission.com>
> Cc: "Serge E. Hallyn" <serue@us.ibm.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

I agree with this change. FWIW: Acked-by: Vegard Nossum
<vegard.nossum@gmail.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

      reply	other threads:[~2008-09-13  7:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-12 20:36 Vegard Nossum
2008-09-12 22:11 ` Andrew Morton
2008-09-13  7:25   ` Vegard Nossum [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19f34abd0809130025x4901c749u987bc2cd30a1586e@mail.gmail.com \
    --to=vegard.nossum@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®