public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
From: Arun Sharma <arun.sharma@intel.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: linux-arch@vger.kernel.org
Subject: Re: [PATCH 2/4] Consolidate do_execve32
Date: Tue, 13 Apr 2004 11:45:50 -0700	[thread overview]
Message-ID: <407C355E.7040009@intel.com> (raw)
In-Reply-To: <200404040222.35467.arnd@arndb.de>

[-- Attachment #1: Type: text/plain, Size: 413 bytes --]

On 4/3/2004 4:22 PM, Arnd Bergmann wrote:

> The code for sys32_execve/do_execve32 in most of the seven versions
> was copied from fs/exec.c but not kept up-to-date. The new
> compat_do_execve() function is based on the mips code and has been
> resync'ed with do_execve().
> 
> IA64 has some special fixup code in sys32_execve, so I'm not touching
> that.
> 

Attached is a patch that takes care of ia64.

	-Arun

[-- Attachment #2: compat_execve_ive.patch --]
[-- Type: text/plain, Size: 3104 bytes --]

diff -purN -X dontdiff linux-2.6.5-compat4/arch/ia64/ia32/sys_ia32.c linux-2.6.5-compat/arch/ia64/ia32/sys_ia32.c
--- linux-2.6.5-compat4/arch/ia64/ia32/sys_ia32.c	2004-04-06 09:54:19.000000000 +0800
+++ linux-2.6.5-compat/arch/ia64/ia32/sys_ia32.c	2004-04-08 15:33:24.000000000 +0800
@@ -90,58 +90,17 @@ extern unsigned long arch_get_unmapped_a
 /* XXX make per-mm: */
 static DECLARE_MUTEX(ia32_mmap_sem);
 
-static int
-nargs (unsigned int arg, char **ap)
-{
-	unsigned int addr;
-	int n, err;
-
-	if (!arg)
-		return 0;
-
-	n = 0;
-	do {
-		err = get_user(addr, (unsigned int *)A(arg));
-		if (err)
-			return err;
-		if (ap)
-			*ap++ = (char *) A(addr);
-		arg += sizeof(unsigned int);
-		n++;
-	} while (addr);
-	return n - 1;
-}
-
 asmlinkage long
-sys32_execve (char *filename, unsigned int argv, unsigned int envp,
-	      struct pt_regs *regs)
+sys32_execve (char *name, compat_uptr_t __user *argv, compat_uptr_t __user *envp, struct pt_regs *regs)
 {
+	long error;
+	char *filename;
 	unsigned long old_map_base, old_task_size, tssd;
-	char **av, **ae;
-	int na, ne, len;
-	long r;
-
-	na = nargs(argv, NULL);
-	if (na < 0)
-		return na;
-	ne = nargs(envp, NULL);
-	if (ne < 0)
-		return ne;
-	len = (na + ne + 2) * sizeof(*av);
-	av = kmalloc(len, GFP_KERNEL);
-	if (!av)
-		return -ENOMEM;
-
-	ae = av + na + 1;
-	av[na] = NULL;
-	ae[ne] = NULL;
 
-	r = nargs(argv, av);
-	if (r < 0)
-		goto out;
-	r = nargs(envp, ae);
-	if (r < 0)
-		goto out;
+	filename = getname(name);
+	error = PTR_ERR(filename);
+	if (IS_ERR(filename))
+		return error;
 
 	old_map_base  = current->thread.map_base;
 	old_task_size = current->thread.task_size;
@@ -152,20 +111,19 @@ sys32_execve (char *filename, unsigned i
 	current->thread.task_size = DEFAULT_TASK_SIZE;
 	ia64_set_kr(IA64_KR_IO_BASE, current->thread.old_iob);
 	ia64_set_kr(IA64_KR_TSSD, current->thread.old_k1);
+
+	error = compat_do_execve(filename, argv, envp, regs);
+	putname(filename);
 
-	set_fs(KERNEL_DS);
-	r = sys_execve(filename, av, ae, regs);
-	if (r < 0) {
+	if (error < 0) {
 		/* oops, execve failed, switch back to old values... */
 		ia64_set_kr(IA64_KR_IO_BASE, IA32_IOBASE);
 		ia64_set_kr(IA64_KR_TSSD, tssd);
 		current->thread.map_base  = old_map_base;
 		current->thread.task_size = old_task_size;
-		set_fs(USER_DS);	/* establish new task-size as the address-limit */
 	}
-  out:
-	kfree(av);
-	return r;
+
+	return error;
 }
 
 int cp_compat_stat(struct kstat *stat, struct compat_stat *ubuf)
diff -purN -X dontdiff linux-2.6.5-compat4/fs/compat.c linux-2.6.5-compat/fs/compat.c
--- linux-2.6.5-compat4/fs/compat.c	2004-04-06 09:54:19.000000000 +0800
+++ linux-2.6.5-compat/fs/compat.c	2004-04-08 18:21:51.000000000 +0800
@@ -981,7 +981,6 @@ out:
 	return ret;
 }
 
-#ifndef __ia64__ /* ia64 needs some extra tweaks */
 /*
  * compat_count() counts the number of arguments/envelopes. It is basically
  * a copy of count() from fs/exec.c, except that it works with 32 bit argv
@@ -1212,7 +1211,6 @@ out_file:
 
 	return retval;
 }
-#endif /* !__ia64__ */
 
 #define __COMPAT_NFDBITS       (8 * sizeof(compat_ulong_t))
 

  reply	other threads:[~2004-04-13 18:46 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200404040204.03594.arnd@arndb.de>
2004-04-04  0:22 ` [PATCH 1/4] Consolidate sys32_readv and sys32_writev Arnd Bergmann
2004-04-04  0:22 ` [PATCH 2/4] Consolidate do_execve32 Arnd Bergmann
2004-04-13 18:45   ` Arun Sharma [this message]
2004-04-04  0:22 ` [PATCH 3/4] Consolidate sys32_select Arnd Bergmann
2004-04-04 10:24   ` Andi Kleen
2004-04-04 10:36     ` Arnd Bergmann
2004-04-04 11:04       ` Andi Kleen
2004-04-04 11:07     ` William Lee Irwin III
2004-04-04 22:51       ` Arnd Bergmann
2004-04-04 23:35         ` Andi Kleen
2004-04-04 23:41           ` Arnd Bergmann
2004-04-07 20:46   ` Arun Sharma
2004-04-08  8:22     ` Arnd Bergmann
2004-04-12 18:55       ` Arun Sharma
2004-04-04  0:22 ` [PATCH 4/4] Consolidate sys32_nfsservctl Arnd Bergmann

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=407C355E.7040009@intel.com \
    --to=arun.sharma@intel.com \
    --cc=arnd@arndb.de \
    --cc=linux-arch@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