linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Consolidate compat_sys_waitid
@ 2005-02-15  3:01 Stephen Rothwell
  2005-02-15  9:51 ` Andi Kleen
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Stephen Rothwell @ 2005-02-15  3:01 UTC (permalink / raw)
  To: LKML; +Cc: paulus, anton, davem, ralf, tony.luck, ak, willy, schwidefsky

Hi all,

This patch does:
	- consolidate the three implementations of compat_sys_waitid
	  (some were called sys32_waitid).
	- adds sys_waitid syscall to ppc
	- adds sys_waitid and compat_sys_waitid syscalls to ppc64

Parisc seemed to assume th existance of compat_sys_waitid.  The MIPS
syscall tables have me confused and may need updating.  I have arbitrarily
chosen the next available syscall number on ppc and ppc64, I hope this is
correct.

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>

Comments?

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

diff -ruNp linus-bk/arch/ia64/ia32/ia32_entry.S linus-bk-waitid.1/arch/ia64/ia32/ia32_entry.S
--- linus-bk/arch/ia64/ia32/ia32_entry.S	2005-01-16 07:07:51.000000000 +1100
+++ linus-bk-waitid.1/arch/ia64/ia32/ia32_entry.S	2005-02-15 12:12:21.000000000 +1100
@@ -494,7 +494,7 @@ ia32_syscall_table:
   	data8 compat_sys_mq_notify
   	data8 compat_sys_mq_getsetattr
 	data8 sys_ni_syscall		/* reserved for kexec */
-	data8 sys32_waitid
+	data8 compat_sys_waitid
 
 	// guard against failures to increase IA32_NR_syscalls
 	.org ia32_syscall_table + 8*IA32_NR_syscalls
diff -ruNp linus-bk/arch/ia64/ia32/sys_ia32.c linus-bk-waitid.1/arch/ia64/ia32/sys_ia32.c
--- linus-bk/arch/ia64/ia32/sys_ia32.c	2005-02-11 13:05:29.000000000 +1100
+++ linus-bk-waitid.1/arch/ia64/ia32/sys_ia32.c	2005-02-15 12:16:35.000000000 +1100
@@ -2633,32 +2633,6 @@ long sys32_fadvise64_64(int fd, __u32 of
 			       advice); 
 } 
 
-asmlinkage long sys32_waitid(int which, compat_pid_t pid,
-			     compat_siginfo_t __user *uinfo, int options,
-			     struct compat_rusage __user *uru)
-{
-	siginfo_t info;
-	struct rusage ru;
-	long ret;
-	mm_segment_t old_fs = get_fs();
-
-	info.si_signo = 0;
-	set_fs (KERNEL_DS);
-	ret = sys_waitid(which, pid, (siginfo_t __user *) &info, options,
-			 uru ? (struct rusage __user *) &ru : NULL);
-	set_fs (old_fs);
-
-	if (ret < 0 || info.si_signo == 0)
-		return ret;
-
-	if (uru && (ret = put_compat_rusage(&ru, uru)))
-		return ret;
-
-	BUG_ON(info.si_code & __SI_MASK);
-	info.si_code |= __SI_CHLD;
-	return copy_siginfo_to_user32(uinfo, &info);
-}
-
 #ifdef	NOTYET  /* UNTESTED FOR IA64 FROM HERE DOWN */
 
 asmlinkage long sys32_setreuid(compat_uid_t ruid, compat_uid_t euid)
diff -ruNp linus-bk/arch/ppc/kernel/misc.S linus-bk-waitid.1/arch/ppc/kernel/misc.S
--- linus-bk/arch/ppc/kernel/misc.S	2005-01-04 17:05:28.000000000 +1100
+++ linus-bk-waitid.1/arch/ppc/kernel/misc.S	2005-02-15 13:12:01.000000000 +1100
@@ -1450,3 +1450,4 @@ _GLOBAL(sys_call_table)
 	.long sys_add_key
 	.long sys_request_key		/* 270 */
 	.long sys_keyctl
+	.long sys_waitid
diff -ruNp linus-bk/arch/ppc64/kernel/misc.S linus-bk-waitid.1/arch/ppc64/kernel/misc.S
--- linus-bk/arch/ppc64/kernel/misc.S	2005-01-16 07:07:51.000000000 +1100
+++ linus-bk-waitid.1/arch/ppc64/kernel/misc.S	2005-02-15 13:13:51.000000000 +1100
@@ -939,6 +939,7 @@ _GLOBAL(sys_call_table32)
 	.llong .sys32_add_key
 	.llong .sys32_request_key
 	.llong .compat_sys_keyctl
+	.llong .compat_sys_waitid
 
 	.balign 8
 _GLOBAL(sys_call_table)
@@ -1214,3 +1215,4 @@ _GLOBAL(sys_call_table)
 	.llong .sys_add_key
 	.llong .sys_request_key		/* 270 */
 	.llong .sys_keyctl
+	.llong .sys_waitid
diff -ruNp linus-bk/arch/sparc64/kernel/sys_sparc32.c linus-bk-waitid.1/arch/sparc64/kernel/sys_sparc32.c
--- linus-bk/arch/sparc64/kernel/sys_sparc32.c	2005-02-11 13:05:29.000000000 +1100
+++ linus-bk-waitid.1/arch/sparc64/kernel/sys_sparc32.c	2005-02-15 12:01:55.000000000 +1100
@@ -1653,34 +1653,3 @@ sys32_timer_create(u32 clock, struct sig
 
 	return err;
 }
-
-asmlinkage long compat_sys_waitid(u32 which, u32 pid,
-				  struct compat_siginfo __user *uinfo,
-				  u32 options, struct compat_rusage __user *uru)
-{
-	siginfo_t info;
-	struct rusage ru;
-	long ret;
-	mm_segment_t old_fs = get_fs();
-
-	memset(&info, 0, sizeof(info));
-
-	set_fs (KERNEL_DS);
-	ret = sys_waitid(which, pid, (siginfo_t __user *) &info,
-			 options,
-			 uru ? (struct rusage __user *) &ru : NULL);
-	set_fs (old_fs);
-
-	if (ret < 0 || info.si_signo == 0)
-		return ret;
-
-	if (uru) {
-		ret = put_compat_rusage(&ru, uru);
-		if (ret)
-			return ret;
-	}
-
-	BUG_ON(info.si_code & __SI_MASK);
-	info.si_code |= __SI_CHLD;
-	return copy_siginfo_to_user32(uinfo, &info);
-}
diff -ruNp linus-bk/arch/x86_64/ia32/ia32entry.S linus-bk-waitid.1/arch/x86_64/ia32/ia32entry.S
--- linus-bk/arch/x86_64/ia32/ia32entry.S	2005-01-16 11:05:29.000000000 +1100
+++ linus-bk-waitid.1/arch/x86_64/ia32/ia32entry.S	2005-02-15 12:11:52.000000000 +1100
@@ -590,7 +590,7 @@ ia32_sys_call_table:
 	.quad compat_sys_mq_notify
 	.quad compat_sys_mq_getsetattr
 	.quad quiet_ni_syscall		/* reserved for kexec */
-	.quad sys32_waitid
+	.quad compat_sys_waitid
 	.quad quiet_ni_syscall		/* sys_altroot */
 	.quad sys_add_key
 	.quad sys_request_key
diff -ruNp linus-bk/arch/x86_64/ia32/sys_ia32.c linus-bk-waitid.1/arch/x86_64/ia32/sys_ia32.c
--- linus-bk/arch/x86_64/ia32/sys_ia32.c	2005-02-04 04:10:36.000000000 +1100
+++ linus-bk-waitid.1/arch/x86_64/ia32/sys_ia32.c	2005-02-15 12:17:04.000000000 +1100
@@ -955,32 +955,6 @@ asmlinkage long sys32_clone(unsigned int
         return do_fork(clone_flags, newsp, regs, 0, parent_tid, child_tid);
 }
 
-asmlinkage long sys32_waitid(int which, compat_pid_t pid,
-			     compat_siginfo_t __user *uinfo, int options,
-			     struct compat_rusage __user *uru)
-{
-	siginfo_t info;
-	struct rusage ru;
-	long ret;
-	mm_segment_t old_fs = get_fs();
-
-	info.si_signo = 0;
-	set_fs (KERNEL_DS);
-	ret = sys_waitid(which, pid, (siginfo_t __user *) &info, options,
-			 uru ? &ru : NULL);
-	set_fs (old_fs);
-
-	if (ret < 0 || info.si_signo == 0)
-		return ret;
-
-	if (uru && (ret = put_compat_rusage(&ru, uru)))
-		return ret;
-
-	BUG_ON(info.si_code & __SI_MASK);
-	info.si_code |= __SI_CHLD;
-	return copy_siginfo_to_user32(uinfo, &info);
-}
-
 /*
  * Some system calls that need sign extended arguments. This could be done by a generic wrapper.
  */ 
diff -ruNp linus-bk/include/asm-ppc/unistd.h linus-bk-waitid.1/include/asm-ppc/unistd.h
--- linus-bk/include/asm-ppc/unistd.h	2005-01-04 17:05:28.000000000 +1100
+++ linus-bk-waitid.1/include/asm-ppc/unistd.h	2005-02-15 13:08:22.000000000 +1100
@@ -276,8 +276,9 @@
 #define __NR_add_key		269
 #define __NR_request_key	270
 #define __NR_keyctl		271
+#define __NR_waitid		272
 
-#define __NR_syscalls		272
+#define __NR_syscalls		273
 
 #define __NR(n)	#n
 
diff -ruNp linus-bk/include/asm-ppc64/unistd.h linus-bk-waitid.1/include/asm-ppc64/unistd.h
--- linus-bk/include/asm-ppc64/unistd.h	2005-01-05 17:06:08.000000000 +1100
+++ linus-bk-waitid.1/include/asm-ppc64/unistd.h	2005-02-15 13:07:33.000000000 +1100
@@ -282,8 +282,9 @@
 #define __NR_add_key		269
 #define __NR_request_key	270
 #define __NR_keyctl		271
+#define __NR_waitid		272
 
-#define __NR_syscalls		272
+#define __NR_syscalls		273
 #ifdef __KERNEL__
 #define NR_syscalls	__NR_syscalls
 #endif
diff -ruNp linus-bk/include/linux/compat.h linus-bk-waitid.1/include/linux/compat.h
--- linus-bk/include/linux/compat.h	2005-01-05 17:06:08.000000000 +1100
+++ linus-bk-waitid.1/include/linux/compat.h	2005-02-15 13:22:13.000000000 +1100
@@ -81,6 +81,12 @@ struct compat_rusage {
 
 extern int put_compat_rusage(const struct rusage *, struct compat_rusage __user *);
 
+struct compat_siginfo;
+
+extern asmlinkage long compat_sys_waitid(u32, u32,
+		struct compat_siginfo __user *, u32,
+		struct compat_rusage __user *);
+
 struct compat_dirent {
 	u32		d_ino;
 	compat_off_t	d_off;
@@ -143,7 +149,6 @@ long compat_get_bitmap(unsigned long *ma
 		       unsigned long bitmap_size);
 long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask,
 		       unsigned long bitmap_size);
-struct compat_siginfo;
 int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from);
 int copy_siginfo_to_user32(struct compat_siginfo __user *to, siginfo_t *from);
 #endif /* CONFIG_COMPAT */
diff -ruNp linus-bk/kernel/compat.c linus-bk-waitid.1/kernel/compat.c
--- linus-bk/kernel/compat.c	2005-01-16 07:07:51.000000000 +1100
+++ linus-bk-waitid.1/kernel/compat.c	2005-02-15 12:09:46.000000000 +1100
@@ -23,6 +23,7 @@
 #include <linux/security.h>
 
 #include <asm/uaccess.h>
+#include <asm/bug.h>
 
 int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts)
 {
@@ -413,6 +414,36 @@ compat_sys_wait4(compat_pid_t pid, compa
 	}
 }
 
+asmlinkage long compat_sys_waitid(u32 which, u32 pid,
+		struct compat_siginfo __user *uinfo, u32 options,
+		struct compat_rusage __user *uru)
+{
+	siginfo_t info;
+	struct rusage ru;
+	long ret;
+	mm_segment_t old_fs = get_fs();
+
+	memset(&info, 0, sizeof(info));
+
+	set_fs(KERNEL_DS);
+	ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
+			 uru ? (struct rusage __user *)&ru : NULL);
+	set_fs(old_fs);
+
+	if ((ret < 0) || (info.si_signo == 0))
+		return ret;
+
+	if (uru) {
+		ret = put_compat_rusage(&ru, uru);
+		if (ret)
+			return ret;
+	}
+
+	BUG_ON(info.si_code & __SI_MASK);
+	info.si_code |= __SI_CHLD;
+	return copy_siginfo_to_user32(uinfo, &info);
+}
+
 static int compat_get_user_cpu_mask(compat_ulong_t __user *user_mask_ptr,
 				    unsigned len, cpumask_t *new_mask)
 {

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Consolidate compat_sys_waitid
  2005-02-15  3:01 [PATCH] Consolidate compat_sys_waitid Stephen Rothwell
@ 2005-02-15  9:51 ` Andi Kleen
  2005-02-15 11:06   ` Stephen Rothwell
  2005-02-15 18:37 ` David S. Miller
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 13+ messages in thread
From: Andi Kleen @ 2005-02-15  9:51 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: LKML, paulus, anton, davem, ralf, tony.luck, ak, willy, schwidefsky

