Re: [PATCH] POSIX-hostname up to 255 characters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 27 May 2006 07:54:38 -0600 Eric W. Biederman wrote:

> "Randy.Dunlap" <[email protected]> writes:
> 
> >> > "Randy.Dunlap" <[email protected]> writes:
> >> >
> >> > > This patch is against 2.6.17-rc5, for review/comments, please.
> >> > > It won't apply to -mm since Andrew has merged the uts-namespace patches.
> >> > > I'll see about merging it with those patches next.
> >> > > ---
> >
> > Per Eric's comments:
> >
> > 1.  use existing sys_gethostname() and sys_sethostname().
> >
> > 2.  add sys_uname_long() to read struct long_utsname;
> >
> > 3.  removed EXPORT_SYMBOL()s
> 
> I have to confess I am still uneasy with sys_uname_long.
> 
> The problem is that we have several revisions of this system
> call almost always simply to accommodate long string lengths,
> and the new interface doesn't seem any less susceptible to
> handling longer strings than the old one.

so you want an interface that is self-describing and extensible?

There are lots of syscalls that require struct pointers
from userspace... that users can get wrong.

Ulrich, do you have any comments/suggestions about this from
the userspace/lib perspective?


> Could we do something like:
> long sys_unamev(int count, char __user **name, size_t name_len)
> {
>         char *table[] = {
> 		system_utsname.sysname,
>                 system_utsname.nodename,
>                 system_utsname.release,
>                 system_utsname.version,
>                 system_utsname.machine,
>                 system_utsname.domainname,
>         };
>         char __user *data;
>         long error;
>         long len;
>         int i;
> 
> 	down_read(&uts_sem);
> 
>         error = -EINVAL;     
>         if (count > 6)
>         	goto out;
> 
>         len = sizeof(char __user *) * count;
>         for (i = 0; i < count; i++) {
>  		len += strlen(table[i]) + 1;
>         }
> 
>         error = -ERANGE;
>         if (len > name_len)
>         	goto out;
> 
>         error = -EFAULT;
>         if (!name)
>         	goto out;
>         if (!access_ok(VERIFY_WRITE, name, name_len))
>         	goto out;
> 
>         error = 0;
>         data = (char __user *)&name[count];
>         for (i = 0; i < count; i++) {
>         	size_t len = strlen(table[i]) + 1;
>                 error |= __put_user(data, name[i]);
>                 error |= __copy_to_user(data, table[i], len);
>                 data += len;
>         }
> out:
> 	up_read(&uts_sem);
>         return error;
> }
> 
> And then in user space we can do.
> struct utsname {
>        char *sysname;
>        char *nodename;
>        char *release;
>        char *version;
>        char *machine;
>        char *domainname;
>        char buf[4096 - (sizeof(char *)*6)];
> };
> 
> int uname(struct utsname *buf)
> {
>         return sys_unamev(6, buf, sizeof(*buf));
> }

---
~Randy
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux