From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 686C4606A327 for ; Mon, 2 Nov 2026 11:11:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BFAwBKbw Received: by kanga.kvack.org (Postfix) id 8938C6B00EF; Mon, 2 Nov 2026 06:11:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8436B6B05B3; Mon, 2 Nov 2026 06:11:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 758786B05B4; Mon, 2 Nov 2026 06:11:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 4C1816B00EF for ; Mon, 2 Nov 2026 06:11:55 -0500 (EST) Received: from smtpin23.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay10.hostedemail.com (Postfix) with ESMTP id BA936C0CAA for ; Mon, 2 Nov 2026 11:11:54 +0000 (UTC) X-FDA: 85389914148.23.D093817 Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf15.hostedemail.com (Postfix) with ESMTP id B4559A0005 for ; Mon, 2 Nov 2026 11:11:52 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=BFAwBKbw; spf=pass (imf15.hostedemail.com: domain of kas@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=kas@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1793617912; b=I9GktilIVQROzuZqZH+GcH5P9GFsYPukUHnFdgeB7toKeQ5vHl1sk0YQwQ/8VD177IhgsH S3D5fnxlq5vYXAkvna2YDnHPDwMhYraSBns7JXPUSH2RTenE0MMMXufyTu8uI30eNSa4eY CvKYGot7oU2We2mNvHb6MmBcsyS149Y= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=BFAwBKbw; spf=pass (imf15.hostedemail.com: domain of kas@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=kas@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1793617912; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=tQierFXrtdBxsv90Wvr5GLl7ZIg6QP9xO7JbeTEr+Xw=; b=2FXoNBuJ1pbedJyMq9sLsF+nl0CxE2b93SjmkkdijxMYgfpcyZZYvxGFumYNHTSkRVRUej 2/tRQLMNfpiDbmkRsqXjeA/p4YDcgWtkoCC/ot53IYi77eAdOcJgpmHxa9lA+dGuOka3M3 K98x01hx0Avg/WTm5oizC4MufzXdx/Q= Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 13AA443A55; Mon, 2 Nov 2026 11:11:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BFD31F00A1D; Mon, 2 Nov 2026 11:11:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793617911; bh=tQierFXrtdBxsv90Wvr5GLl7ZIg6QP9xO7JbeTEr+Xw=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=BFAwBKbwGTlz0Mn4enaQSgX8dTUg8pp7VJO7rtcJP9h8ODPemnCLR2eNJMPd38/pI o3ypw45HPEIawjkPWwjC7vpedMr/rhrB556WMYHevVOUGn2DSZqM3XyTdvy9xaafGs d+/SQtsBFnDZzf2np20BbCeTeaBHQValygZuXcE0jqxRoGvyrwoaqpftP2ml8O9MU/ 0HATVm85QPYzXDyRzMncrpNRNw91wJIj2+fA+lGi97MgKvO2KPKjh0YegXTGOM4QlH zeFv0Pn0ofxsDPqODF/sKmuouK59j9ZhHiStG+T3gwfGMbUvELpg99pmqo5mqiQtDr OUMAd/jT7HUPw== Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfauth.ams.internal (Postfix) with ESMTP id 7A9A5198003A; Mon, 2 Nov 2026 06:11:47 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Mon, 02 Nov 2026 06:11:48 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEK1+02a4zp88u4Tj7j1xR++eJHRcOeZsjArkkCuSqZTrG8QN3et3PJ5Yhpp8JgOy tSOq45tZMVN3zAAAPAjPYdiYp4+PM3U5Ilw/Pvtw7Ftx3GpE/TzxD++/NwBVjZwRlAofk7 pgG6siSuYHP+MNHzb/HomkI1yVPL+oawmIR9pZi9gWP0otMusCPkQ232d0l/98yOZyjaO8 HCSiHgy4dMxZTYLPkGusk7UMm8k5Wt2nCqc9q31PZ/V6ihq/eUyqlvPexGPv0hMZ1E+YGx sYu7Zoyhe+tajg6s4E3RIIUMBh/H9WcY7aPjBvRgJ+f/iJ4hRlMvNuh74OMKCJAds2lDaw LuHKwEP2phflf9q4kE1iwNJtNjh7Mpe/RdmadkWMkn6nU+Wb0hAdhkVdLAVbDQIOIPTSkB lKxK3Thu7rQlxOUPlh1jbY0wFMZNQpWVLZO8yoh/UobjpsE+YBH8Gm+QCT+dRaiS+FcvdP zkcv0QSHR1X6YeFjlgRImzCdCwdeFLmZAWzMlz59bkHguqNYREG58mLEZ2yCI5P0Fx7ld7 0oN+qmyXHVQTlWvextupVYS/txj5aUgCi95wcxQcH7qyY2K7M8bHoBgwfMTdb5Rjozx/jc qNE9yUW3AJqwqBNA5BKKdk/cxyRYVf8/3eXZjLEoHkP9zWRSitoidzhZiOeA X-ME-Proxy: Feedback-ID: i10464835:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 2 Nov 2026 06:11:46 -0500 (EST) Date: Mon, 2 Nov 2026 11:11:45 +0000 From: Kiryl Shutsemau To: Muhammad Mahdi Amirpour Cc: akpm@linux-foundation.org, david@kernel.org, shuah@kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, yeoreum.yun@arm.com, ziy@nvidia.com Subject: Re: [PATCH] selftests/mm: handle child status safely in khugepaged Message-ID: References: <20261030215841.229969-1-ampr.mhd@gmail.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261030215841.229969-1-ampr.mhd@gmail.com> X-Stat-Signature: nfq3uumuz5ahb9q8b6m9xrwsp7y7u949 X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: B4559A0005 X-Rspam-User: X-HE-Tag: 1793617912-265953 X-HE-Meta: U2FsdGVkX18P0H1EB2hOQYBi6DHaGRzJQxV0al6nvexgCY/Ql6nWwmj79jjIwwyRGrAkap59/OU82ktP79pr80bNO9/roCfsYXRciQFJDKYe1lNokcWek5Lhmo26QYZ5xyetxgciqyYiSFKjWMXITYGtJatgyxcc+LQ+p4sQQcULxUWQJIHNaZg1ZFM82tM1qM5kTbzNbVR/IN/VKmXfu0mEbaRPrc/51pDSk7p+YkdQx9TCz/Jd5Z7ApZ/ZS6X/YDT1keMMgNhgrwCraWUnO0ZNqjch3Sv0Z8esW5k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X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Sat, Oct 31, 2026 at 01:28:41AM +0330, Muhammad Mahdi Amirpour wrote: > The khugepaged selftest reports child exit status through a shared > variable without checking that the child actually ran to completion. > When fork() fails or the child is killed by a signal, the status is > undefined and the test can report a false pass. > > Capture the waitpid() result and distinguish normal exit, signal > death, and fork failure before interpreting the status. Report the > child's actual termination cause in the TAP output so failures are > visible rather than silently masked. The bug is real: for a child killed by a signal WEXITSTATUS() is 0, which is KSFT_PASS. The parent goes on with its own checks and reports ok, so a child that crashes in the middle of the collapse goes unnoticed. The description doesn't match it, though. The status comes from wait(), not from a shared variable. For a killed child it is not undefined, it is a pass. And the patch doesn't report the termination cause anywhere. Maybe something like: collapse_fork(), collapse_fork_compound() and collapse_max_ptes_shared() take the child's 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 it when fork() fails, instead of reading an uninitialised status. It came with bd212a7dbdb1 ("kselftest: mm: return fail when child test result is fail in khugepaged"), so a Fixes: tag would be good. > + exit_status = WIFEXITED(wstatus) ? WEXITSTATUS(wstatus) : KSFT_FAIL; A child that dies in the middle of a step leaves the progress line open, and the "not ok" line ends up on the "# ..." comment. Could you call fail() with the signal number here? > + while (waitpid(pid, &wstatus, 0) == -1) { > + if (errno == EINTR) > + continue; > + > + fail("waitpid() failed"); > + goto out; > + } The test installs no signal handlers, so waitpid() cannot return EINTR, and it has no other way to fail for our own child. A plain waitpid() is enough. The same check is now open-coded three times, four with collapse_fork_cow_race(). A helper that takes wstatus, prints the signal and returns the KSFT status would cover all of them. -- Kiryl Shutsemau / Kirill A. Shutemov