Re: [PATCH v3] powerpc/32: remove bogus ppc_select syscall

From: Christophe Leroy
Date: Tue Mar 09 2021 - 11:00:04 EST




Le 05/03/2021 à 13:03, Arnd Bergmann a écrit :
On Fri, Mar 5, 2021 at 11:15 AM Christophe Leroy
<christophe.leroy@xxxxxxxxxx> wrote:
Le 05/03/2021 à 11:06, Arnd Bergmann a écrit :
On Fri, Mar 5, 2021 at 9:40 AM Christophe Leroy <christophe.leroy@xxxxxxxxxx> wrote:
- glibc support for ppc32 gets merged during the linux-2.5 days, supporting
only #142 with the new behavior.

It turns out to be older than I said. This was actually in glibc-1.94
from 1997, so during
the linux-2.1 days, not 2.5!

Whaou, nice archeology, thanks. Do you mind if I copy the history you established ?

That's fine, please copy it.

In your commit, you said 2.3.48. Here in the history you say 2.1.48. Which one is correct ?

2.1.48 is correct.

Regardless of whethere binaries are broken or not for other reason, is that worth expecting an
almost 25 yr old binary to run on future kernels ? If one is able to put the necessary effort to
port you hardware to the latest kernel, can't he really port the binary as well ?

I think the questions of supporting old hardware with new software and
supporting old
binaries on modern kernels are largely orthogonal. The policy we have
is that we don't
break existing user setups, and it really seems unlikely that anyone
still uses pre-1997
executables for anything that requires a modern kernel!

I now checked the oldest mklinux I could find (DR2.1 from 1997), and
even has the
modern glibc and linux-2.0.28 kernel patched to provide the modern semantics at
syscall #142 for glibc, with the same (already unused) compatibility hack at #82
that we still have for ppc32 today. This made mklinux DR2.1 binaries
incompatible
with mainline linux-2.0 kernels, but they might still work with modern kernels,
regardless of whether we remove support for binaries that worked with mainline
linux-2.0.


I had another look. In fact x86, arm and m68k still have the #82 syscall, but they don't have the hack we have on powerpc to "guess" that something is calling the old select with the arguments of the new select.

As part of my series of user accesses cleanup, I'll replace the open coded stuff by a call to sys_old_select(), see below.

Maybe at the end we should keep the #82 syscall, but do we need to keep the powerpc hack really ? Maybe the best is to drop ppc_select() function but mention sys_old_select() instead of ni_syscall for entry #82 in the syscall table ?

Christophe
---
diff --git a/arch/powerpc/include/asm/unistd.h b/arch/powerpc/include/asm/unistd.h
index 700fcdac2e3c..b541c690a31c 100644
--- a/arch/powerpc/include/asm/unistd.h
+++ b/arch/powerpc/include/asm/unistd.h
@@ -40,6 +40,7 @@
#define __ARCH_WANT_SYS_SIGPROCMASK
#ifdef CONFIG_PPC32
#define __ARCH_WANT_OLD_STAT
+#define __ARCH_WANT_SYS_OLD_SELECT
#endif
#ifdef CONFIG_PPC64
#define __ARCH_WANT_SYS_TIME
diff --git a/arch/powerpc/kernel/syscalls.c b/arch/powerpc/kernel/syscalls.c
index 078608ec2e92..a552c9e68d7e 100644
--- a/arch/powerpc/kernel/syscalls.c
+++ b/arch/powerpc/kernel/syscalls.c
@@ -82,16 +82,8 @@ int
ppc_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, struct __kernel_old_timeval __user *tvp)
{
if ( (unsigned long)n >= 4096 )
- {
- unsigned long __user *buffer = (unsigned long __user *)n;
- if (!access_ok(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 __kernel_old_timeval __user * __user *)(buffer+4))))
- return -EFAULT;
- }
+ return sys_old_select((void __user *)n);
+
return sys_select(n, inp, outp, exp, tvp);
}
#endif