From patchwork Wed Sep 24 06:39:14 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 1240 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 771BBDDEDA for ; Wed, 24 Sep 2008 16:39:50 +1000 (EST) X-Original-To: linuxppc-dev@ozlabs.org Delivered-To: linuxppc-dev@ozlabs.org Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.183]) by ozlabs.org (Postfix) with ESMTP id C8FCCDDE11; Wed, 24 Sep 2008 16:39:31 +1000 (EST) Received: from klappe.local ([207.108.95.66]) by mrelayeu.kundenserver.de (node=mrelayeu4) with ESMTP (Nemesis) id 0ML21M-1KiO221uDB-0007sU; Wed, 24 Sep 2008 08:39:27 +0200 From: Arnd Bergmann To: linuxppc-embedded@ozlabs.org, paulus@samba.org Subject: [PATCH] remove bogus ppc_select syscall Date: Wed, 24 Sep 2008 08:39:14 +0200 User-Agent: KMail/1.9.9 References: <7B7EF7F090B9804A830ACC82F2CDE95D56E206@insardxms01.ap.sony.com> <1222160853.12085.136.camel@pasglop> <200809240823.12484.arnd@arndb.de> In-Reply-To: <200809240823.12484.arnd@arndb.de> X-Face: I@=L^?./?$U, EK.)V[4*>`zSqm0>65YtkOe>TFD'!aw?7OVv#~5xd\s, [~w]-J!)|%=]>=?utf-8?q?+=0A=09=7EohchhkRGW=3F=7C6=5FqTmkd=5Ft=3FLZC=23Q-=60=2E=60Y=2Ea=5E?= =?utf-8?q?3zb?=) =?utf-8?q?+U-JVN=5DWT=25cw=23=5BYo0=267C=26bL12wWGlZi=0A=09=7EJ=3B=5Cwg?= =?utf-8?q?=3B3zRnz?=, J"CT_)=\H'1/{?SR7GDu?WIopm.HaBG=QYj"NZD_[zrM\Gip^U MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200809240839.14902.arnd@arndb.de> X-Provags-ID: V01U2FsdGVkX1+OsH+5+4X+m1R9LRUbbddX/CeIvlj+aupjTw2 qV5LR2z4Zm298XXJyEnQgD0kIBdbIKHhs3ikespolLqqmEm1uf E2J5Pzgma7IH1z7nh8tIw== Cc: "Sadashiiv, Halesh" , linuxppc-dev@ozlabs.org X-BeenThere: linuxppc-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org 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 , 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 Cc: Halesh Sadashiiv --- 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. 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) {