mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: "Randy.Dunlap" <rdunlap@xenotime.net>
Cc: lkml <linux-kernel@vger.kernel.org>,
	drepper@redhat.com, akpm <akpm@osdl.org>,
	serue@us.ibm.com, sam@vilain.net, clg@fr.ibm.com, dev@sw.ru
Subject: Re: [PATCH] POSIX-hostname up to 255 characters
Date: Fri, 26 May 2006 03:14:06 -0600	[thread overview]
Message-ID: <m1zmh5b129.fsf@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <20060525204534.4068e730.rdunlap@xenotime.net> (Randy Dunlap's message of "Thu, 25 May 2006 20:45:34 -0700")

"Randy.Dunlap" <rdunlap@xenotime.net> 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.
> ---
>
> From: Randy Dunlap <rdunlap@xenotime.net>
>
> Implement POSIX-defined length for 'hostname' so that hostnames
> can be longer than 64 characters (max. 255 characters plus
> terminating NULL character).
>
> Adds sys_gethostname_long() and sys_sethostname_long().
> Tested on i386 and x86_64.

Is there any particular reason for this?
The existing sys_gethostname and sys_sethostname interfaces
should work for any string length.

Although I do agree that we need at least one new syscall
for the architectures that don't currently use get_hostname.

> Builds on powerpc(64).
> Test program is at http://www.xenotime.net/linux/src/hostnamelong.c .
>
> Consolidates many open-coded copiers of system_utsname into
> functions in lib/utsname.c::put_oldold_uname(), put_old_uname(),
> put_new_uname(). and put_long_uname().
>
> gethostname:
> http://www.opengroup.org/onlinepubs/009695399/functions/gethostname.html
> sysconf:
> http://www.opengroup.org/onlinepubs/009695399/functions/sysconf.html
> unistd.h:
> http://www.opengroup.org/onlinepubs/009695399/basedefs/unistd.h.html
> limits.h:
> http://www.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html
>
>
> Signed-off-by: Randy Dunlap <rdunlap@xenotime.net>

> --- linux-2617-rc5.orig/include/linux/utsname.h
> +++ linux-2617-rc5/include/linux/utsname.h
> @@ -30,7 +30,26 @@ struct new_utsname {
>  	char domainname[65];
>  };
>  
> -extern struct new_utsname system_utsname;
> +/* for (POSIX) IEEE Std. 1003.1, 2004 edition */
> +#define __POSIX_HOST_NAME_MAX 255 /* not including terminating NUL char */
>  
> +struct long_utsname {
> +	char sysname[__NEW_UTS_LEN + 1];	/* O/S name */
> +	char nodename[__POSIX_HOST_NAME_MAX + 1]; /* hostname, but keep field
> +					* name same as other structs here */
> +	char release[__NEW_UTS_LEN + 1];	/* O/S release level */
> +	char version[__NEW_UTS_LEN + 1];	/* version level of release */
> +	char machine[__NEW_UTS_LEN + 1];	/* machine hardware type */
> +	char domainname[__NEW_UTS_LEN + 1];
> +};

Are there any similar issues with the NIS domainname?

> --- /dev/null
> +++ linux-2617-rc5/lib/utsname.c
> @@ -0,0 +1,188 @@
> +#include <linux/compiler.h>
> +#include <linux/errno.h>
> +#include <linux/module.h>
> +#include <linux/rwsem.h>
> +#include <linux/utsname.h>
> +#include <asm/uaccess.h>
> +
> +#ifdef __ARCH_WANT_OLDOLD_UNAME
> +
> +int __put_oldold_uname(struct oldold_utsname __user *name)
> +{
> +	int error;
> +
> +	if (!name)
> +		return -EFAULT;
> +	if (!access_ok(VERIFY_WRITE, name, sizeof(struct oldold_utsname)))
> +		return -EFAULT;
> +
> +	error = __copy_to_user(&name->sysname, &system_utsname.sysname,
> +				__OLD_UTS_LEN);
> +	error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
> +	error |= __copy_to_user(&name->nodename, &system_utsname.nodename,
> +				__OLD_UTS_LEN);
> +	error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
> +	error |= __copy_to_user(&name->release, &system_utsname.release,
> +				__OLD_UTS_LEN);
> +	error |= __put_user(0, name->release + __OLD_UTS_LEN);
> +	error |= __copy_to_user(&name->version, &system_utsname.version,
> +				__OLD_UTS_LEN);
> +	error |= __put_user(0, name->version + __OLD_UTS_LEN);
> +	error |= __copy_to_user(&name->machine, &system_utsname.machine,
> +				__OLD_UTS_LEN);
> +	error |= __put_user(0, name->machine + __OLD_UTS_LEN);
> +
> +	return error;
> +}
> +EXPORT_SYMBOL(__put_oldold_uname);

Why do we need EXPORT_SYMBOL on syscall helpers?
Is there any legitimate modular user?

> +int put_oldold_uname(struct oldold_utsname __user *name)
> +{
> +	int error;
> +
> +	down_read(&uts_sem);
> +	error = __put_oldold_uname(name);
> +	up_read(&uts_sem);
> +
> +	error = error ? -EFAULT : 0;
> +	return error;
> +}
> +EXPORT_SYMBOL(put_oldold_uname);
> +
> +#endif
> +
> +#ifdef __ARCH_WANT_OLD_UNAME
> +
> +int __put_old_uname(struct old_utsname __user *name)
> +{
> +	int error;
> +
> +	if (!name)
> +		return -EFAULT;
> +	if (!access_ok(VERIFY_WRITE, name, sizeof(struct old_utsname)))
> +		return -EFAULT;
> +
> +	error = __copy_to_user(&name->sysname, &system_utsname.sysname,
> +				__NEW_UTS_LEN);
> +	error |= __put_user(0, name->sysname + __NEW_UTS_LEN);
> +	error |= __copy_to_user(&name->nodename, &system_utsname.nodename,
> +				__NEW_UTS_LEN);
> +	error |= __put_user(0, name->nodename + __NEW_UTS_LEN);
> +	error |= __copy_to_user(&name->release, &system_utsname.release,
> +				__NEW_UTS_LEN);
> +	error |= __put_user(0, name->release + __NEW_UTS_LEN);
> +	error |= __copy_to_user(&name->version, &system_utsname.version,
> +				__NEW_UTS_LEN);
> +	error |= __put_user(0, name->version + __NEW_UTS_LEN);
> +	error |= __copy_to_user(&name->machine, &system_utsname.machine,
> +				__NEW_UTS_LEN);
> +	error |= __put_user(0, name->machine + __NEW_UTS_LEN);
> +
> +	return error;
> +}
> +EXPORT_SYMBOL(__put_old_uname);
> +
> +int put_old_uname(struct old_utsname __user *name)
> +{
> +	int error;
> +
> +	down_read(&uts_sem);
> +	error = __put_old_uname(name);
> +	up_read(&uts_sem);
> +
> +	error = error ? -EFAULT : 0;
> +	return error;
> +}
> +EXPORT_SYMBOL(put_old_uname);
> +
> +#endif
> +
> +int __put_new_uname(struct new_utsname __user *name)
> +{
> +	int error;
> +
> +	if (!name)
> +		return -EFAULT;
> +	if (!access_ok(VERIFY_WRITE, name, sizeof(struct new_utsname)))
> +		return -EFAULT;
> +
> +	error = __copy_to_user(&name->sysname, &system_utsname.sysname,
> +				__NEW_UTS_LEN);
> +	error |= __put_user(0, name->sysname + __NEW_UTS_LEN);
> +	error |= __copy_to_user(&name->nodename, &system_utsname.nodename,
> +				__NEW_UTS_LEN);
> +	error |= __put_user(0, name->nodename + __NEW_UTS_LEN);
> +	error |= __copy_to_user(&name->release, &system_utsname.release,
> +				__NEW_UTS_LEN);
> +	error |= __put_user(0, name->release + __NEW_UTS_LEN);
> +	error |= __copy_to_user(&name->version, &system_utsname.version,
> +				__NEW_UTS_LEN);
> +	error |= __put_user(0, name->version + __NEW_UTS_LEN);
> +	error |= __copy_to_user(&name->machine, &system_utsname.machine,
> +				__NEW_UTS_LEN);
> +	error |= __put_user(0, name->machine + __NEW_UTS_LEN);
> +	error |= __copy_to_user(&name->domainname, &system_utsname.domainname,
> +				__NEW_UTS_LEN);
> +	error |= __put_user(0, name->domainname + __NEW_UTS_LEN);
> +
> +	return error;
> +}
> +EXPORT_SYMBOL(__put_new_uname);
> +
> +int put_new_uname(struct new_utsname __user *name)
> +{
> +	int error;
> +
> +	down_read(&uts_sem);
> +	error = __put_new_uname(name);
> +	up_read(&uts_sem);
> +
> +	error = error ? -EFAULT : 0;
> +	return error;
> +}
> +EXPORT_SYMBOL(put_new_uname);
> +
> +int __put_long_uname(struct long_utsname __user *name)
> +{
> +	int error;
> +
> +	if (!name)
> +		return -EFAULT;
> +	if (!access_ok(VERIFY_WRITE, name, sizeof(struct new_utsname)))
> +		return -EFAULT;
> +
> +	error = __copy_to_user(&name->sysname, &system_utsname.sysname,
> +				__NEW_UTS_LEN);
> +	error |= __put_user(0, name->sysname + __NEW_UTS_LEN);
> +	error |= __copy_to_user(&name->nodename, &system_utsname.nodename,
> +				__NEW_UTS_LEN);
> +	error |= __put_user(0, name->nodename + __NEW_UTS_LEN);
> +	error |= __copy_to_user(&name->release, &system_utsname.release,
> +				__NEW_UTS_LEN);
> +	error |= __put_user(0, name->release + __NEW_UTS_LEN);
> +	error |= __copy_to_user(&name->version, &system_utsname.version,
> +				__NEW_UTS_LEN);
> +	error |= __put_user(0, name->version + __NEW_UTS_LEN);
> +	error |= __copy_to_user(&name->machine, &system_utsname.machine,
> +				__NEW_UTS_LEN);
> +	error |= __put_user(0, name->machine + __NEW_UTS_LEN);
> +	error |= __copy_to_user(&name->domainname, &system_utsname.domainname,
> +				__NEW_UTS_LEN);
> +	error |= __put_user(0, name->domainname + __NEW_UTS_LEN);
> +
> +	return error;
> +}
> +EXPORT_SYMBOL(__put_long_uname);
> +
> +int put_long_uname(struct long_utsname __user *name)
> +{
> +	int error;
> +
> +	down_read(&uts_sem);
> +	error = __put_long_uname(name);
> +	up_read(&uts_sem);
> +
> +	error = error ? -EFAULT : 0;
> +	return error;
> +}
> +EXPORT_SYMBOL(put_long_uname);

put_long_uname is probably premature in this patch as nothing uses it yet.

> --- linux-2617-rc5.orig/drivers/char/random.c
> +++ linux-2617-rc5/drivers/char/random.c
> @@ -223,7 +223,6 @@
>   * Eastlake, Steve Crocker, and Jeff Schiller.
>   */
>  
> -#include <linux/utsname.h>
>  #include <linux/config.h>
>  #include <linux/module.h>
>  #include <linux/kernel.h>
> @@ -240,6 +239,7 @@
>  #include <linux/spinlock.h>
>  #include <linux/percpu.h>
>  #include <linux/cryptohash.h>
> +#include <linux/utsname.h>
>  
>  #include <asm/processor.h>
>  #include <asm/uaccess.h>

Is this movement of utsname something other than noise?

> --- linux-2617-rc5.orig/arch/i386/kernel/syscall_table.S
> +++ linux-2617-rc5/arch/i386/kernel/syscall_table.S
> @@ -315,3 +315,6 @@ ENTRY(sys_call_table)
>  	.long sys_splice
>  	.long sys_sync_file_range
>  	.long sys_tee			/* 315 */
> +	.long sys_ni_syscall		/* vmsplice */
> +	.long sys_gethostname_long
> +	.long sys_sethostname_long
> --- linux-2617-rc5.orig/arch/x86_64/ia32/ia32entry.S
> +++ linux-2617-rc5/arch/x86_64/ia32/ia32entry.S
> @@ -694,6 +694,8 @@ ia32_sys_call_table:
>  	.quad compat_sys_get_robust_list
>  	.quad sys_splice
>  	.quad sys_sync_file_range
> -	.quad sys_tee
> +	.quad sys_tee			/* 315 */
>  	.quad compat_sys_vmsplice
> +	.quad sys_gethostname
> +	.quad sys_sethostname
>  ia32_syscall_end:		

Huh?  Not gethostname_log?

  reply	other threads:[~2006-05-26  9:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-26  3:45 Randy.Dunlap
2006-05-26  9:14 ` Eric W. Biederman [this message]
2006-05-26 14:42   ` Jan-Benedict Glaw
2006-05-26 17:28     ` Randy.Dunlap
2006-05-26 18:01       ` Jan-Benedict Glaw
2006-05-26 18:15         ` linux-os (Dick Johnson)
2006-05-26 18:28           ` Ulrich Drepper
2006-05-26 18:35             ` linux-os (Dick Johnson)
2006-05-26 18:55               ` Ulrich Drepper
2006-05-26 19:12                 ` Jan Engelhardt
2006-05-26 21:31                   ` Eric W. Biederman
2006-05-27  1:39   ` Randy.Dunlap
2006-05-27  7:36     ` Randy.Dunlap
2006-05-27 13:54       ` Eric W. Biederman
2006-05-28 18:32         ` Randy.Dunlap

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=m1zmh5b129.fsf@ebiederm.dsl.xmission.com \
    --to=ebiederm@xmission.com \
    --cc=akpm@osdl.org \
    --cc=clg@fr.ibm.com \
    --cc=dev@sw.ru \
    --cc=drepper@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rdunlap@xenotime.net \
    --cc=sam@vilain.net \
    --cc=serue@us.ibm.com \
    /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

Powered by JetHome