* [LTP] [PATCH v2] tst_clone: Fix child detection on sparc
@ 2026-09-29 8:42 Anders Roxell
2026-09-29 11:16 ` [LTP] " linuxtestproject.agent
2026-09-29 14:21 ` [LTP] [PATCH v2] " Petr Vorel
0 siblings, 2 replies; 7+ messages in thread
From: Anders Roxell @ 2026-09-29 8:42 UTC (permalink / raw)
To: ltp
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.
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
---
lib/tst_clone.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lib/tst_clone.c b/lib/tst_clone.c
index 296cd40ac0a0..d7f005a2d2a5 100644
--- a/lib/tst_clone.c
+++ b/lib/tst_clone.c
@@ -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;
}
--
2.53.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [LTP] tst_clone: Fix child detection on sparc
2026-09-29 8:42 [LTP] [PATCH v2] tst_clone: Fix child detection on sparc Anders Roxell
@ 2026-09-29 11:16 ` linuxtestproject.agent
2026-09-29 14:21 ` [LTP] [PATCH v2] " Petr Vorel
1 sibling, 0 replies; 7+ messages in thread
From: linuxtestproject.agent @ 2026-09-29 11:16 UTC (permalink / raw)
To: Anders Roxell; +Cc: ltp
Hi Anders,
On Tue Sep 29 10:42:53 2026 +0200, Anders Roxell wrote:
> tst_clone: Fix child detection on sparc
> @@ -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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [LTP] [PATCH v2] tst_clone: Fix child detection on sparc
2026-09-29 8:42 [LTP] [PATCH v2] tst_clone: Fix child detection on sparc Anders Roxell
2026-09-29 11:16 ` [LTP] " linuxtestproject.agent
@ 2026-09-29 14:21 ` Petr Vorel
2026-09-30 12:16 ` Anders Roxell
1 sibling, 1 reply; 7+ messages in thread
From: Petr Vorel @ 2026-09-29 14:21 UTC (permalink / raw)
To: Anders Roxell; +Cc: ltp
Hi Anders,
> 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
> Save the pid before the clone and compare it after.
> Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
> ---
> lib/tst_clone.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
> diff --git a/lib/tst_clone.c b/lib/tst_clone.c
> index 296cd40ac0a0..d7f005a2d2a5 100644
> --- a/lib/tst_clone.c
> +++ b/lib/tst_clone.c
> @@ -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;
> }
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [LTP] [PATCH v2] tst_clone: Fix child detection on sparc
2026-09-29 14:21 ` [LTP] [PATCH v2] " Petr Vorel
@ 2026-09-30 12:16 ` Anders Roxell
2026-09-30 13:53 ` Petr Vorel
0 siblings, 1 reply; 7+ messages in thread
From: Anders Roxell @ 2026-09-30 12:16 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
On Tue, 29 Sept 2026 at 16:22, Petr Vorel <pvorel@suse.cz> wrote:
>
> Hi Anders,
>
> > 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...
>
>
> 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")
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.
>
> 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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [LTP] [PATCH v2] tst_clone: Fix child detection on sparc
2026-09-30 12:16 ` Anders Roxell
@ 2026-09-30 13:53 ` Petr Vorel
2026-09-30 19:42 ` Anders Roxell
0 siblings, 1 reply; 7+ messages in thread
From: Petr Vorel @ 2026-09-30 13:53 UTC (permalink / raw)
To: Anders Roxell; +Cc: ltp
Hi Anders,
> On Tue, 29 Sept 2026 at 16:22, Petr Vorel <pvorel@suse.cz> wrote:
> > Hi Anders,
> > > 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.
> > 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")
> 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.
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=*
> > 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
> Cheers,
> Anders
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [LTP] [PATCH v2] tst_clone: Fix child detection on sparc
2026-09-30 13:53 ` Petr Vorel
@ 2026-09-30 19:42 ` Anders Roxell
0 siblings, 0 replies; 7+ messages in thread
From: Anders Roxell @ 2026-09-30 19:42 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
On Wed, 30 Sept 2026 at 15:53, Petr Vorel <pvorel@suse.cz> wrote:
>
> Hi Anders,
>
> > On Tue, 29 Sept 2026 at 16:22, Petr Vorel <pvorel@suse.cz> wrote:
>
> > > Hi Anders,
>
> > > > 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.
>
>
>
> > > 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")
>
> > 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.
>
> 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=*
>
> > > 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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 7+ messages in thread
* [LTP] [PATCH] tst_clone: Fix child detection on sparc
@ 2026-09-28 21:27 Anders Roxell
2026-09-28 23:51 ` [LTP] " linuxtestproject.agent
0 siblings, 1 reply; 7+ messages in thread
From: Anders Roxell @ 2026-09-28 21:27 UTC (permalink / raw)
To: ltp
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.
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
---
lib/tst_clone.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/lib/tst_clone.c b/lib/tst_clone.c
index 296cd40ac0a0..2fdd9e163717 100644
--- a/lib/tst_clone.c
+++ b/lib/tst_clone.c
@@ -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 = getpid();
+#endif
tst_flush();
@@ -31,7 +34,7 @@ pid_t tst_clone(const struct tst_clone_args *tst_args)
return -1;
if (pid != -1)
- return pid;
+ goto out;
flags = args.exit_signal | args.flags;
@@ -44,5 +47,11 @@ pid_t tst_clone(const struct tst_clone_args *tst_args)
if (pid == -1)
return -2;
+out:
+#ifdef __sparc__
+ if (getpid() != parent_pid)
+ pid = 0;
+#endif
+
return pid;
}
--
2.53.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [LTP] tst_clone: Fix child detection on sparc
2026-09-28 21:27 [LTP] [PATCH] " Anders Roxell
@ 2026-09-28 23:51 ` linuxtestproject.agent
0 siblings, 0 replies; 7+ messages in thread
From: linuxtestproject.agent @ 2026-09-28 23:51 UTC (permalink / raw)
To: Anders Roxell; +Cc: ltp
Hi Anders,
On Mon Sep 28 23:27:13 2026 +0200, Anders Roxell <anders.roxell@linaro.org> wrote:
> tst_clone: Fix child detection on sparc
> +#ifdef __sparc__
> + pid_t parent_pid = getpid();
> +#endif
Use tst_getpid() instead of getpid(). glibc versions prior to 2.25 cache
getpid(), which returns a stale PID if tst_clone() is called from a child
process created by a direct clone syscall.
> +out:
> +#ifdef __sparc__
> + if (getpid() != parent_pid)
> + pid = 0;
> +#endif
Calling getpid() in the child returns the cached parent PID on glibc < 2.25
because the raw clone syscall bypasses glibc, causing child detection to fail.
Use if (pid == parent_pid) pid = 0; instead, or use tst_getpid().
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-09-30 19:42 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-29 8:42 [LTP] [PATCH v2] tst_clone: Fix child detection on sparc Anders Roxell
2026-09-29 11:16 ` [LTP] " linuxtestproject.agent
2026-09-29 14:21 ` [LTP] [PATCH v2] " Petr Vorel
2026-09-30 12:16 ` Anders Roxell
2026-09-30 13:53 ` Petr Vorel
2026-09-30 19:42 ` Anders Roxell
-- strict thread matches above, loose matches on Subject: below --
2026-09-28 21:27 [LTP] [PATCH] " Anders Roxell
2026-09-28 23:51 ` [LTP] " linuxtestproject.agent
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.