Skip to contentSkip to conversation

ia32: use generic sys_pipe()

PATCH In review Amerigo Wang 5 participants 11 messages Jul 22, 2009 – Sep 18, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ia32: use generic sys_pipe()

As suggested by Al, it's better to use the generic sys_pipe() for ia32.

Cc Ingo Molnar <[email protected]>
Cc Al Viro <[email protected]>
CC Linus Torvalds <[email protected]>

---

arch/x86/ia32/ia32entry.S +1 -1
index e590261..ba331bf 100644
@@ -537,7 +537,7 @@ ia32_sys_call_table:
 	.quad sys_mkdir
 	.quad sys_rmdir		/* 40 */
 	.quad sys_dup
-	.quad sys32_pipe
+	.quad sys_pipe
 	.quad compat_sys_times
 	.quad quiet_ni_syscall			/* old prof syscall holder */
 	.quad sys_brk		/* 45 */
arch/x86/ia32/sys_ia32.c +0 -14
index 085a8c3..9f55271 100644
@@ -189,20 +189,6 @@ asmlinkage long sys32_mprotect(unsigned long start, size_t len,
 	return sys_mprotect(start, len, prot);
 }
 
-asmlinkage long sys32_pipe(int __user *fd)
-{
-	int retval;
-	int fds[2];
-
-	retval = do_pipe_flags(fds, 0);
-	if (retval)
-		goto out;
-	if (copy_to_user(fd, fds, sizeof(fds)))
-		retval = -EFAULT;
-out:
-	return retval;
-}
-
 asmlinkage long sys32_rt_sigaction(int sig, struct sigaction32 __user *act,
 				   struct sigaction32 __user *oact,
 				   unsigned int sigsetsize)
#1 lore raw

PATCH 2/2 xtensa: use generic sys_pipe()

As suggested by Al, we can use the generic sys_pipe() instead of xtensa_pipe() for xtensa.

Cc Al Viro <[email protected]>
CC Linus Torvalds <[email protected]>

---

arch/xtensa/include/asm/syscall.h +0 -1
index 05cebf8..76a1fb8 100644
@@ -12,7 +12,6 @@ struct pt_regs;
 struct sigaction;
 asmlinkage long xtensa_execve(char*, char**, char**, struct pt_regs*);
 asmlinkage long xtensa_clone(unsigned long, unsigned long, struct pt_regs*);
-asmlinkage long xtensa_pipe(int __user *);
 asmlinkage long xtensa_mmap2(unsigned long, unsigned long, unsigned long,
     			     unsigned long, unsigned long, unsigned long);
 asmlinkage long xtensa_ptrace(long, long, long, long);
arch/xtensa/include/asm/unistd.h +1 -1
index c092c8f..b6880c8 100644
@@ -94,7 +94,7 @@ __SYSCALL( 35, sys_readlink, 3)
 #define __NR_mknod 				 36
 __SYSCALL( 36, sys_mknod, 3)
 #define __NR_pipe 				 37
-__SYSCALL( 37, xtensa_pipe, 1)
+__SYSCALL(37, sys_pipe, 1)
 #define __NR_unlink 				 38
 __SYSCALL( 38, sys_unlink, 1)
 #define __NR_rmdir 				 39
arch/xtensa/kernel/syscall.c +0 -18
index ac15ecb..c7279be 100644
@@ -39,24 +39,6 @@ syscall_t sys_call_table[__NR_syscall_count] /* FIXME __cacheline_aligned */= {
 #include <asm/unistd.h>
 };
 
