diff mbox series

[2/2] lib/cloner.c: Use __clone instead of clone for s390

Message ID 8f28b9797be3408c0c1086d0a2bc9c052b55bfe2.1588942426.git.agordeev@linux.ibm.com
State Rejected
Headers show
Series syscalls/kcmp03.c: Fix CLONE_IO failure on s390 | expand

Commit Message

Alexander Gordeev May 8, 2020, 1:09 p.m. UTC
The kernel sys_clone and s390 glibc entry __clone assume
the flags parameter type as unsigned long. However, the
glibc clone wrapper used by ltp_clone helper defines flags
as signed int. That leads to gcc extending CLONE_IO flag of
0x80000000 value to 0xffffffff80000000.

A quick solution for s390 is to skip clone weak alias and
use __clone entry point directly.

Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
---
 lib/cloner.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Jan Stancek May 8, 2020, 2:20 p.m. UTC | #1
----- Original Message -----
> The kernel sys_clone and s390 glibc entry __clone assume
> the flags parameter type as unsigned long. However, the
> glibc clone wrapper used by ltp_clone helper defines flags
> as signed int. That leads to gcc extending CLONE_IO flag of
> 0x80000000 value to 0xffffffff80000000.

Same problem exists on ppc64le. There's a patch proposed to fix this on
kernel side:
  https://lore.kernel.org/lkml/20200507103214.77218-1-christian.brauner@ubuntu.com/

Earlier discussion is here:
  https://sourceware.org/pipermail/libc-alpha/2020-May/113596.html
Petr Vorel May 11, 2020, 8:33 a.m. UTC | #2
Hi,

> ----- Original Message -----
> > The kernel sys_clone and s390 glibc entry __clone assume
> > the flags parameter type as unsigned long. However, the
> > glibc clone wrapper used by ltp_clone helper defines flags
> > as signed int. That leads to gcc extending CLONE_IO flag of
> > 0x80000000 value to 0xffffffff80000000.

> Same problem exists on ppc64le. There's a patch proposed to fix this on
> kernel side:
>   https://lore.kernel.org/lkml/20200507103214.77218-1-christian.brauner@ubuntu.com/

> Earlier discussion is here:
>   https://sourceware.org/pipermail/libc-alpha/2020-May/113596.html

OK instead of merging whole patchset we should add git commit hash once this fix is
merged (although no reply since v2 post).

Kind regards,
Petr
diff mbox series

Patch

diff --git a/lib/cloner.c b/lib/cloner.c
index 11401f2..1192e4b 100644
--- a/lib/cloner.c
+++ b/lib/cloner.c
@@ -49,6 +49,11 @@  extern int __clone2(int (*fn) (void *arg), void *child_stack_base,
                     size_t child_stack_size, int flags, void *arg,
                     pid_t *parent_tid, void *tls, pid_t *child_tid);
 #endif
+#if defined(__s390__)
+# define clone __clone
+extern int __clone(int (*fn)(void *arg), void *child_stack, unsigned long flags,
+		   void *arg, pid_t *parent_tid, void *tls, pid_t *child_tid);
+#endif
 
 #ifndef CLONE_SUPPORTS_7_ARGS
 # define clone(fn, stack, flags, arg, ptid, tls, ctid) \