From patchwork Tue Nov 14 20:05:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 165068 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:a59:b0:164:83eb:24d7 with SMTP id 25csp2173062rwb; Tue, 14 Nov 2023 12:07:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IGenwPbRJFogJ28PoVKjXtNJRWHXa0VQqFchuMDlXeinSBFztePpSGEfdjN3Mng5yeWjwD+ X-Received: by 2002:a17:902:eccb:b0:1cc:3c2f:9c41 with SMTP id a11-20020a170902eccb00b001cc3c2f9c41mr3946280plh.23.1699992468217; Tue, 14 Nov 2023 12:07:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699992468; cv=none; d=google.com; s=arc-20160816; b=YHVeNHnrZpuBXT5HysQGIZ0NsCHYftqOlnnLZOYzTU0GU2FZaNMAY3utVPu2F/7QG2 VZBdgqa1qA1CZh7kNwF+cx7plO2mpAQzS9DVdr5RB+DSMBgq8CgN+mOiQyU833Rir6Ui r1uwmjYjpMcaQpLZOZ6vbaYic68pM6I0Moze2EOufbASC592G9dTE6lIuyYrbGS+HRD3 L92BTZ/8Fwoo8fAI/ph54E7H1fxpazAUmyk/6JCyaXM4jHjZAlST5dUEuJF9UisaM4fC 0XyiLmgV25PqK120J2MMaBktxawxSumO1zTSNvM1D+bI6USQhGVDTcap2SelPUTvpN7f Pb9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=rnrAcFFJlTaTWrEDOlhOmzSEK/Ayvew57WsJeG2pZk8=; fh=oQRZOFrDQfXNJ7G92Ah9cs8vRP0rRtblCDc+u4U9urY=; b=wQ58fGTg8NEpymBnUKb72WzfAYPXyZ26uDP3tQ4vprHEIle2o5yY44PAVnD38/wq2H ZLRts2FYqK85A8oyXRXCbWRVEXXgSK1Sv+LZ5PXXywiWggF/nLaJm52a8pLuEf4OMCyY uzKJKj9tr5LagNMJIXZEzKcYSyt2Zd7mejWal2euiq0nW84G47pAuvjwSPtAuhwCln0t pzsXNFney9G4U6bT11ldRReln4ozTp+3BxsT90fB1LnaJtxgc9nnbH/BbewhILhBUjt1 C207Ug7PPHh/14EXitjFhXWAov8z0we7HHS5p/6ST3VIE+MHU+CGXNBPcBzm73EciLmL trbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Uxh8I9pc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id x4-20020a170902b40400b001cc37466bdasi8101155plr.239.2023.11.14.12.07.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 12:07:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Uxh8I9pc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 2DF79802F56D; Tue, 14 Nov 2023 12:07:35 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233994AbjKNUHF (ORCPT + 29 others); Tue, 14 Nov 2023 15:07:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233895AbjKNUGu (ORCPT ); Tue, 14 Nov 2023 15:06:50 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B3861A1 for ; Tue, 14 Nov 2023 12:06:42 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0514EC433C7; Tue, 14 Nov 2023 20:06:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699992401; bh=ZmJrvmANp1kG9kAUuq4ZkamJ4qQyGfBTGbaFEhsSApg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Uxh8I9pcemFU+yGRtS7Vuo8DeS1M2BfZvhrOG5xhsC6Vl9YyuKMKsy6cEUNGdNfiv YmA3bhEelh6LltyPaU9bt3Zc3Lg3i0sjQu9Zwd7nzaVlur7sQZ70zDACZyeTab0nm2 dYQCYAY7bxQ6e77mhy4d2sMZjrl3x4mjjvQgv6fqT1RWKnja7bFeIBoZBnfkz79M8t pahN+VpPRyQrkpJSMfwLojoddj2xVk0MDgpJlE5I3DF5TQ9lHSxgt94f8gOmTvIjLR XTiOU+i0gIO0xfAHPC7G4I7x3lpMx865OJ2rAlENPzHA48GKK10BLFPoG2+w92sY3P zU/cCwv7UzeQg== From: Mark Brown Date: Tue, 14 Nov 2023 20:05:57 +0000 Subject: [PATCH RFC RFT v2 4/5] selftests/clone3: Allow tests to flag if -E2BIG is a valid error code MIME-Version: 1.0 Message-Id: <20231114-clone3-shadow-stack-v2-4-b613f8681155@kernel.org> References: <20231114-clone3-shadow-stack-v2-0-b613f8681155@kernel.org> In-Reply-To: <20231114-clone3-shadow-stack-v2-0-b613f8681155@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 , Kees Cook , jannh@google.com, bsegall@google.com, 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=ZmJrvmANp1kG9kAUuq4ZkamJ4qQyGfBTGbaFEhsSApg=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBlU9MvjU45KxHk6MXI07uEtQfGL2f1juaDoVQx1uQt jstsNW6JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZVPTLwAKCRAk1otyXVSH0Cn2B/ 9NNiANJ4S5XcTNlqQbxd9WuKQLoSseYwhfB+36m1g1HI6ZznOzMdea9h1Mw5JQ4ab4pNSnRgZSJ+uX 7ViidqykpVO08D3UL5GDOfiTf+5qsshyDTU822KPe4CV40HJlVyaS/hHqiT5b1V7f0j/X501W+iEBi N2c9NmMSgFTMPwbfDm078r34xcxrNsRq2PnhO7RsS4aC461EufZRU4KhF3FqI+tGBgEdGW4gAlVBOD AaCdWmgGOc3CuiDQK33lkd06u7bHZAGM1J96SbZAmWcAbXHizTMc5jCafHbgNWM+Kkdbb+m0oMStL7 bRS0J5f9pVElfhbFo0IcbtqUrqkZJD X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 14 Nov 2023 12:07:35 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782571302555648799 X-GMAIL-MSGID: 1782571302555648799 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 1108bd8e36d6..6adbfd14c841 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);