From nobody Thu Sep 24 14:26:06 2026 Received: from mail-oa2-f12.google.com (mail-oa2-f12.google.com [74.125.231.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07DF457EDA7 for ; Wed, 23 Sep 2026 20:56:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.231.76 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790196989; cv=none; b=YNIn5aUvy+Wk4FHs0HATFE9ZAbW93lMafV8m4T6UPyrazF7zoli7HIDUNt6bGtrO9QleccHTqhrstzchgyNps1xuaJSh2XvcAHW55NjYiCr9nUOSrujaPF800G5HlNTW6Jql5LP8v7CIDhQ4olx8uar6nmWxrZs5+NIR7+8e6xc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790196989; c=relaxed/simple; bh=KoXj6lDz/zEBfEDePNaRooRZZ1oXmLqh7Vi2llPxlvI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oiPkIAWsCvLD5qQtB3zlLlIZN0wTFVBUOuIM5e+2goUWUFBaBxmDcHeTpFPhCudkDaCSfRrP+Nmd1RMMz2moOJxAAPJQdTV9CXNnmkCsFQixVetD/Gd8pFViynpqTFhYiKRwqsTsYkm0gCOdQ3ubYgJ3uQC1jM7J/u61OylR6BA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fqwLqlw6; arc=none smtp.client-ip=74.125.231.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fqwLqlw6" Received: by mail-oa2-f12.google.com with SMTP id 586e51a60fabf-46dae65dc5cso714321fac.1 for ; Wed, 23 Sep 2026 13:56:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790196986; x=1790801786; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=bEO8AN5y0124ULpZTldBK8ZJ7R24pfDL+mJFB6JEsyI=; b=fqwLqlw6d03aME8cU8AmS5XrMcGsj5tF/xzaSYCrAyY5H2efou4ii7em5vceKC2bFT qsm6ag6iTvXLPKPf+EfX87N60/w6hwi/47psV36isZegpRgZlW4YlNb+JymVcG9uW2L8 +BIH98YrZ2DmA8SflRP28V23sHBApbPXXov3PrU6v+VlVbBjXLHFhB+AP1ApU5WDBdMm 0umZJmqEYgvCxGdKaxtMEu20mNWotX69GPc9pI4p8PVPJoyORZ6r3KeNG0rL4RlUYJzj wsIMFV+GeEUO4Uw0lQZo8K1DG02jF4KFdw2fuXhrAWPJLIGHLYXFeiSKRkYIU8tyoyHI XR8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790196986; x=1790801786; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=bEO8AN5y0124ULpZTldBK8ZJ7R24pfDL+mJFB6JEsyI=; b=DgHYeBfPl3WutffXOo5HEClTW0ODtsu2fAItJBUbXdu8IdUgaFwBDxA4NoNBeZb3sF p6Z5MUQ/X0yGO29ZpjfGPTx9luK5BKB7CHfiPUlO28jxPH/h8Jna30mnMJGeIyuPyURw Fkq1/nO87c6wO9vOxRysBkuVxlWio1VT38vjir/jqVKPLjefz7KqlKVGlg6HjvokdjCf K8fzrhB/r3i48amlmR6XZBYTIiVbqpQAg4ROBiAow0Bz9sbMhtAiXHoyJj71yGI6lEdG PE+bR4XSkdPOCZfFluLPz4rQ2SSAcbAcqn3xfYJ4UhAv6FOxWYPA1d/ZDxpWijE3Gi0h 3e1A== X-Forwarded-Encrypted: i=1; AKwUvBxVqPrLKgdR59E39VnQr1COkWeOZbVCMJm2d3jcRH0ibKQQnBwBCKhKMGxogLJWX7n4eGimeeDUdPBEyDk=@vger.kernel.org X-Gm-Message-State: AFuF++krsBXFAYGcxfE1aQJ6/+zJG29SbLmlTk3MTdO3u0LXYoaLEkHL ja0b2ZW9NTmzJGkn5LbcbsDpnMFGvDr93HDPKthb03K4CZ1REsnOsFcJMjUIHCf1 X-Gm-Gg: AYBFou0r2jeRH6Vi7vgssWhKTMmaVHZt543QmkiG5t/Wk38ZcS1A8xduXUTBieYv3mX 9N4ql5UeKX6QZv8SWl2p9BHaHSUSUttAKGD+AdMwSUwAHVpFzwqW+Rxa8EP23rmVi/lJ+FEq7JF ybA44bG4JH7JZAc1KNqCNLBaTT6BoR1XABRWeebVMm900IxYY73hKlDemFt75OtptKrnVIAsmzk aOOI9Sb78gNnJdgvgrU5vCFPoJ8KuL65DQu11y7R89weoZFBR3h4DSjck2BD6d1Ah9dN0iImkbz eQe/dZ7fGr9gLT13FFjYERWyfP2cMN0lgv7ViPS8Zr4JBVkbHPPhWHY2SCYVa13rdAEhw49kbqc gT8GWz7D4lM/nplEVtPZb2Aoyxiy1jSv1wWTYAG07zmcG8xrE0004deZWnZ/udt+vgyRiQkUNGI 7tH+zjwleeDW/BNH7Xi9MUweXwRhwJEdQ6F7fJsZyr5rT8vmY4RRtUcxG0/erUOHERbIAkjyAc3 HEhp5s64X+bLp34nS1VEe3BCFohZWmIn1ulP+EA X-Received: by 2002:a05:6808:159b:b0:4d6:9293:9b53 with SMTP id 5614622812f47-4d72ef56171mr358627b6e.59.1790196985628; Wed, 23 Sep 2026 13:56:25 -0700 (PDT) Received: from archlinux.lan ([136.34.156.120]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-81603ad0f20sm4498893a34.9.2026.09.23.13.56.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2026 13:56:25 -0700 (PDT) From: Danish Khateeb To: Willy Tarreau , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Cc: Shuah Khan , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Danish Khateeb , stable@vger.kernel.org Subject: [PATCH 1/2] tools/nolibc: fix WIFSIGNALED() for status 0 Date: Wed, 23 Sep 2026 15:56:21 -0500 Message-ID: <20260923205622.1123270-2-danishkhateeb03@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260923205622.1123270-1-danishkhateeb03@gmail.com> References: <20260923205622.1123270-1-danishkhateeb03@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" WIFSIGNALED() needs the subtraction to wrap around for status 0, so that only 1 to 0xff, a terminating signal with or without the core dump flag, pass the check. But status is an int, and 0 - 1 is -1, which is less than 0xff. A child that exits with 0 is therefore reported as both exited and killed, and a caller that tests WIFSIGNALED() first sees "killed by signal 0". Make the subtraction unsigned, as musl does in the same macro. Fixes: 8c934d4822c7 ("tools/nolibc: add helpers for wait() signal exits") Cc: stable@vger.kernel.org # v6.4+ Assisted-by: LLM Signed-off-by: Danish Khateeb --- tools/include/nolibc/types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h index 8f3cb18df7f1..4373bd8a5b5f 100644 --- a/tools/include/nolibc/types.h +++ b/tools/include/nolibc/types.h @@ -119,7 +119,7 @@ struct timeval { #define WEXITSTATUS(status) (((status) & 0xff00) >> 8) #define WIFEXITED(status) (((status) & 0x7f) =3D=3D 0) #define WTERMSIG(status) ((status) & 0x7f) -#define WIFSIGNALED(status) ((status) - 1 < 0xff) +#define WIFSIGNALED(status) ((status) - 1U < 0xff) =20 /* standard exit() codes */ #define EXIT_SUCCESS 0 --=20 2.55.0 From nobody Thu Sep 24 14:26:06 2026 Received: from mail-oi2-f12.google.com (mail-oi2-f12.google.com [74.125.231.204]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E688857C72B for ; Wed, 23 Sep 2026 20:56:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.231.204 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790196989; cv=none; b=iH4mFadk4wKM/pWJKFtMoN7EO/S2i8kE4Alq7rHiWPHAYPS8XYvpuEBa45/0BCu6cVsYxCe3fmBumXUUdhaOdwny6dSflYeeIe4lT0+v57wgPoWjvve7SOHU1cVtHVqn0DnFlvdzZX/Q0swlQKZFXbNsNOrx0Jy6xELp3mD9GH4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790196989; c=relaxed/simple; bh=wpHW3AGsvTtcq9qNGtfCUgb1bpdoHKJpgQc9YAeigZE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ns/P4DD4Z7rMVhkzwvZnowbBZbXrBaWcNJHxQmguAtWZWA8jFUYT5/tnrj3PHNaEXS65yEe0PcOF2tS79Fpl7hx8y1Ebxk6r43y2iVSwv4LbBRuWlCxyxJ/hxDcx478YE5hu2KIIs93NfaJYwfXs9bIRHrmTxeFcFR+MWJzezM8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nkOw+Bzm; arc=none smtp.client-ip=74.125.231.204 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nkOw+Bzm" Received: by mail-oi2-f12.google.com with SMTP id 46e09a7af769-80a6fbf797dso376752a34.0 for ; Wed, 23 Sep 2026 13:56:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790196986; x=1790801786; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=fG6cE21OsL9ueGhX4z1Iih/4qzjC2Z1wROlNZIqAoKY=; b=nkOw+Bzm3eFVu2UFtvqFdJDr8dO1dGC3Fo+yfUY5Q8MMOmEXXMxlVQAhwFMdLQlXnl 8TYlnQeQ18VOVcbW4apdpF3twdf3sFCOflyd8DI2U3V7h4ylO3048EqXnBsIn1a/wpsz W3gQkFMv8j/Pqp4HreKul6g/ENUWGgpfy+WUsJtkk17bbyKY0XNUX8IKqwTRshcvwdWK y6hvh+iGFYkdjqClJiG1R/Tf4jJBT96FKTl463PBVUvxR0TVvhN6kkOo8F255/EcsDkR BQBpq8NWHzkOBTBwdTjrY68VuwPpovhgDqIxbaUA/VIGGIm2cfnSvvkkLI7h1kYUmmAB gfbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790196986; x=1790801786; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=fG6cE21OsL9ueGhX4z1Iih/4qzjC2Z1wROlNZIqAoKY=; b=bQhsEIsqjhe6qvVQZhK5GRWv9HjXcXC7opKtL6JMZL+9snMuh0W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DTSK2UKIdyKJxBlb8NF2d+cA== X-Received: by 2002:a05:6830:4129:b0:7f9:555:1df4 with SMTP id 46e09a7af769-81783485e5cmr448186a34.16.1790196986532; Wed, 23 Sep 2026 13:56:26 -0700 (PDT) Received: from archlinux.lan ([136.34.156.120]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-81603ad0f20sm4498893a34.9.2026.09.23.13.56.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2026 13:56:26 -0700 (PDT) From: Danish Khateeb To: Willy Tarreau , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Cc: Shuah Khan , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Danish Khateeb Subject: [PATCH 2/2] selftests/nolibc: add tests for the wait status macros Date: Wed, 23 Sep 2026 15:56:22 -0500 Message-ID: <20260923205622.1123270-3-danishkhateeb03@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260923205622.1123270-1-danishkhateeb03@gmail.com> References: <20260923205622.1123270-1-danishkhateeb03@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Until the previous commit, WIFSIGNALED() was true for status 0, which is what waitpid() reports for a child that exits with 0. nolibc-test did not notice, because its only use of WIFSIGNALED(), in the abort test, also checks WTERMSIG(). Add tests for WEXITSTATUS(), WIFEXITED(), WIFSIGNALED() and WTERMSIG(), on the statuses the kernel reports for an exit with 0 or 0x12, a kill by SIGKILL, a SIGSEGV with the core dump flag, and a stop by SIGSTOP. Assisted-by: LLM Signed-off-by: Danish Khateeb --- tools/testing/selftests/nolibc/nolibc-test.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/s= elftests/nolibc/nolibc-test.c index f62183a46205..8985aa1ba96a 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -2038,6 +2038,14 @@ int run_stdlib(int min, int max) CASE_TEST(htole32); EXPECT_EQ(1, htole32(is_le ? 0x01234= 567 : 0x67452301), 0x01234567); break; CASE_TEST(htobe64); EXPECT_EQ(1, htobe64(is_le ? 0x01234= 56789000000 : 0x8967452301), 0x8967452301); break; CASE_TEST(htole64); EXPECT_EQ(1, htole64(is_le ? 0x01234= 56789 : 0x8967452301000000), 0x0123456789); break; + CASE_TEST(wexitstatus); EXPECT_EQ(1, WEXITSTATUS(0x1200), 0x= 12); break; + CASE_TEST(wifexited_exit0); EXPECT_NZ(1, WIFEXITED(0)); break; + CASE_TEST(wifexited_signal); EXPECT_ZR(1, WIFEXITED(SIGKILL)); br= eak; + CASE_TEST(wifsignaled_exit0); EXPECT_ZR(1, WIFSIGNALED(0)); break; + CASE_TEST(wifsignaled_exit); EXPECT_ZR(1, WIFSIGNALED(0x1200)); b= reak; + CASE_TEST(wifsignaled_signal); EXPECT_NZ(1, WIFSIGNALED(SIGKILL)); = break; + CASE_TEST(wifsignaled_stopped); EXPECT_ZR(1, WIFSIGNALED((SIGSTOP <<= 8) | 0x7f)); break; + CASE_TEST(wtermsig_core); EXPECT_EQ(1, WTERMSIG(0x80 | SIGSEGV= ), SIGSEGV); break; =20 case __LINE__: return ret; /* must be last */ --=20 2.55.0