On Tue, Feb 15, 2005 at 02:01:49PM +1100, Stephen Rothwell wrote:
> +asmlinkage long compat_sys_waitid(u32 which, u32 pid,
> +		struct compat_siginfo __user *uinfo, u32 options,
> +		struct compat_rusage __user *uru)
> +{
> +	siginfo_t info;
> +	struct rusage ru;
> +	long ret;
> +	mm_segment_t old_fs = get_fs();
> +
> +	memset(&info, 0, sizeof(info));
> +
> +	set_fs(KERNEL_DS);
> +	ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
> +			 uru ? (struct rusage __user *)&ru : NULL);
> +	set_fs(old_fs);

I don't think this will work for sparc64/s390/UML etc.
They cannot access kernel data inside KERNEL_DS. You would need to use
compat_alloc_user_space() for ru

-Andi

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Consolidate compat_sys_waitid
  2005-02-15  9:51 ` Andi Kleen
@ 2005-02-15 11:06   ` Stephen Rothwell
  2005-02-15 11:10     ` Andi Kleen
  0 siblings, 1 reply; 13+ messages in thread
From: Stephen Rothwell @ 2005-02-15 11:06 UTC (permalink / raw)
  To: Andi Kleen
  Cc: linux-kernel, paulus, anton, davem, ralf, tony.luck, ak, willy,
	schwidefsky

Hi Andi,

On Tue, 15 Feb 2005 10:51:53 +0100 Andi Kleen <ak@suse.de> wrote:
>
> I don't think this will work for sparc64/s390/UML etc.
> They cannot access kernel data inside KERNEL_DS. You would need to use
> compat_alloc_user_space() for ru

.. and, presumably, for info as well.  Interestingly, this code
came directly from sparc64 ...

However, if you are right, there are quite a few other compat sys calls
that should not be working either.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Consolidate compat_sys_waitid
  2005-02-15 11:06   ` Stephen Rothwell
