From patchwork Mon Nov 11 16:18:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13870952 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E3FA1A254F; Mon, 11 Nov 2024 16:19:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731341953; cv=none; b=bvfUDVezEidNU9EULlhBmQdHIaaDurgoCiIAV9q2uRbKpaKutF+MLsr/GkpMnQQ+R9itLiwxkRTSMYc3qPtxQ8ciYbrA0EYCFCYPE/PH2ahJr+G6ZA0qgA8oNv86at+FPvROfHZlJNESHILlSFi4H/QXZnw8FqGB4BTivGI7Kxg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731341953; c=relaxed/simple; bh=g4YRupDmS6rsFE+fXj4fCiJaZnhgWz5kCy7tqLUbGPc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NDVAeg6rwC58NlSgKjldWKoNbsChJq0sv8VIp1UY5R74sxIBO7KfG+D1nmvHogGZqSkRHP/Md6Ugu+A1Tdug4/4I5j5a1XwVN8qk2bmWzShZPwabpJll1Zr+z53p51O8HQdayEagIIbSkJEWq81b/atIIb9xEU5KDn1qgNlVTWY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=m+BwE4Nn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="m+BwE4Nn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 388D7C4CED5; Mon, 11 Nov 2024 16:19:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731341952; bh=g4YRupDmS6rsFE+fXj4fCiJaZnhgWz5kCy7tqLUbGPc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=m+BwE4NnKbLT5R3oGmmZtiRrc+XhPt8Nmq3mDWP7k7VgCQRhSg5Ufoj/wAKAjHhPd vPhpkrU3GdEQJkRY7vwaKXuz5jO+OBD7ClUtV90r37ccrrB5itCWDLynhxDp0GeNI6 yFktqayQrOsOKjJbd9/M0t/u6IEwRtrgCwg71pE/Xtopf6mK0dlvrZUH2VudV5qUFk /TQFR+WXSL0r8f9IN2yPgHZAPNocGahZ0KGufVvj9fcFuejnOJA96IvyqIcebYVAHA Cl3ubG/YEWueRf1YOj97/Z5IJc8nKmfq/wjGrl6M4o8Pi6ffIpNDQB0P7lwe/1c+7U xbtyRPoK8SYwQ== From: Mark Brown Date: Mon, 11 Nov 2024 16:18:55 +0000 Subject: [PATCH 1/2] kselftest/arm64: Don't leak pipe fds in pac.exec_sign_all() Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241111-arm64-pac-test-collisions-v1-1-171875f37e44@kernel.org> References: <20241111-arm64-pac-test-collisions-v1-0-171875f37e44@kernel.org> In-Reply-To: <20241111-arm64-pac-test-collisions-v1-0-171875f37e44@kernel.org> To: Catalin Marinas , Will Deacon , Shuah Khan Cc: linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Brown X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=923; i=broonie@kernel.org; h=from:subject:message-id; bh=g4YRupDmS6rsFE+fXj4fCiJaZnhgWz5kCy7tqLUbGPc=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBnMi57hYbOZoCypxxS5DdntS9d1pQSZA5sNIhza 3ZAtKIvlWGJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZzIuewAKCRAk1otyXVSH 0Ct6B/9GaplZ+Wh3jbdMs+/axyR5eFAUQoGrgCp4yDH16vLv6X6MxioUbodUygXW9QAlaFfCISv uTKM2qH7KJvur5hsY4sGV1cmmZWNAB8jhWNVpzZ2nbjIiidg6GXYPm09Ck9KAO8mkFDSuc+eDfH p4Nynex1KCFehgEI/AYG6y0Nc6XNx83LpPqiTxHEeEe1nxS1OCdRtAzVUP2/BmFMBUxdS8RnBrx rDC+bMGrY5NrBKOfm+dbPSnnORUcDNrBHGVxYOgudxew/CKp16yVECIo1+HX7S0gskv96hAc7qH AI8O3nEP2dnlcKzTZeBTx80K4LNKdRDIH1QXvhqAsg3DG8p4 X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB The PAC exec_sign_all() test spawns some child processes, creating pipes to be stdin and stdout for the child. It cleans up most of the file descriptors that are created as part of this but neglects to clean up the parent end of the child stdin and stdout. Add the missing close() calls. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/pauth/pac.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/testing/selftests/arm64/pauth/pac.c b/tools/testing/selftests/arm64/pauth/pac.c index b743daa772f55f570a3c0a912ac0c2c403c4256a..5a07b3958fbf292b09c9d6b11b8f9db2880beeed 100644 --- a/tools/testing/selftests/arm64/pauth/pac.c +++ b/tools/testing/selftests/arm64/pauth/pac.c @@ -182,6 +182,9 @@ int exec_sign_all(struct signatures *signed_vals, size_t val) return -1; } + close(new_stdin[1]); + close(new_stdout[0]); + return 0; } From patchwork Mon Nov 11 16:18:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13870953 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C1821A2C27; Mon, 11 Nov 2024 16:19:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731341955; cv=none; b=tk/Kd0H96F4otE28wcOXWHNVOVeMskX1T8w5avrLfyZwkZctsKdS2gmW0Ge68RtoHfYMUw0uikCZw4qifeN3HtKGid23kfjGw24ikQ9N4+NTq0jTHImU/ccXVN/X6UZnkuykTnAlbhSg1K2EG+rrPlQ2a2dL+gXSVCeEE7vUCSM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731341955; c=relaxed/simple; bh=9cyh4O1U5G+quhH4mm627kHtyNUEPP2A3/N1m265/l0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lUNG5E4e2qn55mPBny+chH+92wwd6F5b0kBjsYv4NhebuFvA4B4YMR68+Q/tDxKcfRQuklOC1h6Njr5Q6RAhmhjgUFSCyEIrx3su/sJVEJe8oWcz9nuaA9V+pToBZmP3GcFceKCvxuGUmlXrPV+TgP67nUfQBL5iLtnt9XoJdJU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tpSfi6sz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tpSfi6sz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 447E2C4CECF; Mon, 11 Nov 2024 16:19:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731341954; bh=9cyh4O1U5G+quhH4mm627kHtyNUEPP2A3/N1m265/l0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tpSfi6szIGQ1/P2NbGmmPURdONHXrmQaS9FJkjZMRxZ7vbHzW9P9Hh92+qyymxFRU 1Zlq6opK8+hZXuSV6JjAtF3CHplmd0/unNlCDiMJxl5+tkDIEu2RI0gnBNzJ1N0Goz Hw6kjk+Es6SBhrqjTbt8vPCpXMA/AWxPzOZLXi86rQK/ZsZiba9Hlr+dteUU4kJ06V q7CqD6O1l/tTWzxA9HWWsas65z9EXcsJbEJI4lYrew0+276563iAO6JA43dH8yIEmx mf347ya6V6+XeJYu9wuBJeVaXDCN/FhaFNbi5Cv7q6VCpijvRBC5204OkVHLZZWiGJ UWh4W7syExE1w== From: Mark Brown Date: Mon, 11 Nov 2024 16:18:56 +0000 Subject: [PATCH 2/2] kselftest/arm64: Try harder to generate different keys during PAC tests Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241111-arm64-pac-test-collisions-v1-2-171875f37e44@kernel.org> References: <20241111-arm64-pac-test-collisions-v1-0-171875f37e44@kernel.org> In-Reply-To: <20241111-arm64-pac-test-collisions-v1-0-171875f37e44@kernel.org> To: Catalin Marinas , Will Deacon , Shuah Khan Cc: linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Brown X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=1708; i=broonie@kernel.org; h=from:subject:message-id; bh=9cyh4O1U5G+quhH4mm627kHtyNUEPP2A3/N1m265/l0=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBnMi58jgwmS4v3ef00rmDIKXGflINOqMihqygBt HmqWBC0ANOJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZzIufAAKCRAk1otyXVSH 0MxSB/9AzHa5kOicOsY4cAV412rEHAWT2qZEK1xKi3h/eENhxz0LC++OwfzN3D+SFWY8xxbmRdP FNiPlPn/9sD7F2XmUNIlczNn48rMwO5c/JIpIY48bPUklBJl/3rwFR8B33Pnsg5mkUQK1v5pljM D7tMSYDtUIPq49oH6kzc6lcqEFCHdfP9hR4prgpansGchCYkGcP43WBAz4DY71UcwFn5tX0/x6C ll3N5dAgB/OZaiuuSdB1PUnGCy9szdE1N0cg5fDSXq5m8ReqyHAxlPdMFtChsnMJMY/rr3Tw7Do 91GDxAt+g9NgTmRnXykAjANxDYmOTTHxBzVVuuoZGnT+zdrM X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB We very intermittently see failures in the single_thread_different_keys PAC test. As noted in the comment in the test the PAC field can be quite narrow so there is a chance of collisions even with different keys with a chance of 5% for 7 bit keys, and the potential for narrower keys. The test tries to avoid this by running repeatedly, but only tries 10 times which even with a 5% chance of collisions isn't enough. Increase the number of times we attempt to look for collisions by a factor of 100, this also affects other tests which are following a similar pattern with running the test repeatedly and either don't care like with pac_instruction_not_nop or potentially have the same issue like exec_sign_all. The PAC tests are very fast, running in a second or two even in emulation, so the 100x increased cost is mildly irritating but not a huge issue. The bulk of the overhead is in the exec_sign_all test which does a fork() and exec() per iteration. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/pauth/pac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/arm64/pauth/pac.c b/tools/testing/selftests/arm64/pauth/pac.c index 5a07b3958fbf292b09c9d6b11b8f9db2880beeed..6d21b2fc758d80d0cd7d0db2859de3b308522cb4 100644 --- a/tools/testing/selftests/arm64/pauth/pac.c +++ b/tools/testing/selftests/arm64/pauth/pac.c @@ -13,7 +13,7 @@ #include "../../kselftest_harness.h" #include "helper.h" -#define PAC_COLLISION_ATTEMPTS 10 +#define PAC_COLLISION_ATTEMPTS 1000 /* * The kernel sets TBID by default. So bits 55 and above should remain * untouched no matter what.