From: Paolo Abeni <pabeni@redhat.com>
To: Jingjing Xu <xujingjing@cmss.chinamobile.com>, netdev@vger.kernel.org
Cc: linux-kselftest@vger.kernel.org, kuba@kernel.org,
edumazet@kernel.org, horms@kernel.org, shuah@kernel.org,
sdf@fomichev.me, joe@dama.to
Subject: Re: [PATCH net-next] selftests: net: py: close the wait pipe after reaping a command
Date: Mon, 30 Nov 2026 18:42:23 +0100 [thread overview]
Message-ID: <072fefa5-bc5c-4493-93ba-a17b765cf05e@redhat.com> (raw)
In-Reply-To: <20261122154827.1272059-1-xujingjing@cmss.chinamobile.com>
On 11/22/26 16:48, Jingjing Xu wrote:
> Commands started with ksft_wait keep the parent write end in ksft_term_fd.
> After communicate() reaps the child, that descriptor is still open, so
> each completed command leaks a pipe in the Python process.
>
> Close the parent end after successful communication and clear its saved
> value, before decoding output or reporting a failed child exit status.
> Leave paths where communication has not completed unchanged.
>
> Run this from tools/testing/selftests/net to repeat the supported pipe
> handshake. It prints 16 on the original helper and 0 with the fix:
>
> python3 - <<'PYCODE'
> import os
> from lib.py import bkg
> child = ["python3", "-c",
> "import os; os.write(int(os.environ['KSFT_READY_FD']), b'1');"
> "os.read(int(os.environ['KSFT_WAIT_FD']), 1)"]
> before = len(os.listdir("/proc/self/fd"))
> for _ in range(16):
> with bkg(child, ksft_wait=3): pass
> print(len(os.listdir("/proc/self/fd")) - before)
> PYCODE
>
> Found by AI-assisted inspection. Both this reproducer and a C helper
> using the existing ksft_ready()/ksft_wait() functions confirm the fix.
> Normal completion, initialization EOF and nonzero child exit each leak
> 16 descriptors before and none after; ordinary and ready-only controls
> remain clean. No kernel instrumentation or fault injection was used.
> No hardware suite was run. Timeout cleanup and a child exiting after
> readiness but before the parent's notification remain outside this fix.
>
> Fixes: 71477137994f ("selftests: drv-net: add a way to wait for a local process")
> Signed-off-by: Jingjing Xu <xujingjing@cmss.chinamobile.com>
Note that this does not deserve the fixes tag: AFAICS selftest outcome
(fail/pass) does not change, and no system resources are permanently leaked.
This is a minor cleanup, dropping the fixes.
Also please consider most substantial targets for other works (i.e.
more reviews and testing are always appreciated).
/P
next prev parent reply other threads:[~2026-11-30 17:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 15:48 [PATCH net-next] selftests: net: py: close the wait pipe after reaping a command Jingjing Xu
2026-11-30 17:42 ` Paolo Abeni [this message]
2026-11-30 17:50 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=072fefa5-bc5c-4493-93ba-a17b765cf05e@redhat.com \
--to=pabeni@redhat.com \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=joe@dama.to \
--cc=kuba@kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=xujingjing@cmss.chinamobile.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox