From patchwork Mon Oct 23 13:20:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13432853 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DCC9C001E0 for ; Mon, 23 Oct 2023 13:26:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231136AbjJWN0T (ORCPT ); Mon, 23 Oct 2023 09:26:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231143AbjJWNZ0 (ORCPT ); Mon, 23 Oct 2023 09:25:26 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93C742D5E; Mon, 23 Oct 2023 06:23:52 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D6AFC433CD; Mon, 23 Oct 2023 13:23:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698067431; bh=7YKUNDbMUGXSSUeiwJ4pvwvRXBVAoVFkUMX3lRaprx0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=PWLcOKFhupYV9/bqMkM4lxQOSU/F1PNenDMqUP2nr8ywu6exhRiNukK+uIE+/Zw/c iU+iSf44SJ9vy/SBSkqAC+YxOtzhvgKTMBqc7TRBMBfZALr2dZDRuRlBDlB3EMaj/S XucKem9LvbMEQhmfOwcurZlACzDVBxyEzVI8wE6X7ANEfKHjtFde5bkUAFu+e3dbOH /HqHCchaB0EKA50WNP80jGAxcGnkzWPPKzvkPADrDoU42JXIisU5Qv9UF/x/aGgspD OAOuOjyXcNYyk8DnhXrvCRIokWRE/LP0SKZKFLnrLfcQThSCE2rzqmDL2Yrq6xTYCD EoRc0h+CkS3sg== From: Mark Brown Date: Mon, 23 Oct 2023 14:20:43 +0100 Subject: [PATCH RFC RFT 4/5] selftests/clone3: Allow tests to flag if -E2BIG is a valid error code MIME-Version: 1.0 Message-Id: <20231023-clone3-shadow-stack-v1-4-d867d0b5d4d0@kernel.org> References: <20231023-clone3-shadow-stack-v1-0-d867d0b5d4d0@kernel.org> In-Reply-To: <20231023-clone3-shadow-stack-v1-0-d867d0b5d4d0@kernel.org> To: "Rick P. Edgecombe" , Deepak Gupta , Szabolcs Nagy , "H.J. Lu" , Florian Weimer , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Christian Brauner , Shuah Khan Cc: linux-kernel@vger.kernel.org, Catalin Marinas , Will Deacon , linux-kselftest@vger.kernel.org, linux-api@vger.kernel.org, Mark Brown X-Mailer: b4 0.13-dev-0438c X-Developer-Signature: v=1; a=openpgp-sha256; l=1887; i=broonie@kernel.org; h=from:subject:message-id; bh=7YKUNDbMUGXSSUeiwJ4pvwvRXBVAoVFkUMX3lRaprx0=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBlNnPGU1TmRkbNZV+PUcum00dEkiIMDqfUoWpyRl5x dSWGE7uJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZTZzxgAKCRAk1otyXVSH0MsuCA CBCxQGFxf1wABIz0HrZYeAmZPKrdLDZvInZAqm14LQGGXm+SenttiAoWPxh2g9cS5O0r/b5yDwhRk9 0kReorlYqDoFBe8QMuSijaS+TIvVfVyx7Izl8FtllIa0TI6F5H3DGnA7gOzdYHO7uKSSTyXXWxCybO vepIT1S7c8t51eEQox1oI3oHwxuoz9gZUX6+YvtzKAwvVQZkF72BwHB+Eq3hj4eodzm8Y4tYILokmS wKDbliHKE9QXK9IQ8/cxhuoNjpyhf9gmgYjWnfcLfgGUYzJvII30VWOCtWBY4jBF+slAgqS9yLcs5o WnIUWfg74tyCf7jv7//409H63hoNrb X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org The clone_args structure is extensible, with the syscall passing in the length of the structure. Inside the kernel we use copy_struct_from_user() to read the struct but this has the unfortunate side effect of silently accepting some overrun in the structure size providing the extra data is all zeros. This means that we can't discover the clone3() features that the running kernel supports by simply probing with various struct sizes. We need to check this for the benefit of test systems which run newer kselftests on old kernels. Add a flag which can be set on a test to indicate that clone3() may return -E2BIG due to the use of newer struct versions. Currently no tests need this but it will become an issue for testing clone3() support for shadow stacks, the support for shadow stacks is already present on x86. Signed-off-by: Mark Brown --- tools/testing/selftests/clone3/clone3.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/testing/selftests/clone3/clone3.c b/tools/testing/selftests/clone3/clone3.c index afe383689a67..f1802db82e4e 100644 --- a/tools/testing/selftests/clone3/clone3.c +++ b/tools/testing/selftests/clone3/clone3.c @@ -39,6 +39,7 @@ struct test { size_t size; size_function size_function; int expected; + bool e2big_valid; enum test_mode test_mode; filter_function filter; }; @@ -141,6 +142,11 @@ static void test_clone3(const struct test *test) ksft_print_msg("[%d] clone3() with flags says: %d expected %d\n", getpid(), ret, test->expected); if (ret != test->expected) { + if (test->e2big_valid && ret == -E2BIG) { + ksft_print_msg("Test reported -E2BIG\n"); + ksft_test_result_skip("%s\n", test->name); + return; + } ksft_print_msg( "[%d] Result (%d) is different than expected (%d)\n", getpid(), ret, test->expected);