Re: [PATCH v2] selftests/mm: handle child status safely in khugepaged

From: Kiryl Shutsemau

Date: Tue Nov 03 2026 - 05:03:41 EST


On Mon, Nov 02, 2026 at 10:21:30PM +0330, Muhammad Mahdi Amirpour wrote:
> collapse_fork(), collapse_fork_compound() and
> collapse_max_ptes_shared() take the child result from
> WEXITSTATUS() without checking WIFEXITED(). For a child
> killed by a signal WEXITSTATUS() is 0, which is KSFT_PASS:
> the parent runs its own checks and the test reports ok even
> though the child crashed.
>
> Fail the test when the child did not exit normally, and print
> the signal that killed it. Also fail when fork() fails,
> instead of reading an uninitialised status.
>
> Use get_child_status() in all four fork tests, and use
> wait_for_child() to handle fork() and waitpid() in the
> three blocking-wait tests.
>
> Fixes: bd212a7dbdb1 ("kselftest: mm: return fail when child test result is fail in khugepaged")
> Signed-off-by: Muhammad Mahdi Amirpour <ampr.mhd@xxxxxxxxx>

Reviewed-by: Kiryl Shutsemau (Meta) <kas@xxxxxxxxxx>

--
Kiryl Shutsemau / Kirill A. Shutemov