NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/59608: compat_linux should ignore LINUX_CLONE_SYSVSEM and assume stack grows down



hi,

just a quick up on this, as maybe i should clarified that glibc blindly uses the

clone_sysvsem: https://codebrowser.dev/glibc/glibc/nptl/pthread_create.c.html#279

and, since there is a clone3 syscall now, that returns einval because of the flag,

https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/clone-internal.c.html#47

so the fallback never reaches, rendering multithreading unusable in binary emulation...



the (updated, reattached) patch addresses the flag to slip through the checks,

and later gets ignored, and then points the stack pointer to the proper location,

restoring the pthread_create functionality... applying the patch to the 11-beta

(and seemingly 10-daily also needs this) passes the simple test code i sent earlier.

awaiting your feedback on merging if you find it appropriate... :)

ps: this time i added the ifdef to check the stack-grows-up/down behavior....

all the best,

csaba





On 8/25/25 21:20, gnats-admin%netbsd.org@localhost wrote:
Thank you very much for your problem report.
It has the internal identification `kern/59608'.
The individual assigned to look at your
report is: kern-bug-people.

Category:       kern
Responsible:    kern-bug-people
Synopsis:       compat_linux should ignore LINUX_CLONE_SYSVSEM and assume stack grows down
Arrival-Date:   Mon Aug 25 19:20:00 +0000 2025

--- src.bad/sys/compat/linux/common/linux_sched.h	2024-09-28 21:35:56.000000000 +0200
+++ src.ok/sys/compat/linux/common/linux_sched.h	2025-08-25 20:48:10.531115738 +0200
@@ -85,7 +85,7 @@
     LINUX_CLONE_VM | LINUX_CLONE_FS | LINUX_CLONE_FILES | \
     LINUX_CLONE_SIGHAND | LINUX_CLONE_THREAD | LINUX_CLONE_VFORK | \
     LINUX_CLONE_PARENT_SETTID | LINUX_CLONE_CHILD_CLEARTID | \
-    LINUX_CLONE_CHILD_SETTID | LINUX_CLONE_SETTLS)
+    LINUX_CLONE_CHILD_SETTID | LINUX_CLONE_SETTLS | LINUX_CLONE_SYSVSEM)
 
 #define LINUX_CLONE_UNIMPLEMENTED_FLAGS ( \
     LINUX_CLONE_NEWNS | LINUX_CLONE_NEWUTS | LINUX_CLONE_NEWIPC | \
--- src.bad/sys/compat/linux/common/linux_sched.c	2024-10-03 14:56:49.000000000 +0200
+++ src.ok/sys/compat/linux/common/linux_sched.c	2025-08-27 09:03:56.571338285 +0200
@@ -230,7 +230,11 @@
    // XXX: clone3 has stacksize, instead implement clone as a clone3
    // wrapper.
    SCARG(&clone_args, flags) = flags;
+#ifdef __MACHINE_STACK_GROWS_UP
    SCARG(&clone_args, stack) = (void *)(uintptr_t)cl_args.stack;
+#else
+	SCARG(&clone_args, stack) = (void *)((uintptr_t)cl_args.stack + (uintptr_t)cl_args.stack_size);
+#endif
    SCARG(&clone_args, parent_tidptr) =
        (void *)(intptr_t)cl_args.parent_tid;
    SCARG(&clone_args, tls) =


Home | Main Index | Thread Index | Old Index