From patchwork Thu Jul 13 14:33:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksa Sarai X-Patchwork-Id: 13312300 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7EEBBC001DD for ; Thu, 13 Jul 2023 14:34:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1D9F990002F; Thu, 13 Jul 2023 10:34:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1896390001C; Thu, 13 Jul 2023 10:34:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0521690002F; Thu, 13 Jul 2023 10:34:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id E9E7690001C for ; Thu, 13 Jul 2023 10:34:57 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B6F6CC0236 for ; Thu, 13 Jul 2023 14:34:57 +0000 (UTC) X-FDA: 81006835434.28.476CD31 Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [80.241.56.161]) by imf21.hostedemail.com (Postfix) with ESMTP id 58C0E1C000A for ; Thu, 13 Jul 2023 14:34:55 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=cyphar.com header.s=MBO0001 header.b=oUPbMSvF; dmarc=pass (policy=reject) header.from=cyphar.com; spf=pass (imf21.hostedemail.com: domain of cyphar@cyphar.com designates 80.241.56.161 as permitted sender) smtp.mailfrom=cyphar@cyphar.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689258895; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=AjkT2Rw0tr8TGJD0iIqzpuuYdLQQeUx5R46ODfk76ks=; b=aOwz+NO1JvXOJy9UDD0VZ8hsVKdn8mA9hAxfuCCrXTLiNYUqTZx9KjoVasyJtvO/8ckUcy VruvcxCQGNRVPy7UINLZuXTvq/4S8DTE0fzfDc/ibXdnzfGmmsd7QiCWC5XcyXWntBF0GT GpuGJv4WSrLW/ts5n0a6Hf2mTK6OgFg= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=cyphar.com header.s=MBO0001 header.b=oUPbMSvF; dmarc=pass (policy=reject) header.from=cyphar.com; spf=pass (imf21.hostedemail.com: domain of cyphar@cyphar.com designates 80.241.56.161 as permitted sender) smtp.mailfrom=cyphar@cyphar.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689258895; a=rsa-sha256; cv=none; b=NLiJQt3nhLpDFr8XGDzK0F7v+R3Y+RCjomJsbDufLPLCKbigdFqx1YDdANkT0thbZ2uGRz x2fsfGn3z2RASbln0dkNy6dnoFapOQyTAWEg/QKBd18a/iJjyBYCNecJTqvdTdNIOy+1U5 FxXBQsZBg8Nb1GbG4vvsK2rpgUdmUgs= Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4R1xvv49w8z9smK; Thu, 13 Jul 2023 16:34:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cyphar.com; s=MBO0001; t=1689258891; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AjkT2Rw0tr8TGJD0iIqzpuuYdLQQeUx5R46ODfk76ks=; b=oUPbMSvFRXiwqcHE7ijt/I2Po5hVe412fH7+Zw7UUG7G1C9CpYODK0GqEDq3rt0TFrkkhL 1tNmFOUhIxW+8niTHneU0GlIQIKTb6E/qvqpI4k2QGWSPUcblzv8Kr+3MQujKeJeipq92o fyUVU28INwU+8/j7kGpG9X88cGqLp//9GbxWyx0E8JzQ83j5jLqKPC2JSe0dm8W4DkpVib qOwiJzm6/m2A2CIHNt5W/m2DHigJTLnOhqLukSiyYW7RmmbCp91YhXYJTYRZLlvzdJKTiJ yz60SgIfQxO38akH874sgDryFay5VgDPdiEMraS/27HTPOqYmlXvXpc36qYndg== From: Aleksa Sarai To: Shuah Khan , Jeff Xu , Andrew Morton , Daniel Verkamp , Aleksa Sarai , Kees Cook Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 3/3] selftests: memfd: error out test process when child test fails Date: Fri, 14 Jul 2023 00:33:48 +1000 Message-ID: <20230713143406.14342-4-cyphar@cyphar.com> In-Reply-To: <20230713143406.14342-1-cyphar@cyphar.com> References: <20230713143406.14342-1-cyphar@cyphar.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 58C0E1C000A X-Stat-Signature: ptfqfkou6mu1w5u9taxi877x8srgqpxw X-Rspam-User: X-HE-Tag: 1689258895-687630 X-HE-Meta: U2FsdGVkX18oNhyOZpS4/HQ/8kJWYozVMb0cUdhwdlcsOgIxG6N/rx06JLuAI47vvAypzP37ODF1zj/biB1adOg/1AiVKFyhQTDyGOD+bSls9kDyuV979BVdiEvwmfTOwS/Z8UrWI+tKPO3u/esMuthGMZmZpux/PBD2lqVfNJM7CmiN6hKu1BN4NZ2uc/OIfe0TboR2vtwWR1Qy73IIfnY1zxcbs+zomE8u5rNU84hdIdt9nwWo5l+s311ndtTwSKDwQIn8Z5ah4Jt7Uedwkh0fbz/lmIH/HvSYBfVzQZ/+63YP/rrqhId0+NDLAYtN53ePGmcV9HNF4iiJeYsW9gIMuBl+cUqfDT35Kf+A2mSMcW5UDgLlqhnx9WoI37pmZxHWjei+6ZuDauvjagmJfPQH4qZTjYcZKgp1hIblaAsKrMyuZBah++aK52VqGeHqMHomZg4aaH24YsXYX8iN33NyH7gegwNg0b9lj72pxSjtKZ5zzTZIkWQxEOtauEUkNEjaOWR+/HJ7WamWIoqRo5QB+IVv6jlDUCwVjWCyzCtw102OX85GgBdfISlP8a8VZQ4OcMCFsoRQZbaAVLHL499jisWDtcdsI/crDS7NvhlHGKm3RRWo3Cv9kwzHEca06MLfrD45SW4Ci7vrYblawdrNjJABctmvfS8s1jF1Tr1l88Pmwwsw6/0bhq2xdn6KzfVbBMCa7YAY//VXuBMs/JymnVKg7yAyAW5GbsjId8kY19FJM7fs9aEo3ZX1pK3w6azqeYF/kvGoRIWPwhcWGu5qZfYt98hm6a3u90LxOTgIs7OzneLFmDuiT7eDgtnJo+hgZhpP3WU+a9bWmOrAvqLZH6F3UzBjTzsSLN8B5pPjiujTZJKvHmylws0YGz5xWvB79jKAr/JLaMMHuGdG9ccX+TGlk5p7X6C/Fkhx8fUMkUkALoYYL9Pvjgk/0d7VzUz4K6MVBgkGueiK8wC MT81S54X /Pbm/hBzGmo+2UmBxe1S9KLYwUq2010DopWfTlNOp2w7bU27iCc+e15zjjml7C8awBHec/EYr9VrL3mjJwlMZ8viJZzjzFJWk9gAzMIwI/EGqC3F2GnSahzy+0VOpfw9DUir2PXOLxuuytoHNRo4+pFCQd3lZRi+n1Dt4JVsNDQEWf7c1FmYbpd1clEJgKx3YM0uzXN+7EoGjE9WO/LsOr2fCfg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Before this change, a test runner using this self test would see a return code of 0 when the tests using a child process (namely the MFD_NOEXEC_SEAL and MFD_EXEC tests) failed, masking test failures. Fixes: 11f75a01448f ("selftests/memfd: add tests for MFD_NOEXEC_SEAL MFD_EXEC") Signed-off-by: Aleksa Sarai Signed-off-by: Jeff Xu Reviewed-by: Jeff Xu --- tools/testing/selftests/memfd/memfd_test.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c index d8342989c547..8b7390ad81d1 100644 --- a/tools/testing/selftests/memfd/memfd_test.c +++ b/tools/testing/selftests/memfd/memfd_test.c @@ -1219,7 +1219,24 @@ static pid_t spawn_newpid_thread(unsigned int flags, int (*fn)(void *)) static void join_newpid_thread(pid_t pid) { - waitpid(pid, NULL, 0); + int wstatus; + + if (waitpid(pid, &wstatus, 0) < 0) { + printf("newpid thread: waitpid() failed: %m\n"); + abort(); + } + + if (WIFEXITED(wstatus) && WEXITSTATUS(wstatus) != 0) { + printf("newpid thread: exited with non-zero error code %d\n", + WEXITSTATUS(wstatus)); + abort(); + } + + if (WIFSIGNALED(wstatus)) { + printf("newpid thread: killed by signal %d\n", + WTERMSIG(wstatus)); + abort(); + } } /*