tst_clone: Fix child detection on sparc
PATCH v2 1/1 tst_clone: Fix child detection on sparc
On sparc the clone syscall does not return 0 in the child. It returns the parent pid, so the child thinks it is the parent.
Save the pid before the clone and compare it after.
--- lib/tst_clone.c | 8 ++++++++ 1 file changed, 8 insertions(+)
lib/tst_clone.c +8 -0
@@ -20,6 +20,9 @@ pid_t tst_clone(const struct tst_clone_args *tst_args) };int flags;pid_t pid =-1 ; +#ifdef __sparc__ +pid_t parent_pid =tst_getpid (); +#endif tst_flush ();
@@ -44,5 +47,10 @@ pid_t tst_clone(const struct tst_clone_args *tst_args)if (pid ==-1 )return -2 ; +#ifdef __sparc__ +if (pid == parent_pid) + pid =0 ; +#endif +return pid; }
Signature · 5 lines
2.53.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Anders,
lib/tst_clone.c pid_t tst_clone(const struct tst_clone_args *tst_args) · line 25
Quoted 9 lines · Anders Roxell
tst_clone: Fix child detection on sparclib/tst_clone.c +3
-0@@ -20,6 +20,9 @@ pid_t tst_clone(const struct tst_clone_args *tst_args) };int flags;pid_t pid =-1 ; +#ifdef __sparc__ +pid_t parent_pid =tst_getpid (); +#endif
On SPARC, clone3 already returns 0 in the child, making this call redundant when clone3 succeeds; move it into the clone fallback path right before syscall(__NR_clone, ...). Additionally, the SPARC kernel returns the caller's TID (current->pid) in %o0 to the child, so use tst_gettid() instead of tst_getpid() to support multithreaded callers.
Verdict - Needs revision
---
Note:
The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Anders,
Quoted 2 lines
On sparc the clone syscall does not return 0 in the child. It returns the parent pid, so the child thinks it is the parent.
So, somebody still test sparc :). Before applying a workaround few questions.
I suppose this is because we did not updated our syscalls numbers.
I send a patch which regenerated syscall numbers to have clone3 on sparc (both 32 and 64 bit) v7.0:
$ include/lapi/syscalls/generate_arch.sh ../linux
Can you please verify it works with clone3()? It was added this year in v7.0 in 2153b2e8917b7 ("sparc: Add architecture support for clone3")
Do we care about the past?
Kind regards,
Petr
Quoted 32 lines
Save the pid before the clone and compare it after.
Signed-off-by Anders Roxell <[email protected]>--- lib/tst_clone.c | 8 ++++++++ 1 file changed, 8 insertions(+)lib/tst_clone.c +8
-0@@ -20,6 +20,9 @@ pid_t tst_clone(const struct tst_clone_args *tst_args) };int flags;pid_t pid =-1 ; +#ifdef __sparc__ +pid_t parent_pid =tst_getpid (); +#endif tst_flush ();@@ -44,5 +47,10 @@ pid_t tst_clone(const struct tst_clone_args *tst_args)if (pid ==-1 )return -2 ; +#ifdef __sparc__ +if (pid == parent_pid) + pid =0 ; +#endif +return pid; }
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 9 lines · Petr Vorel
Hi Anders,
Quoted 2 lines
On sparc the clone syscall does not return 0 in the child. It returns the parent pid, so the child thinks it is the parent.
So, somebody still test sparc :). Before applying a workaround few questions.
I suppose this is because we did not updated our syscalls numbers.
Yes, clone3 was missing...
Quoted 9 lines
I send a patch which regenerated syscall numbers to have clone3 on sparc (both 32 and 64 bit) v7.0:
$ include/lapi/syscalls/generate_arch.sh ../linuxCan you please verify it works with
clone3()? It was added this year in v7.0 in2153b2e8917b7("sparc: Add architecture support for clone3")
Yes, it works. I tested on sparc64 in QEMU with a v7.3-rc4 kernel and a buildroot
rootfs with LTP 20260529 + your patch only. All 94 fs_bind tests pass.
Quoted 2 lines
Do we care about the past?
That's a good question, I think we do, because of the LTS kernels... We run the latest LTP on the LTS kernels...
Cheers,
Anders
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Anders,
Quoted 12 lines · Petr Vorel
Quoted 9 lines
Hi Anders,
Quoted 2 lines
On sparc the clone syscall does not return 0 in the child. It returns the parent pid, so the child thinks it is the parent.
So, somebody still test sparc :). Before applying a workaround few questions.
I suppose this is because we did not updated our syscalls numbers.
Yes, clone3 was missing...
Thanks for info.
Quoted 11 lines
Quoted 7 lines
I send a patch which regenerated syscall numbers to have clone3 on sparc (both 32 and 64 bit) v7.0:
$ include/lapi/syscalls/generate_arch.sh ../linuxCan you please verify it works with
clone3()? It was added this year in v7.0 in2153b2e8917b7("sparc: Add architecture support for clone3")Yes, it works. I tested on sparc64 in QEMU with a v7.3-rc4 kernel and a buildroot
rootfs with LTP 20260529 + your patch only. All 94fs_bindtests pass.
FYI there is v2 from Andrea, your testing is highly appreciated (although the might be some additional changes to script which generates it.
https://patchwork.kernel.org/project/ltp/list/?series=1176684&state=*
Quoted 4 lines
Quoted 1 line
Do we care about the past?
That's a good question, I think we do, because of the LTS kernels... We run the latest LTP on the LTS kernels...
Yeah, it should be probably merged. I'm sorry that we did not make it to this LTP release (Cyril is tagging today). Could you please send v3, which address agent issues?
https://lore.kernel.org/ltp/CADYN=9Jh83y=n55DbM-niXBE0kot87jECtuM778_WSo6e3p=8g@mail.gmail.com/
Kind regards,
Petr
Quoted 2 lines
Cheers,
Anders
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 37 lines · Petr Vorel
Hi Anders,
Quoted 12 lines · Petr Vorel
Quoted 9 lines
Hi Anders,
Quoted 2 lines
On sparc the clone syscall does not return 0 in the child. It returns the parent pid, so the child thinks it is the parent.
So, somebody still test sparc :). Before applying a workaround few questions.
I suppose this is because we did not updated our syscalls numbers.
Yes, clone3 was missing...
Thanks for info.
Quoted 11 lines
Quoted 7 lines
I send a patch which regenerated syscall numbers to have clone3 on sparc (both 32 and 64 bit) v7.0:
$ include/lapi/syscalls/generate_arch.sh ../linuxCan you please verify it works with
clone3()? It was added this year in v7.0 in2153b2e8917b7("sparc: Add architecture support for clone3")Yes, it works. I tested on sparc64 in QEMU with a v7.3-rc4 kernel and a buildroot
rootfs with LTP 20260529 + your patch only. All 94fs_bindtests pass.FYI there is v2 from Andrea, your testing is highly appreciated (although the might be some additional changes to script which generates it.
https://patchwork.kernel.org/project/ltp/list/?series=1176684&state=*
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Do we care about the past?
That's a good question, I think we do, because of the LTS kernels... We run the latest LTP on the LTS kernels...
Yeah, it should be probably merged. I'm sorry that we did not make it to this LTP release (Cyril is tagging today). Could you please send v3, which address agent issues?
Yes I will rework the patch, send it out shortly.
Cheers,
Anders
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp