* [LTP] [PATCH 0/2] syscalls/kcmp03.c: Fix CLONE_IO failure on s390 @ 2020-05-08 13:09 Alexander Gordeev 2020-05-08 13:09 ` [LTP] [PATCH 1/2] syscalls/kcmp03.c: Extend clone_type type to unsigned long Alexander Gordeev 2020-05-08 13:09 ` [LTP] [PATCH 2/2] lib/cloner.c: Use __clone instead of clone for s390 Alexander Gordeev 0 siblings, 2 replies; 5+ messages in thread From: Alexander Gordeev @ 2020-05-08 13:09 UTC (permalink / raw) To: ltp Hi all, This series fixes the CLONE_IO flag test on s390: kcmp03.c:82: FAIL: clone() Failed: EBADF (9) The reason for the failure is CLONE_IO flag is sign- extended to unsigned long and CLONE_INTO_CGROUP gets set unintentionally. The kernel does its job well and fails the syscall. The fix is probably wrong, as the right solution needs to accomodate all archs. I however, post it as a short-term solution that might work for other archs as well. Thanks! Alexander Gordeev (2): syscalls/kcmp03.c: Extend clone_type type to unsigned long lib/cloner.c: Use __clone instead of clone for s390 lib/cloner.c | 5 +++++ testcases/kernel/syscalls/kcmp/kcmp03.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) -- 1.8.3.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [LTP] [PATCH 1/2] syscalls/kcmp03.c: Extend clone_type type to unsigned long 2020-05-08 13:09 [LTP] [PATCH 0/2] syscalls/kcmp03.c: Fix CLONE_IO failure on s390 Alexander Gordeev @ 2020-05-08 13:09 ` Alexander Gordeev 2020-05-08 13:09 ` [LTP] [PATCH 2/2] lib/cloner.c: Use __clone instead of clone for s390 Alexander Gordeev 1 sibling, 0 replies; 5+ messages in thread From: Alexander Gordeev @ 2020-05-08 13:09 UTC (permalink / raw) To: ltp Member clone_type is defined as signed integer type. That is too small to accomodate CLONE_IO (which conflicts with the sign bit) and newer clone flags (i.e CLONE_INTO_CGROUP). Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com> --- testcases/kernel/syscalls/kcmp/kcmp03.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testcases/kernel/syscalls/kcmp/kcmp03.c b/testcases/kernel/syscalls/kcmp/kcmp03.c index 30ac3ec..f36515f 100644 --- a/testcases/kernel/syscalls/kcmp/kcmp03.c +++ b/testcases/kernel/syscalls/kcmp/kcmp03.c @@ -31,7 +31,7 @@ static int pid2; static void *stack; static struct tcase { - int clone_type; + unsigned long clone_type; int kcmp_type; } tcases[] = { {CLONE_VM, KCMP_VM}, -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [LTP] [PATCH 2/2] lib/cloner.c: Use __clone instead of clone for s390 2020-05-08 13:09 [LTP] [PATCH 0/2] syscalls/kcmp03.c: Fix CLONE_IO failure on s390 Alexander Gordeev 2020-05-08 13:09 ` [LTP] [PATCH 1/2] syscalls/kcmp03.c: Extend clone_type type to unsigned long Alexander Gordeev @ 2020-05-08 13:09 ` Alexander Gordeev 2020-05-08 14:20 ` Jan Stancek 1 sibling, 1 reply; 5+ messages in thread From: Alexander Gordeev @ 2020-05-08 13:09 UTC (permalink / raw) To: ltp 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(+) 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) \ -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [LTP] [PATCH 2/2] lib/cloner.c: Use __clone instead of clone for s390 2020-05-08 13:09 ` [LTP] [PATCH 2/2] lib/cloner.c: Use __clone instead of clone for s390 Alexander Gordeev @ 2020-05-08 14:20 ` Jan Stancek 2020-05-11 8:33 ` Petr Vorel 0 siblings, 1 reply; 5+ messages in thread From: Jan Stancek @ 2020-05-08 14:20 UTC (permalink / raw) To: ltp ----- 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [LTP] [PATCH 2/2] lib/cloner.c: Use __clone instead of clone for s390 2020-05-08 14:20 ` Jan Stancek @ 2020-05-11 8:33 ` Petr Vorel 0 siblings, 0 replies; 5+ messages in thread From: Petr Vorel @ 2020-05-11 8:33 UTC (permalink / raw) To: ltp 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-05-11 8:33 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-05-08 13:09 [LTP] [PATCH 0/2] syscalls/kcmp03.c: Fix CLONE_IO failure on s390 Alexander Gordeev 2020-05-08 13:09 ` [LTP] [PATCH 1/2] syscalls/kcmp03.c: Extend clone_type type to unsigned long Alexander Gordeev 2020-05-08 13:09 ` [LTP] [PATCH 2/2] lib/cloner.c: Use __clone instead of clone for s390 Alexander Gordeev 2020-05-08 14:20 ` Jan Stancek 2020-05-11 8:33 ` Petr Vorel
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.