lkml.org 
[lkml]   [1998]   [May]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: Bug in set/gethostname.
    Hi guys,

    Linus writes ...

    asmlinkage int sys_gethostname(char *name, int len)
    {
    - int i;
    + int i, errno;

    if (len < 0)
    return -EINVAL;
    i = 1 + strlen(system_utsname.nodename);
    if (i > len)
    i = len;
    - return copy_to_user(name, system_utsname.nodename, i) ? -EFAULT : 0;
    + down(&uts_sem);
    + errno = 0;
    + if (copy_to_user(name, system_utsname.nodename, i))
    + errno = -EFAULT;
    + up(&uts_sem);
    + return errno;
    }

    In my humble opinion, sys_gethostname should acquire the semaphore
    before calling strlen on system_utsname.nodename. That way, gethostname
    will return either the old name or the new name, but not some mongrel
    mixture of the two.

    Also, system_utsname is used in a bunch of other places. These places
    look like they actually read or write it:

    arch/alpha/kernel/osf_sys.c
    arch/arm/kernel/sys_arm.c
    arch/i386/kernel/sys_i386.c
    arch/mips/kernel/syscall.c
    arch/ppc/kernel/syscalls.c
    arch/sparc/kernel/sys_sparc.c
    arch/sparc/kernel/sys_sunos.c
    arch/sparc64/kernel/sys_sparc.c
    arch/sparc64/kernel/sys_sunos32.c
    arch/sparc64/solaris/misc.c
    drivers/char/random.c
    drivers/sound/soundcard.c
    fs/lockd/clntproc.c
    fs/lockd/mon.c
    fs/nfs/nfsroot.c
    kernel/sys.c
    kernel/sysctl.c
    net/ipv4/ipconfig.c
    net/sunrpc/auth_unix.c

    Cheers,

    Michael Chastain
    <mailto:mec@shout.net>
    "love without fear"

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

    \
     
     \ /
      Last update: 2005-03-22 13:42    [W:0.019 / U:31.340 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site