Patchwork remove bogus ppc_select syscall

login
register
mail settings
Submitter Arnd Bergmann
Date Sept. 24, 2008, 6:39 a.m.
Message ID <200809240839.14902.arnd@arndb.de>
Download mbox | patch
Permalink /patch/1240/
State Changes Requested
Headers show

Comments

Arnd Bergmann - Sept. 24, 2008, 6:39 a.m.
The ppc_select function was introduced in linux-2.3.48 in order to support
code confusing the legacy select() calling convention with the standard one.
Even 11 years ago, all correctly built code should not have done this and
could have easily been phased out. Nothing that was compiled later should
actually try to use the old_select interface, and it would have been broken
already on all ppc64 kernels with the syscall emulation layer.

This patch brings the 32 bit compat ABI and the native 32 bit ABI for
powerpc into a consistent state, by removing support for both the
old_select system call number and the handler for it.

The bug report triggering this came from Halesh Sadashiiv <halesh.sadashiv@ap.sony.com>, who discovered that the 32 bit
implementation of ppc_select would in case of a negative number
of file descriptors incorrectly return -EFAULT instead of -EINVAL.
There seems to be no way to fix this problem in a way that would
keep broken pre-1997 binaries running.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Halesh Sadashiiv <halesh.sadashiv@ap.sony.com>
---

Halesh, please test this patch to make sure it fixes the problem
you reported. I do not have a ppc32 machine I can try this on.
Paul Mackerras - Sept. 24, 2008, 4:29 p.m.
Arnd Bergmann writes:

> diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/asm/systbl.h
> index f6cc7a4..5a69b32 100644
> --- a/arch/powerpc/include/asm/systbl.h
> +++ b/arch/powerpc/include/asm/systbl.h
> @@ -85,7 +85,7 @@ COMPAT_SYS_SPU(gettimeofday)
>  COMPAT_SYS_SPU(settimeofday)
>  COMPAT_SYS_SPU(getgroups)
>  COMPAT_SYS_SPU(setgroups)
> -SYSX(sys_ni_syscall,sys_ni_syscall,ppc_select)
> +SYSCALL(sys_ni_syscall)

I don't see any reason to remove the old select syscall on 32-bit
kernels.  I think this hunk below is the only part of the patch that
we actually need:

> @@ -145,7 +145,7 @@ SYSCALL_SPU(setfsuid)
>  SYSCALL_SPU(setfsgid)
>  SYSCALL_SPU(llseek)
>  COMPAT_SYS_SPU(getdents)
> -SYSX_SPU(sys_select,ppc32_select,ppc_select)
> +SYSX_SPU(sys_select,ppc32_select,sys_select)

Paul.
Arnd Bergmann - Sept. 24, 2008, 5:03 p.m.
On Wednesday 24 September 2008, Paul Mackerras wrote:
> > diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/asm/systbl.h
> > index f6cc7a4..5a69b32 100644
> > --- a/arch/powerpc/include/asm/systbl.h
> > +++ b/arch/powerpc/include/asm/systbl.h
> > @@ -85,7 +85,7 @@ COMPAT_SYS_SPU(gettimeofday)
> >  COMPAT_SYS_SPU(settimeofday)
> >  COMPAT_SYS_SPU(getgroups)
> >  COMPAT_SYS_SPU(setgroups)
> > -SYSX(sys_ni_syscall,sys_ni_syscall,ppc_select)
> > +SYSCALL(sys_ni_syscall)
> 
> I don't see any reason to remove the old select syscall on 32-bit
> kernels.  

Well, the point I made earlier ist that the native ppc32 path should
behave the same way as the compat ppc32 path. If we keep ppc_select
in one way or another, we should also have a compat wrapper for that,
right?

	Arnd <><
Benjamin Herrenschmidt - Oct. 10, 2008, 4:29 a.m.
On Wed, 2008-09-24 at 08:39 +0200, Arnd Bergmann wrote:
> The ppc_select function was introduced in linux-2.3.48 in order to support
> code confusing the legacy select() calling convention with the standard one.
> Even 11 years ago, all correctly built code should not have done this and
> could have easily been phased out. Nothing that was compiled later should
> actually try to use the old_select interface, and it would have been broken
> already on all ppc64 kernels with the syscall emulation layer.
> 
> This patch brings the 32 bit compat ABI and the native 32 bit ABI for
> powerpc into a consistent state, by removing support for both the
> old_select system call number and the handler for it.

 .../...

It's me or the patch is whitespaces damaged ?

Cheers,
Ben.
Paul Mackerras - Oct. 10, 2008, 7:40 a.m.
Arnd Bergmann writes:

> Well, the point I made earlier ist that the native ppc32 path should
> behave the same way as the compat ppc32 path. If we keep ppc_select
> in one way or another, we should also have a compat wrapper for that,
> right?

No - we have other old system calls that don't exist at all on a
64-bit kernel but do on a 32-bit kernel.  We decided a long time ago
that there was no point supporting really ancient 32-bit userland code
on a 64-bit kernel.  That doesn't mean we need to rip out the support
from the 32-bit kernel.

Paul.
Paul Mackerras - Oct. 10, 2008, 7:43 a.m.
Benjamin Herrenschmidt writes:

> On Wed, 2008-09-24 at 08:39 +0200, Arnd Bergmann wrote:
> > The ppc_select function was introduced in linux-2.3.48 in order to support
> > code confusing the legacy select() calling convention with the standard one.
> > Even 11 years ago, all correctly built code should not have done this and
> > could have easily been phased out. Nothing that was compiled later should
> > actually try to use the old_select interface, and it would have been broken
> > already on all ppc64 kernels with the syscall emulation layer.
> > 
> > This patch brings the 32 bit compat ABI and the native 32 bit ABI for
> > powerpc into a consistent state, by removing support for both the
> > old_select system call number and the handler for it.
> 
>  .../...
> 
> It's me or the patch is whitespaces damaged ?

Please don't apply Arnd's patch.  As I said, all we need is this
one-line change in arch/powerpc/include/asm/systbl.h:

-SYSX_SPU(sys_select,ppc32_select,ppc_select)
+SYSX_SPU(sys_select,ppc32_select,sys_select)

Paul.
Benjamin Herrenschmidt - Oct. 10, 2008, 11:17 p.m.
On Fri, 2008-10-10 at 18:43 +1100, Paul Mackerras wrote:
> > It's me or the patch is whitespaces damaged ?
> 
> Please don't apply Arnd's patch.  As I said, all we need is this
> one-line change in arch/powerpc/include/asm/systbl.h:
> 
> -SYSX_SPU(sys_select,ppc32_select,ppc_select)
> +SYSX_SPU(sys_select,ppc32_select,sys_select)

Ok, so you want to keep compat with the old stuff. Note that we still
have this weird thing that on 64-bit kernels, we don't provide this.

Ben.
Arnd Bergmann - Oct. 12, 2008, 8:58 a.m.
On Saturday 11 October 2008, Benjamin Herrenschmidt wrote:
> > 
> > -SYSX_SPU(sys_select,ppc32_select,ppc_select)
> > +SYSX_SPU(sys_select,ppc32_select,sys_select)
> 
> Ok, so you want to keep compat with the old stuff. Note that we still
> have this weird thing that on 64-bit kernels, we don't provide this.

This change makes the funny wrapper only active for the "old" select
number on native ppc32, which is not active on ppc64 or compat32,
while any programs using the "new" select number, i.e. any binay you
will ever encounter in practice, now gets the standard semantics.

	Arnd <><
Ayman El-Khashab - Oct. 13, 2008, 2:42 a.m.
Does the linux i2o driver / subsystem work with the i2o unit
in the AMCC 460EX?  In the AMCC part it is part of the PCI-E
interface.  

Thanks
ayman

Patch

diff --git a/arch/powerpc/include/asm/unistd.h b/arch/powerpc/include/asm/unistd.h
index e07d0c7..46107cc 100644
--- a/arch/powerpc/include/asm/unistd.h
+++ b/arch/powerpc/include/asm/unistd.h
@@ -92,7 +92,7 @@ 
 #define __NR_settimeofday       79
 #define __NR_getgroups          80
 #define __NR_setgroups          81
-#define __NR_select             82
+/* Number 82 was the old (pre-1.3.x) select */
 #define __NR_symlink            83
 #define __NR_oldlstat           84
 #define __NR_readlink           85
diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/asm/systbl.h
index f6cc7a4..5a69b32 100644
--- a/arch/powerpc/include/asm/systbl.h
+++ b/arch/powerpc/include/asm/systbl.h
@@ -85,7 +85,7 @@  COMPAT_SYS_SPU(gettimeofday)
 COMPAT_SYS_SPU(settimeofday)
 COMPAT_SYS_SPU(getgroups)
 COMPAT_SYS_SPU(setgroups)
-SYSX(sys_ni_syscall,sys_ni_syscall,ppc_select)
+SYSCALL(sys_ni_syscall)
 SYSCALL_SPU(symlink)
 OLDSYS(lstat)
 COMPAT_SYS_SPU(readlink)
@@ -145,7 +145,7 @@  SYSCALL_SPU(setfsuid)
 SYSCALL_SPU(setfsgid)
 SYSCALL_SPU(llseek)
 COMPAT_SYS_SPU(getdents)
-SYSX_SPU(sys_select,ppc32_select,ppc_select)
+SYSX_SPU(sys_select,ppc32_select,sys_select)
 SYSCALL_SPU(flock)
 SYSCALL_SPU(msync)
 COMPAT_SYS_SPU(readv)
diff --git a/arch/powerpc/kernel/syscalls.c b/arch/powerpc/kernel/syscalls.c
index c04832c..c2e6a74 100644
--- a/arch/powerpc/kernel/syscalls.c
+++ b/arch/powerpc/kernel/syscalls.c
@@ -183,31 +183,6 @@  unsigned long sys_mmap(unsigned long addr, size_t len,
 	return do_mmap2(addr, len, prot, flags, fd, offset, PAGE_SHIFT);
 }
 
-#ifdef CONFIG_PPC32
-/*
- * Due to some executables calling the wrong select we sometimes
- * get wrong args.  This determines how the args are being passed
- * (a single ptr to them all args passed) then calls
- * sys_select() with the appropriate args. -- Cort
- */
-int
-ppc_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, struct timeval __user *tvp)
-{
-	if ( (unsigned long)n >= 4096 )
-	{
-		unsigned long __user *buffer = (unsigned long __user *)n;
-		if (!access_ok(VERIFY_READ, buffer, 5*sizeof(unsigned long))
-		    || __get_user(n, buffer)
-		    || __get_user(inp, ((fd_set __user * __user *)(buffer+1)))
-		    || __get_user(outp, ((fd_set  __user * __user *)(buffer+2)))
-		    || __get_user(exp, ((fd_set  __user * __user *)(buffer+3)))
-		    || __get_user(tvp, ((struct timeval  __user * __user *)(buffer+4))))
-			return -EFAULT;
-	}
-	return sys_select(n, inp, outp, exp, tvp);
-}
-#endif
-
 #ifdef CONFIG_PPC64
 long ppc64_personality(unsigned long personality)
 {