From: Geliang Tang <tanggeliang@kylinos.cn>
Fix the pidfd leak in kselftest_harness.h's __wait_for_test() where
childfd = syscall(__NR_pidfd_open, t->pid, 0) is never closed.
Fixes: 73a3cde97677 ("selftests: harness: Implement test timeouts through pidfd")
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
v2:
- move close() directly after poll() as Thomas suggested.
Hi,
While adding more TLS selftests for MPTCP KTLS development, a segmentation
fault occurred. Debugging revealed that the accept() failure was due to MPTCP
tests requiring over 1024 file descriptors simultaneously. I initially raised
the limit to 4096 in [1], but sashiko noted that the real issue was a pidfd
leak in kselftest_harness.h's __wait_for_test(). Hence, this fix addresses that.
Thanks,
-Geliang
[1]
https://patchwork.kernel.org/project/mptcp/patch/ced184831757eaae9e690f65d799809ed22cae28.1776469069.git.tanggeliang@kylinos.cn/
---
tools/testing/selftests/kselftest_harness.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
index 75fb016cd190..53535c188b33 100644
--- a/tools/testing/selftests/kselftest_harness.h
+++ b/tools/testing/selftests/kselftest_harness.h
@@ -996,6 +996,7 @@ static void __wait_for_test(struct __test_metadata *t)
poll_child.fd = childfd;
poll_child.events = POLLIN;
ret = poll(&poll_child, 1, t->timeout * 1000);
+ close(childfd);
if (ret == -1) {
t->exit_code = KSFT_FAIL;
fprintf(TH_LOG_STREAM,
--
2.51.0
Hi Geliang,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal (except selftest_mptcp_join): Success! ✅
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Unstable: 1 failed test(s): packetdrill_dss ⚠️
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/24659860268
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/dbc5b80ffca6
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1083220
If there are some issues, you can reproduce them using the same environment as
the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normal
For more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a
stable tests suite when executed on a public CI like here, it is possible some
reported issues are not due to your modifications. Still, do not hesitate to
help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
On Mon, Apr 20, 2026 at 05:45:28PM +0800, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> Fix the pidfd leak in kselftest_harness.h's __wait_for_test() where
> childfd = syscall(__NR_pidfd_open, t->pid, 0) is never closed.
>
> Fixes: 73a3cde97677 ("selftests: harness: Implement test timeouts through pidfd")
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
Reviewed-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
(...)
© 2016 - 2026 Red Hat, Inc.