@ 2005-02-15 11:10     ` Andi Kleen
  0 siblings, 0 replies; 13+ messages in thread
From: Andi Kleen @ 2005-02-15 11:10 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: Andi Kleen, linux-kernel, paulus, anton, davem, ralf, tony.luck,
	willy, schwidefsky

On Tue, Feb 15, 2005 at 10:06:14PM +1100, Stephen Rothwell wrote:
> Hi Andi,
> 
> On Tue, 15 Feb 2005 10:51:53 +0100 Andi Kleen <ak@suse.de> wrote:
> >
> > I don't think this will work for sparc64/s390/UML etc.
> > They cannot access kernel data inside KERNEL_DS. You would need to use
> > compat_alloc_user_space() for ru
> 
> .. and, presumably, for info as well.  Interestingly, this code
> came directly from sparc64 ...

Sorry, I misread the code. In this case it's actually ok.

The only thing that doesn't work is mixing the pointers (e.g. accessing
user mode pointers inside KERNEL_DS) 

So the patch is fine.

-Andi

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Consolidate compat_sys_waitid
  2005-02-15  3:01 [PATCH] Consolidate compat_sys_waitid Stephen Rothwell
  2005-02-15  9:51 ` Andi Kleen
@ 2005-02-15 18:37 ` David S. Miller
  2005-02-15 18:43 ` Matthew Wilcox
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 13+ messages in thread
From: David S. Miller @ 2005-02-15 18:37 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: linux-kernel, paulus, anton, ralf, tony.luck, ak, willy, schwidefsky

On Tue, 15 Feb 2005 14:01:49 +1100
Stephen Rothwell <sfr@canb.auug.org.au> wrote:

> This patch does:
> 	- consolidate the three implementations of compat_sys_waitid
> 	  (some were called sys32_waitid).
> 	- adds sys_waitid syscall to ppc
> 	- adds sys_waitid and compat_sys_waitid syscalls to ppc64
> 
> Parisc seemed to assume th existance of compat_sys_waitid.  The MIPS
> syscall tables have me confused and may need updating.  I have arbitrarily
> chosen the next available syscall number on ppc and ppc64, I hope this is
> correct.
> 
> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
> 
> Comments?

Looks good to me.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Consolidate compat_sys_waitid
  2005-02-15  3:01 [PATCH] Consolidate compat_sys_waitid Stephen Rothwell
  2005-02-15  9:51 ` Andi Kleen
  2005-02-15 18:37 ` David S. Miller
@ 2005-02-15 18:43 ` Matthew Wilcox
  2005-02-15 19:23   ` Andi Kleen
  2005-02-18  5:22   ` Stephen Rothwell
  2005-02-15 19:33 ` Daniel Jacobowitz
  2005-02-16  0:06 ` Paul Mackerras
  4 siblings, 2 replies; 13+ messages in thread
From: Matthew Wilcox @ 2005-02-15 18:43 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: LKML, paulus, anton, davem, ralf, tony.luck, ak, willy, schwidefsky

On Tue, Feb 15, 2005 at 02:01:49PM +1100, Stephen Rothwell wrote:
> Parisc seemed to assume th existance of compat_sys_waitid.

PA-RISC already has a compat_sys_waitid ;-P

The reason it isn't in Linus' tree yet is that it depends on the
is_compat_task() predicate which Andi vetoed out of Andrew's tree.
As a result, I haven't been able to merge any of the compat stuff
sitting in the PA tree.  A few more voices in favour of reintroducing
is_compat_task() would help.

> @@ -413,6 +414,36 @@ compat_sys_wait4(compat_pid_t pid, compa
>  	}
>  }
>  
> +asmlinkage long compat_sys_waitid(u32 which, u32 pid,
> +		struct compat_siginfo __user *uinfo, u32 options,
> +		struct compat_rusage __user *uru)

Some subtle differences which I feel incompetent to diagnose ... ours
looks like:

asmlinkage int compat_sys_waitid(int which, pid_t pid,
                                 compat_siginfo_t __user *infop, int options,
                                 struct compat_rusage __user *ru)


> +	BUG_ON(info.si_code & __SI_MASK);
> +	info.si_code |= __SI_CHLD;
> +	return copy_siginfo_to_user32(uinfo, &info);
> +}

Other than variable names, we're identical to this point:

        /* Tell copy_siginfo_to_user that it was __SI_CHLD */
        ksiginfo.si_code |= __SI_CHLD;
        
        if (compat_copy_siginfo_to_user(infop, &ksiginfo) != 0)
                return -EFAULT;

        return 0;
}

-- 
"Next the statesmen will invent cheap lies, putting the blame upon 
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince 
himself that the war is just, and will thank God for the better sleep 
he enjoys after this process of grotesque self-deception." -- Mark Twain

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Consolidate compat_sys_waitid
  2005-02-15 18:43 ` Matthew Wilcox
@ 2005-02-15 19:23   ` Andi Kleen
  2005-02-15 19:27     ` Al Viro
  2005-02-18  5:22   ` Stephen Rothwell
  1 sibling, 1 reply; 13+ messages in thread
From: Andi Kleen @ 2005-02-15 19:23 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Stephen Rothwell, LKML, paulus, anton, davem, ralf, tony.luck,
	ak, willy, schwidefsky

> The reason it isn't in Linus' tree yet is that it depends on the
> is_compat_task() predicate which Andi vetoed out of Andrew's tree.
> As a result, I haven't been able to merge any of the compat stuff
> sitting in the PA tree.  A few more voices in favour of reintroducing
> is_compat_task() would help.

Just change PA-RISC to not need is_compat_task?   It's not that
difficult really, you just have to split the parts that need
to know about this into separate functions and files.

-Andi

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Consolidate compat_sys_waitid
  2005-02-15 19:23   ` Andi Kleen