-/*
- * xtensa_pipe() is the normal C calling standard for creating a pipe. It's not
- * the way unix traditional does this, though.
- */
-
-asmlinkage long xtensa_pipe(int __user *userfds)
-{
-	int fd[2];
-	int error;
-
-	error = do_pipe_flags(fd, 0);
-	if (!error) {
-		if (copy_to_user(userfds, fd, 2 * sizeof(int)))
-			error = -EFAULT;
-	}
-	return error;
-}
-
 
 asmlinkage long xtensa_mmap2(unsigned long addr, unsigned long len,
    			     unsigned long prot, unsigned long flags,
Reviewed-by on v1 2/2
#2 lore raw

Re: [Patch 2/2] xtensa: use generic sys_pipe()

[CC Chris]

Quoted 7 lines · Amerigo Wang

As suggested by Al, we can use the generic sys_pipe() instead of xtensa_pipe() for xtensa.

Cc Al Viro <[email protected]>
CC Linus Torvalds <[email protected]>
Quoted 18 lines

---

arch/xtensa/include/asm/syscall.h +0 -1
index 05cebf8..76a1fb8 100644
@@ -12,7 +12,6 @@ struct pt_regs;
 struct sigaction;
 asmlinkage long xtensa_execve(char*, char**, char**, struct pt_regs*);
 asmlinkage long xtensa_clone(unsigned long, unsigned long, struct pt_regs*);
-asmlinkage long xtensa_pipe(int __user *);
 asmlinkage long xtensa_mmap2(unsigned long, unsigned long, unsigned long,
     			     unsigned long, unsigned long, unsigned long);
 asmlinkage long xtensa_ptrace(long, long, long, long);
arch/xtensa/include/asm/unistd.h +0 -0
index c092c8f..b6880c8 100644

arch/xtensa/include/asm/unistd.h __SYSCALL( 35, sys_readlink, 3) · line 97

Quoted 5 lines
arch/xtensa/include/asm/unistd.h +1 -1
@@ -94,7 +94,7 @@ __SYSCALL( 35, sys_readlink, 3)
 #define __NR_mknod 				 36
 __SYSCALL( 36, sys_mknod, 3)
 #define __NR_pipe 				 37
-__SYSCALL( 37, xtensa_pipe, 1)
+__SYSCALL(37, sys_pipe, 1)

It would have been nice to keep the spacing but that shouldn't be a show stopper..

Quoted 22 lines
arch/xtensa/include/asm/unistd.h +0 -0
 #define __NR_unlink 				 38
 __SYSCALL( 38, sys_unlink, 1)
 #define __NR_rmdir 				 39
arch/xtensa/kernel/syscall.c +0 -11
index ac15ecb..c7279be 100644
@@ -39,24 +39,6 @@ syscall_t sys_call_table[__NR_syscall_count] /* FIXME __cacheline_aligned */= {
 #include <asm/unistd.h>
 };
 
-/*
- * xtensa_pipe() is the normal C calling standard for creating a pipe. It's not
- * the way unix traditional does this, though.
- */
-
-asmlinkage long xtensa_pipe(int __user *userfds)
-{
-	int fd[2];
-	int error;
-
-	error = do_pipe_flags(fd, 0);

arch/xtensa/kernel/syscall.c syscall_t sys_call_table[__NR_syscall_count] /* FIXME __cacheline_aligned */= { · line 44

Quoted 10 lines
arch/xtensa/kernel/syscall.c +0 -7
-	if (!error) {
-		if (copy_to_user(userfds, fd, 2 * sizeof(int)))
-			error = -EFAULT;
-	}
-	return error;
-}
-
 
 asmlinkage long xtensa_mmap2(unsigned long addr, unsigned long len,
    			     unsigned long prot, unsigned long flags,

Hannes

#3 lore raw

Re: [Patch 2/2] xtensa: use generic sys_pipe()

Quoted 4 lines · Johannes Weiner

[CC Chris]

On Wed, Jul 22, 2009 at 05:08:42AM -0400, Amerigo Wang wrote:

Quoted 10 lines
Quoted 6 lines

As suggested by Al, we can use the generic sys_pipe() instead of xtensa_pipe() for xtensa.

Cc Al Viro <[email protected]> CC: Linus Torvalds <[email protected]>

Thanks for your review.

Quoted 19 lines
Quoted 19 lines

---

arch/xtensa/include/asm/syscall.h +0 -1
index 05cebf8..76a1fb8 100644
@@ -12,7 +12,6 @@ struct pt_regs;
 struct sigaction;
 asmlinkage long xtensa_execve(char*, char**, char**, struct pt_regs*);
 asmlinkage long xtensa_clone(unsigned long, unsigned long, struct pt_regs*);
-asmlinkage long xtensa_pipe(int __user *);
 asmlinkage long xtensa_mmap2(unsigned long, unsigned long, unsigned long,
     			     unsigned long, unsigned long, unsigned long);
 asmlinkage long xtensa_ptrace(long, long, long, long);
arch/xtensa/include/asm/unistd.h +0 -0
index c092c8f..b6880c8 100644
@@ -94,7 +94,7 @@ __SYSCALL( 35, sys_readlink, 3)
 #define __NR_mknod 				 36
Quoted 10 lines

arch/xtensa/include/asm/unistd.h __SYSCALL( 35, sys_readlink, 3)

Quoted 5 lines
arch/xtensa/include/asm/unistd.h +1 -1
 __SYSCALL( 36, sys_mknod, 3)
 #define __NR_pipe 				 37
-__SYSCALL( 37, xtensa_pipe, 1)
+__SYSCALL(37, sys_pipe, 1)
 

It would have been nice to keep the spacing but that shouldn't be a show stopper..

I did this, but checkpatch.pl complained about this... so I removed the space. Do I need to update and resend the patch? :)

Thanks.

#4 lore raw

Re: [Patch 2/2] xtensa: use generic sys_pipe()

Quoted 53 lines · Amerigo Wang
Quoted 8 lines · Johannes Weiner

[CC Chris]

Quoted 4 lines · Amerigo Wang

As suggested by Al, we can use the generic sys_pipe() instead of xtensa_pipe()
for xtensa.

Quoted 8 lines
Quoted 4 lines
Cc Al Viro <[email protected]>
CC Linus Torvalds <[email protected]>

Thanks for your review.

Quoted 23 lines
Quoted 23 lines

---

arch/xtensa/include/asm/syscall.h +0 -0
index 05cebf8..76a1fb8 100644
@@ -12,7 +12,6 @@ struct pt_regs;
 struct sigaction;
 asmlinkage long xtensa_execve(char*, char**, char**, struct pt_regs*);

asmlinkage long xtensa_clone(unsigned long, unsigned long, struct pt_regs*);
-asmlinkage long xtensa_pipe(int __user *);
asmlinkage long xtensa_mmap2(unsigned long, unsigned long, unsigned long,
unsigned long, unsigned long, unsigned long);
asmlinkage long xtensa_ptrace(long, long, long, long);

arch/xtensa/include/asm/unistd.h +0 -0
index c092c8f..b6880c8 100644
@@ -94,7 +94,7 @@ __SYSCALL( 35, sys_readlink, 3)
 #define __NR_mknod 				 36
Quoted 10 lines

arch/xtensa/include/asm/unistd.h __SYSCALL( 35, sys_readlink, 3)

Quoted 5 lines
arch/xtensa/include/asm/unistd.h +1 -1
 __SYSCALL( 36, sys_mknod, 3)
 #define __NR_pipe 				 37
-__SYSCALL( 37, xtensa_pipe, 1)
+__SYSCALL(37, sys_pipe, 1)
 

It would have been nice to keep the spacing but that shouldn't be a show stopper..

Quoted 2 lines

I did this, but checkpatch.pl complained about this... so I removed the space.

Yeah, but look at the file. checkpatch suggests alignment that is common for function calls, but this doesn't look like a sequence of function calls, rather like a table - and we align other tables (like fields in structure definitions) as well because you usually don't read them in a linear fashion but want to spot key values immediately.

Please ignore checkpatch in this case.

Reviewed-by Johannes Weiner
#5 lore raw

Re: [Patch 2/2] xtensa: use generic sys_pipe()

Quoted 2 lines · Johannes Weiner
Quoted 1 line · Amerigo Wang

Johannes Weiner wrote:

<snip>

Quoted 18 lines
Quoted 15 lines
Quoted 4 lines
Quoted 4 lines
arch/xtensa/include/asm/unistd.h +0 -0
@@ -94,7 +94,7 @@ __SYSCALL( 35, sys_readlink, 3)
 #define __NR_mknod 				 36
Quoted 10 lines

arch/xtensa/include/asm/unistd.h __SYSCALL( 35, sys_readlink, 3) · line 98

Quoted 5 lines
arch/xtensa/include/asm/unistd.h +1 -1
 __SYSCALL( 36, sys_mknod, 3)
 #define __NR_pipe 				 37
-__SYSCALL( 37, xtensa_pipe, 1)
+__SYSCALL(37, sys_pipe, 1)
 

It would have been nice to keep the spacing but that shouldn't be a show stopper..

Quoted 2 lines

I did this, but checkpatch.pl complained about this... so I removed the space.

Quoted 7 lines

Yeah, but look at the file. checkpatch suggests alignment that is common for function calls, but this doesn't look like a sequence of function calls, rather like a table - and we align other tables (like fields in structure definitions) as well because you usually don't read them in a linear fashion but want to spot key values immediately.

Please ignore checkpatch in this case.

Ok, thanks! Below is it.

--------------------------->

As suggested by Al, we can use the generic sys_pipe() instead of xtensa_pipe() for xtensa.

---

arch/xtensa/include/asm/syscall.h +0 -1
index 05cebf8..76a1fb8 100644
@@ -12,7 +12,6 @@ struct pt_regs;
 struct sigaction;
 asmlinkage long xtensa_execve(char*, char**, char**, struct pt_regs*);
 asmlinkage long xtensa_clone(unsigned long, unsigned long, struct pt_regs*);
-asmlinkage long xtensa_pipe(int __user *);
 asmlinkage long xtensa_mmap2(unsigned long, unsigned long, unsigned long,
     			     unsigned long, unsigned long, unsigned long);
 asmlinkage long xtensa_ptrace(long, long, long, long);
arch/xtensa/include/asm/unistd.h +1 -1
index c092c8f..b6880c8 100644
@@ -94,7 +94,7 @@ __SYSCALL( 35, sys_readlink, 3)
 #define __NR_mknod 				 36
 __SYSCALL( 36, sys_mknod, 3)
 #define __NR_pipe 				 37
-__SYSCALL( 37, xtensa_pipe, 1)
+__SYSCALL( 37, sys_pipe, 1)
 #define __NR_unlink 				 38
 __SYSCALL( 38, sys_unlink, 1)
 #define __NR_rmdir 				 39
arch/xtensa/kernel/syscall.c +0 -18
index ac15ecb..c7279be 100644
@@ -39,24 +39,6 @@ syscall_t sys_call_table[__NR_syscall_count] /* FIXME __cacheline_aligned */= {
 #include <asm/unistd.h>
 };
 
-/*
- * xtensa_pipe() is the normal C calling standard for creating a pipe. It's not
- * the way unix traditional does this, though.
- */
-
-asmlinkage long xtensa_pipe(int __user *userfds)
-{
-	int fd[2];
-	int error;
-
-	error = do_pipe_flags(fd, 0);
-	if (!error) {
-		if (copy_to_user(userfds, fd, 2 * sizeof(int)))
-			error = -EFAULT;
-	}
-	return error;
-}
-
 
 asmlinkage long xtensa_mmap2(unsigned long addr, unsigned long len,
    			     unsigned long prot, unsigned long flags,
#6 lore raw
In reply to Amerigo Wang
Quoted 17 lines · Amerigo Wang

As suggested by Al, it's better to use the generic sys_pipe() for ia32.

Cc Ingo Molnar <[email protected]>
Cc Al Viro <[email protected]>
CC Linus Torvalds <[email protected]>
arch/x86/ia32/sys_ia32.c +0 -3
@@ -189,20 +189,6 @@ asmlinkage long sys32_mprotect(unsigned long start, size_t len,
 	return sys_mprotect(start, len, prot);
 }
 
-asmlinkage long sys32_pipe(int __user *fd)
-{
-	int retval;

arch/x86/ia32/sys_ia32.c asmlinkage long sys32_mprotect(unsigned long start, size_t len, · line 204

Quoted 10 lines
arch/x86/ia32/sys_ia32.c +0 -10
-	int fds[2];
-
-	retval = do_pipe_flags(fds, 0);
-	if (retval)
-		goto out;
-	if (copy_to_user(fd, fds, sizeof(fds)))
-		retval = -EFAULT;
-out:
-	return retval;
-}

Please _ALWAYS_ mention the change in behavior in the changelog, just in case someone ends up bisecting it. I only found out when i reviewed the two syscalls out of caution.

The syscall you remove kept stale fd's around in case of -EFAULT from copy_to_user(). The generic version does an explicit close of those files:

                        sys_close(fd[0]);
                        sys_close(fd[1]);
                        error = -EFAULT;

The generic version looks like the better choice to me but this difference should be mentioned in the changelog nevertheless, just in case some buggy app runs into this issue.

Ingo

#7 lore raw
Quoted 35 lines · Ingo Molnar
Quoted 19 lines · Amerigo Wang

As suggested by Al, it's better to use the generic sys_pipe() for ia32.

Cc Ingo Molnar <[email protected]>
Cc Al Viro <[email protected]>
CC Linus Torvalds <[email protected]>
arch/x86/ia32/sys_ia32.c +0 -4
@@ -189,20 +189,6 @@ asmlinkage long sys32_mprotect(unsigned long start, size_t len,
 	return sys_mprotect(start, len, prot);
 }
 
-asmlinkage long sys32_pipe(int __user *fd)
-{
-	int retval;
-	int fds[2];

arch/x86/ia32/sys_ia32.c asmlinkage long sys32_mprotect(unsigned long start, size_t len, · line 192

Quoted 10 lines
arch/x86/ia32/sys_ia32.c +0 -9
-
-	retval = do_pipe_flags(fds, 0);
-	if (retval)
-		goto out;
-	if (copy_to_user(fd, fds, sizeof(fds)))
-		retval = -EFAULT;
-out:
-	return retval;
-}
 

Please _ALWAYS_ mention the change in behavior in the changelog, just in case someone ends up bisecting it. I only found out when i reviewed the two syscalls out of caution.

Quoted 8 lines

The syscall you remove kept stale fd's around in case of -EFAULT from copy_to_user(). The generic version does an explicit close of those files:

                        sys_close(fd[0]);
                        sys_close(fd[1]);
                        error = -EFAULT;

The generic version looks like the better choice to me but this difference should be mentioned in the changelog nevertheless, just in case some buggy app runs into this issue.

Hi, yes, exactly.
Thank you! I will be careful next time.

#8 lore raw
In reply to Ingo Molnar
Quoted 8 lines · Ingo Molnar

Please _ALWAYS_ mention the change in behavior in the changelog, just in case someone ends up bisecting it. I only found out when i reviewed the two syscalls out of caution.

The syscall you remove kept stale fd's around in case of -EFAULT from copy_to_user(). The generic version does an explicit close of those files:

Quoted 7 lines
                        sys_close(fd[0]);
                        sys_close(fd[1]);
                        error = -EFAULT;

The generic version looks like the better choice to me but this difference should be mentioned in the changelog nevertheless, just in case some buggy app runs into this issue.

It's not a matter of QOI, actually - sys32_pipe() is supposed to do what sys_pipe() would do on i386 host. So any difference in handling of an error case is simply wrong.

Whether we want those sys_close() in sys_pipe() or not is a separate question, but we definitely want the same behaviour when 32bit process is run natively and when it's run on amd64. So sys32_pipe() has no business existing at all.

#9 lore raw
Quoted 5 lines · Al Viro
Quoted 3 lines · Ingo Molnar

Please _ALWAYS_ mention the change in behavior in the changelog, just in case someone ends up bisecting it. I only found out when i reviewed the two syscalls out of caution.

[snip]

Quoted 4 lines
Quoted 3 lines

The generic version looks like the better choice to me but this difference should be mentioned in the changelog nevertheless, just in case some buggy app runs into this issue.

Quoted 8 lines

It's not a matter of QOI, actually - sys32_pipe() is supposed to do what sys_pipe() would do on i386 host. So any difference in handling of an error case is simply wrong.

Whether we want those sys_close() in sys_pipe() or not is a separate question, but we definitely want the same behaviour when 32bit process is run natively and when it's run on amd64. So sys32_pipe() has no business existing at all.

PS: said that, mentioning the change in commit message is a Good Idea(tm), obviously...

#10 lore raw
In reply to Al Viro
Quoted 18 lines · Al Viro
Quoted 8 lines · Ingo Molnar

Please _ALWAYS_ mention the change in behavior in the changelog, just in case someone ends up bisecting it. I only found out when i reviewed the two syscalls out of caution.

The syscall you remove kept stale fd's around in case of -EFAULT from copy_to_user(). The generic version does an explicit close of those files:

Quoted 7 lines
                        sys_close(fd[0]);
                        sys_close(fd[1]);
                        error = -EFAULT;

The generic version looks like the better choice to me but this difference should be mentioned in the changelog nevertheless, just in case some buggy app runs into this issue.

Quoted 8 lines

It's not a matter of QOI, actually - sys32_pipe() is supposed to do what sys_pipe() would do on i386 host. So any difference in handling of an error case is simply wrong.

Whether we want those sys_close() in sys_pipe() or not is a separate question, but we definitely want the same behaviour when 32bit process is run natively and when it's run on amd64. So sys32_pipe() has no business existing at all.

I generally agree except the notion that we 'must' do this change.

This is a (small) past ABI sin of ours and we have to live with the consequences without breaking apps. We didnt break any it appears so it's all good.

Ingo