On Thu, Nov 25, 2021 at 06:10:54AM -0600, Rob Landley wrote: > On 11/25/21 1:25 AM, Arnd Bergmann wrote: ... > > > > The best reference I could find is: > > > > https://lore.kernel.org/linux-api/20190604160944.4058-2-christian@xxxxxxxxxx/ > > Does not say what the special handling is. Does not provide an example of said > special handling. Implied that only three do NOT need special handling, two of > which are x86 and arm, which seems... convenient. > > Right, let's see what "grep -r clone arch/" says: > > m68k/kernel/process.c is obviously overriding > arc/include/syscalls.h has sys_clone_wrapper() > nios2/kernel/process.c has nios2_clone() > openrisc/kernel/entry.S has __sys_clone() > sparc/kernel/process.c has sparce_clone() > h8300/kernel/process.c has its own sys_clone() > ia64/kernel/process.c has ia64_clone() > user mode linux is just weird. > > So the architectures that wrap clone are m68k, arc, nios2, openrisc, sparc, > h8300, and ia64. This got me reading/refreshing my memory, we have a wrapper for clone in openrisc, but not clone3. The wrapper ensures we save registers which get clobbered by switch hence we need it for clone/fork. It looks like clone3 missing this wrapper may be an issue. Though, I have been running the whole glibc test suite on this without seeing any issues. I will patch this anyway. > Implying that the ones that DON'T are alpha, arm64, hexagon, nds32, parisc, > s390, csky, microblaze, powerpc, sh, x86, arm, mips, riscv, and xtensa. > > Which would mean 2/3 of architectures don't wrap clone, and thus arch/sh not > doing so isn't unusual. > > > If fork() and clone() don't need special handling on arch/sh, then > > clone3 shouldn't > > need it either, unless the existing ones are also wrong. It looks like > > some architectures > > override these to avoid leaking register state from the kernel to the > > child process. I would agree with this. -Stafford