@ 2005-02-15 19:27     ` Al Viro
  0 siblings, 0 replies; 13+ messages in thread
From: Al Viro @ 2005-02-15 19:27 UTC (permalink / raw)
  To: Andi Kleen
  Cc: Matthew Wilcox, Stephen Rothwell, LKML, paulus, anton, davem,
	ralf, tony.luck, willy, schwidefsky

On Tue, Feb 15, 2005 at 08:23:41PM +0100, Andi Kleen wrote:
> > The reason it isn't in Linus' tree yet is that it depends on the
> > is_compat_task() predicate which Andi vetoed out of Andrew's tree.
> > As a result, I haven't been able to merge any of the compat stuff
> > sitting in the PA tree.  A few more voices in favour of reintroducing
> > is_compat_task() would help.
> 
> Just change PA-RISC to not need is_compat_task?   It's not that
> difficult really, you just have to split the parts that need
> to know about this into separate functions and files.

Seconded.  Come on, folks, you *know* that is_compat_task() is an invitation
for massive fuckups by driver-writers...

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Consolidate compat_sys_waitid
  2005-02-15  3:01 [PATCH] Consolidate compat_sys_waitid Stephen Rothwell
                   ` (2 preceding siblings ...)
  2005-02-15 18:43 ` Matthew Wilcox
@ 2005-02-15 19:33 ` Daniel Jacobowitz
  2005-02-16  0:06 ` Paul Mackerras
  4 siblings, 0 replies; 13+ messages in thread
From: Daniel Jacobowitz @ 2005-02-15 19:33 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: LKML, paulus, anton, davem, ralf, tony.luck, ak, willy, schwidefsky

On Tue, Feb 15, 2005 at 02:01:49PM +1100, Stephen Rothwell wrote:
> Hi all,
> 
> This patch does:
> 	- consolidate the three implementations of compat_sys_waitid
> 	  (some were called sys32_waitid).
> 	- adds sys_waitid syscall to ppc
> 	- adds sys_waitid and compat_sys_waitid syscalls to ppc64
> 
> Parisc seemed to assume th existance of compat_sys_waitid.  The MIPS
> syscall tables have me confused and may need updating.  I have arbitrarily
> chosen the next available syscall number on ppc and ppc64, I hope this is
> correct.

I posted a (not-consolidated) sys32_waitid to the MIPS list on Sunday.
The syscall tables should confuse you :-)  N32 needs to use compat
versions of most structures, but not siginfo_t.  O32 needs to use
compat versions of everything.  Your new version can replace the
sys32_waitid from my patch, but not sysn32_waitid.

Ralf, I'll let you sort it out :-)

-- 
Daniel Jacobowitz
CodeSourcery, LLC

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Consolidate compat_sys_waitid
  2005-02-15  3:01 [PATCH] Consolidate compat_sys_waitid Stephen Rothwell
                   ` (3 preceding siblings ...)
  2005-02-15 19:33 ` Daniel Jacobowitz
@ 2005-02-16  0:06 ` Paul Mackerras
  4 siblings, 0 replies; 13+ messages in thread
From: Paul Mackerras @ 2005-02-16  0:06 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: LKML, anton, davem, ralf, tony.luck, ak, willy, schwidefsky

Stephen Rothwell writes:

> This patch does:
> 	- consolidate the three implementations of compat_sys_waitid
> 	  (some were called sys32_waitid).
> 	- adds sys_waitid syscall to ppc
> 	- adds sys_waitid and compat_sys_waitid syscalls to ppc64

Looks good to me.  Are you going to submit it to Andrew?

Paul.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] Consolidate compat_sys_waitid
  2005-02-15 18:43 ` Matthew Wilcox
  2005-02-15 19:23   ` Andi Kleen
@ 2005-02-18  5:22   ` Stephen Rothwell
  1 sibling, 0 replies; 13+ messages in thread
From: Stephen Rothwell @ 2005-02-18  5:22 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: linux-kernel, paulus, anton, davem, ralf, tony.luck, ak, willy,
	schwidefsky

On Tue, 15 Feb 2005 18:43:07 +0000 Matthew Wilcox <matthew@wil.cx> wrote:
>
> On Tue, Feb 15, 2005 at 02:01:49PM +1100, Stephen Rothwell wrote:
> 
> > +asmlinkage long compat_sys_waitid(u32 which, u32 pid,
> > +		struct compat_siginfo __user *uinfo, u32 options,
> > +		struct compat_rusage __user *uru)
> 
> Some subtle differences which I feel incompetent to diagnose ... ours
> looks like:
> 
> asmlinkage int compat_sys_waitid(int which, pid_t pid,
>                                  compat_siginfo_t __user *infop, int options,
>                                  struct compat_rusage __user *ru)

They are u32 in my version because we decided that the kernel zero extends
the compat syscall parameters.

> Other than variable names, we're identical to this point:
> 
>         /* Tell copy_siginfo_to_user that it was __SI_CHLD */
>         ksiginfo.si_code |= __SI_CHLD;
>         
>         if (compat_copy_siginfo_to_user(infop, &ksiginfo) != 0)

Every other relevant architecture has copy_siginfo_to_user32 which returns
0/-EFAULT.  And it is declared in linux/compat.h.  I like your name
better, but that is a different patch.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH] Consolidate compat_sys_waitid
@ 2005-03-07  1:08 Stephen Rothwell
  0 siblings, 0 replies; 13+ messages in thread
From: Stephen Rothwell @ 2005-03-07  1:08 UTC (permalink / raw)
  To: Andrew Morton, Linus; +Cc: LKML

Hi Andrew, Linus,

This patch does:
	- consolidate the three implementations of compat_sys_waitid
	  (some were called sys32_waitid).
	- adds sys_waitid syscall to ppc
	- adds sys_waitid and compat_sys_waitid syscalls to ppc64

I have left PARISC and MIPS to their own devices (by request).

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>

Diffstat looks like this:
 arch/ia64/ia32/ia32_entry.S       |    2 +-
 arch/ia64/ia32/sys_ia32.c         |   26 --------------------------
 arch/ppc/kernel/misc.S            |    1 +
 arch/ppc64/kernel/misc.S          |    2 ++
 arch/sparc64/kernel/sys_sparc32.c |   31 -------------------------------
 arch/x86_64/ia32/ia32entry.S      |    2 +-
 arch/x86_64/ia32/sys_ia32.c       |   26 --------------------------
 include/asm-ppc/unistd.h          |    3 ++-
 include/asm-ppc64/unistd.h        |    3 ++-
 include/linux/compat.h            |    7 ++++++-
 kernel/compat.c                   |   31 +++++++++++++++++++++++++++++++
 11 files changed, 46 insertions(+), 88 deletions(-)

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

diff -ruNp linus/arch/ia64/ia32/ia32_entry.S linus-waitid.1/arch/ia64/ia32/ia32_entry.S
--- linus/arch/ia64/ia32/ia32_entry.S	2005-01-16 07:07:51.000000000 +1100
+++ linus-waitid.1/arch/ia64/ia32/ia32_entry.S	2005-03-07 10:58:57.000000000 +1100
@@ -494,7 +494,7 @@ ia32_syscall_table:
   	data8 compat_sys_mq_notify
   	data8 compat_sys_mq_getsetattr
 	data8 sys_ni_syscall		/* reserved for kexec */
-	data8 sys32_waitid
+	data8 compat_sys_waitid
 
 	// guard against failures to increase IA32_NR_syscalls
 	.org ia32_syscall_table + 8*IA32_NR_syscalls
diff -ruNp linus/arch/ia64/ia32/sys_ia32.c linus-waitid.1/arch/ia64/ia32/sys_ia32.c
--- linus/arch/ia64/ia32/sys_ia32.c	2005-02-11 13:05:29.000000000 +1100
+++ linus-waitid.1/arch/ia64/ia32/sys_ia32.c	2005-03-07 10:58:57.000000000 +1100
@@ -2633,32 +2633,6 @@ long sys32_fadvise64_64(int fd, __u32 of
 			       advice); 
 } 
 
-asmlinkage long sys32_waitid(int which, compat_pid_t pid,
-			     compat_siginfo_t __user *uinfo, int options,
-			     struct compat_rusage __user *uru)
-{
-	siginfo_t info;
-	struct rusage ru;
-	long ret;
-	mm_segment_t old_fs = get_fs();
-
-	info.si_signo = 0;
-	set_fs (KERNEL_DS);
-	ret = sys_waitid(which, pid, (siginfo_t __user *) &info, options,
-			 uru ? (struct rusage __user *) &ru : NULL);
-	set_fs (old_fs);
-
-	if (ret < 0 || info.si_signo == 0)
-		return ret;
-
-	if (uru && (ret = put_compat_rusage(&ru, uru)))
-		return ret;
-
-	BUG_ON(info.si_code & __SI_MASK);
-	info.si_code |= __SI_CHLD;
-	return copy_siginfo_to_user32(uinfo, &info);
-}
-
 #ifdef	NOTYET  /* UNTESTED FOR IA64 FROM HERE DOWN */
 
 asmlinkage long sys32_setreuid(compat_uid_t ruid, compat_uid_t euid)
diff -ruNp linus/arch/ppc/kernel/misc.S linus-waitid.1/arch/ppc/kernel/misc.S
--- linus/arch/ppc/kernel/misc.S	2005-01-04 17:05:28.000000000 +1100
+++ linus-waitid.1/arch/ppc/kernel/misc.S	2005-03-07 10:58:58.000000000 +1100
@@ -1450,3 +1450,4 @@ _GLOBAL(sys_call_table)
 	.long sys_add_key
 	.long sys_request_key		/* 270 */
 	.long sys_keyctl
+	.long sys_waitid
diff -ruNp linus/arch/ppc64/kernel/misc.S linus-waitid.1/arch/ppc64/kernel/misc.S
--- linus/arch/ppc64/kernel/misc.S	2005-01-16 07:07:51.000000000 +1100
+++ linus-waitid.1/arch/ppc64/kernel/misc.S	2005-03-07 10:58:58.000000000 +1100
@@ -939,6 +939,7 @@ _GLOBAL(sys_call_table32)
 	.llong .sys32_add_key
 	.llong .sys32_request_key
 	.llong .compat_sys_keyctl
+	.llong .compat_sys_waitid
 
 	.balign 8
 _GLOBAL(sys_call_table)
@@ -1214,3 +1215,4 @@ _GLOBAL(sys_call_table)
 	.llong .sys_add_key
 	.llong .sys_request_key		/* 270 */
 	.llong .sys_keyctl
+	.llong .sys_waitid
diff -ruNp linus/arch/sparc64/kernel/sys_sparc32.c linus-waitid.1/arch/sparc64/kernel/sys_sparc32.c
--- linus/arch/sparc64/kernel/sys_sparc32.c	2005-02-19 07:06:16.000000000 +1100
+++ linus-waitid.1/arch/sparc64/kernel/sys_sparc32.c	2005-03-07 10:58:58.000000000 +1100
@@ -1121,34 +1121,3 @@ sys32_timer_create(u32 clock, struct sig
 
 	return err;
 }
-
-asmlinkage long compat_sys_waitid(u32 which, u32 pid,
-				  struct compat_siginfo __user *uinfo,
-				  u32 options, struct compat_rusage __user *uru)
-{
-	siginfo_t info;
-	struct rusage ru;
-	long ret;
-	mm_segment_t old_fs = get_fs();
-
-	memset(&info, 0, sizeof(info));
-
-	set_fs (KERNEL_DS);
-	ret = sys_waitid(which, pid, (siginfo_t __user *) &info,
-			 options,
-			 uru ? (struct rusage __user *) &ru : NULL);
-	set_fs (old_fs);
-
-	if (ret < 0 || info.si_signo == 0)
-		return ret;
-
-	if (uru) {
-		ret = put_compat_rusage(&ru, uru);
-		if (ret)
-			return ret;
-	}
-
-	BUG_ON(info.si_code & __SI_MASK);
-	info.si_code |= __SI_CHLD;
-	return copy_siginfo_to_user32(uinfo, &info);
-}
diff -ruNp linus/arch/x86_64/ia32/ia32entry.S linus-waitid.1/arch/x86_64/ia32/ia32entry.S
--- linus/arch/x86_64/ia32/ia32entry.S	2005-01-16 11:05:29.000000000 +1100
+++ linus-waitid.1/arch/x86_64/ia32/ia32entry.S	2005-03-07 10:58:58.000000000 +1100
@@ -590,7 +590,7 @@ ia32_sys_call_table:
 	.quad compat_sys_mq_notify
 	.quad compat_sys_mq_getsetattr
 	.quad quiet_ni_syscall		/* reserved for kexec */
-	.quad sys32_waitid
+	.quad compat_sys_waitid
 	.quad quiet_ni_syscall		/* sys_altroot */
 	.quad sys_add_key
 	.quad sys_request_key
diff -ruNp linus/arch/x86_64/ia32/sys_ia32.c linus-waitid.1/arch/x86_64/ia32/sys_ia32.c
--- linus/arch/x86_64/ia32/sys_ia32.c	2005-02-04 04:10:36.000000000 +1100
+++ linus-waitid.1/arch/x86_64/ia32/sys_ia32.c	2005-03-07 10:58:58.000000000 +1100
@@ -955,32 +955,6 @@ asmlinkage long sys32_clone(unsigned int
         return do_fork(clone_flags, newsp, regs, 0, parent_tid, child_tid);
 }
 
-asmlinkage long sys32_waitid(int which, compat_pid_t pid,
-			     compat_siginfo_t __user *uinfo, int options,
-			     struct compat_rusage __user *uru)
-{
-	siginfo_t info;
-	struct rusage ru;
-	long ret;
-	mm_segment_t old_fs = get_fs();
-
-	info.si_signo = 0;
-	set_fs (KERNEL_DS);
-	ret = sys_waitid(which, pid, (siginfo_t __user *) &info, options,
-			 uru ? &ru : NULL);
-	set_fs (old_fs);
-
-	if (ret < 0 || info.si_signo == 0)
-		return ret;
-
-	if (uru && (ret = put_compat_rusage(&ru, uru)))
-		return ret;
-
-	BUG_ON(info.si_code & __SI_MASK);
-	info.si_code |= __SI_CHLD;
-	return copy_siginfo_to_user32(uinfo, &info);
-}
-
 /*
  * Some system calls that need sign extended arguments. This could be done by a generic wrapper.
  */ 
diff -ruNp linus/include/asm-ppc/unistd.h linus-waitid.1/include/asm-ppc/unistd.h
--- linus/include/asm-ppc/unistd.h	2005-01-04 17:05:28.000000000 +1100
+++ linus-waitid.1/include/asm-ppc/unistd.h	2005-03-07 10:58:58.000000000 +1100
@@ -276,8 +276,9 @@
 #define __NR_add_key		269
 #define __NR_request_key	270
 #define __NR_keyctl		271
+#define __NR_waitid		272
 
-#define __NR_syscalls		272
+#define __NR_syscalls		273
 
 #define __NR(n)	#n
 
diff -ruNp linus/include/asm-ppc64/unistd.h linus-waitid.1/include/asm-ppc64/unistd.h
--- linus/include/asm-ppc64/unistd.h	2005-01-05 17:06:08.000000000 +1100
+++ linus-waitid.1/include/asm-ppc64/unistd.h	2005-03-07 10:58:58.000000000 +1100
@@ -282,8 +282,9 @@
 #define __NR_add_key		269
 #define __NR_request_key	270
 #define __NR_keyctl		271
+#define __NR_waitid		272
 
-#define __NR_syscalls		272
+#define __NR_syscalls		273
 #ifdef __KERNEL__
 #define NR_syscalls	__NR_syscalls
 #endif
diff -ruNp linus/include/linux/compat.h linus-waitid.1/include/linux/compat.h
--- linus/include/linux/compat.h	2005-02-23 03:08:59.000000000 +1100
+++ linus-waitid.1/include/linux/compat.h	2005-03-07 10:58:58.000000000 +1100
@@ -83,6 +83,12 @@ struct compat_rusage {
 
 extern int put_compat_rusage(const struct rusage *, struct compat_rusage __user *);
 
+struct compat_siginfo;
+
+extern asmlinkage long compat_sys_waitid(int, compat_pid_t,
+		struct compat_siginfo __user *, int,
+		struct compat_rusage __user *);
+
 struct compat_dirent {
 	u32		d_ino;
 	compat_off_t	d_off;
@@ -145,7 +151,6 @@ long compat_get_bitmap(unsigned long *ma
 		       unsigned long bitmap_size);
 long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask,
 		       unsigned long bitmap_size);
-struct compat_siginfo;
 int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from);
 int copy_siginfo_to_user32(struct compat_siginfo __user *to, siginfo_t *from);
 #endif /* CONFIG_COMPAT */
diff -ruNp linus/kernel/compat.c linus-waitid.1/kernel/compat.c
--- linus/kernel/compat.c	2005-01-16 07:07:51.000000000 +1100
+++ linus-waitid.1/kernel/compat.c	2005-03-07 10:58:58.000000000 +1100
@@ -23,6 +23,7 @@
 #include <linux/security.h>
 
 #include <asm/uaccess.h>
+#include <asm/bug.h>
 
 int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts)
 {
@@ -413,6 +414,36 @@ compat_sys_wait4(compat_pid_t pid, compa
 	}
 }
 
+asmlinkage long compat_sys_waitid(int which, compat_pid_t pid,
+		struct compat_siginfo __user *uinfo, int options,
+		struct compat_rusage __user *uru)
+{
+	siginfo_t info;
+	struct rusage ru;
+	long ret;
+	mm_segment_t old_fs = get_fs();
+
+	memset(&info, 0, sizeof(info));
+
+	set_fs(KERNEL_DS);
+	ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
+			 uru ? (struct rusage __user *)&ru : NULL);
+	set_fs(old_fs);
+
+	if ((ret < 0) || (info.si_signo == 0))
+		return ret;
+
+	if (uru) {
+		ret = put_compat_rusage(&ru, uru);
+		if (ret)
+			return ret;
+	}
+
+	BUG_ON(info.si_code & __SI_MASK);
+	info.si_code |= __SI_CHLD;
+	return copy_siginfo_to_user32(uinfo, &info);
+}
+
 static int compat_get_user_cpu_mask(compat_ulong_t __user *user_mask_ptr,
 				    unsigned len, cpumask_t *new_mask)
 {

^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [PATCH] Consolidate compat_sys_waitid
@ 2005-02-15 18:09 Luck, Tony
  0 siblings, 0 replies; 13+ messages in thread
From: Luck, Tony @ 2005-02-15 18:09 UTC (permalink / raw)
  To: Stephen Rothwell, LKML; +Cc: paulus, anton, davem, ralf, ak, willy, schwidefsky


>This patch does:
>	- consolidate the three implementations of compat_sys_waitid
>	  (some were called sys32_waitid).
>	- adds sys_waitid syscall to ppc
>	- adds sys_waitid and compat_sys_waitid syscalls to ppc64
>
>Parisc seemed to assume th existance of compat_sys_waitid.  The MIPS
>syscall tables have me confused and may need updating.  I have arbitrarily
>chosen the next available syscall number on ppc and ppc64, I hope this is
>correct.
>
>Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
>
>Comments?

Compiles cleanly, and my test case runs on ia64.

Acked-by: Tony Luck <tony.luck@intel.com>

-Tony

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2005-03-07  1:09 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-15  3:01 [PATCH] Consolidate compat_sys_waitid Stephen Rothwell
2005-02-15  9:51 ` Andi Kleen
2005-02-15 11:06   ` Stephen Rothwell
2005-02-15 11:10     ` Andi Kleen
2005-02-15 18:37 ` David S. Miller
2005-02-15 18:43 ` Matthew Wilcox
2005-02-15 19:23   ` Andi Kleen
2005-02-15 19:27     ` Al Viro
2005-02-18  5:22   ` Stephen Rothwell
2005-02-15 19:33 ` Daniel Jacobowitz
2005-02-16  0:06 ` Paul Mackerras
2005-02-15 18:09 Luck, Tony
2005-03-07  1:08 Stephen Rothwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).