From patchwork Tue Nov 22 20:39:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 24557 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2428804wrr; Tue, 22 Nov 2022 12:41:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf7ux7crK3zesPrhrqp08Bi2qhEzxZejEN0sy8oqgmL46mQKSEjl4BPE7iz7QyM4bqCOT1yO X-Received: by 2002:a05:6a00:1696:b0:537:b0c3:691 with SMTP id k22-20020a056a00169600b00537b0c30691mr5645812pfc.59.1669149671396; Tue, 22 Nov 2022 12:41:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669149671; cv=none; d=google.com; s=arc-20160816; b=nMUWS3ug4eQaJm2QAGNxY6rzLhtc7O72N7RzfnAK08FYzpBEGZ8XFZPxG6GraJFli2 fIvw3i92lw0EYjLRLciJaG1xjRDeWhlwY74QiO+6EzOHJRftgihbXMQRSCJMAdNYe817 YzYeANSqim/KUVdVD/gKReC40NDnOzrMjCpIaJaZJ840RiH5gvfx0B1dw8A1vxUD1fb+ JnulT/el3y9tpHVcdEn4rlwqN6O3EuZbGJIQ9pAPE+iUi3Ii3MkSxIX0qxAglvp6P/jS d83RdbGzAGsKrYdNeigiZqxBp3ZKirBz/jAMpC0VxG+f0wA9a7wCv3QUIcuSEEZrq7Gn 1NPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1RY1pK1yxcHOeKEN3vBtCtwyn3LSSBX4qmS113zLo2A=; b=cRofuLxbYGPWhJe7h91USRQNN5+ZyXm5mFtrp8ZKX2UxPROysDuMw+f4inKXpTAAkU SreHsNC5ay1gR7fII+A8rrRG5wzc6tfARinAEo60V0KXtTW9VD3n2HAtk+/oN1CljNfp 05hLQWMKXWAO/zsTQR2jojFtKibNlYauXn2CsDXU5PA+9PB6f0FANnWsKm566y/imu29 eJo2ONotJPhUJjBAYxL9DmfLHsRMApLNqrHS+tJNAZy5kG9zXS2zTQinxmmCs6NtiZsc sdvd5PiTRcmQNFXI5NaTHP0EXT4TvUpTpk3Dz5iTxatzmZBtd016qiyci4oTA7dkop9C PdNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=KzuJsJ+A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x27-20020a63171b000000b00476e3bb232dsi14993299pgl.185.2022.11.22.12.40.57; Tue, 22 Nov 2022 12:41:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=KzuJsJ+A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234711AbiKVUkJ (ORCPT + 99 others); Tue, 22 Nov 2022 15:40:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233928AbiKVUju (ORCPT ); Tue, 22 Nov 2022 15:39:50 -0500 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 546DE716E3; Tue, 22 Nov 2022 12:39:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1669149584; bh=ow2wHboTcwRtSOUGXRGJ9ltX+L8eM9I6Nfqms25JGf4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KzuJsJ+A54gpO+PRhoOUBboRSMMY965HVnq4OsxK2ZSH3HZusxjhQKnlhyKG16O6u N7/OlbG9xcJxngNN+hWkRaxKOt1TaN1wAk0jpTwztZpAI38yGfb3rBXo4QSOzlnGMR NK2brKziL4hZHD89/pc9swAvvdL5oDuuT8oY8k7ZyiD1HNqCi3VKfDVIibSM8vmKJk tD9knFgwE8z8RlLSOmUnkAHHv79ZjgV5OL462dHNdgSXm7Ois+Di29YGIpOJ2Jjbp8 3aa5jysMcKJ1VP93M0e8kuJ8a30vephtFwoXQ8thLaKWpp2eRFDDHb9K3TpLurkvut 3OSTDuq9ule5g== Received: from localhost.localdomain (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4NGx2S4KSZzXDS; Tue, 22 Nov 2022 15:39:44 -0500 (EST) From: Mathieu Desnoyers To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , "Paul E . McKenney" , Boqun Feng , "H . Peter Anvin" , Paul Turner , linux-api@vger.kernel.org, Christian Brauner , Florian Weimer , David.Laight@ACULAB.COM, carlos@redhat.com, Peter Oskolkov , Alexander Mikhalitsyn , Chris Kennelly , Mathieu Desnoyers Subject: [PATCH 01/30] selftests/rseq: Fix: Fail thread registration when CONFIG_RSEQ=n Date: Tue, 22 Nov 2022 15:39:03 -0500 Message-Id: <20221122203932.231377-2-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221122203932.231377-1-mathieu.desnoyers@efficios.com> References: <20221122203932.231377-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750230285509441150?= X-GMAIL-MSGID: =?utf-8?q?1750230285509441150?= When linking the selftests against a libc which does not handle rseq registration (before 2.35), rseq thread registration silently succeed even with CONFIG_RSEQ=n because it erroneously thinks that libc is handling rseq registration. This is caused by setting the rseq ownership flag only after the rseq_available() check. It should rather be set before the rseq_available() check. Set the rseq_size to 0 (error value) immediately after the rseq_available() check fails rather than in the thread registration functions. Signed-off-by: Mathieu Desnoyers --- tools/testing/selftests/rseq/rseq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/rseq/rseq.c b/tools/testing/selftests/rseq/rseq.c index 4177f9507bbe..376a73f1ac41 100644 --- a/tools/testing/selftests/rseq/rseq.c +++ b/tools/testing/selftests/rseq/rseq.c @@ -119,9 +119,11 @@ void rseq_init(void) rseq_flags = *libc_rseq_flags_p; return; } - if (!rseq_available()) - return; rseq_ownership = 1; + if (!rseq_available()) { + rseq_size = 0; + return; + } rseq_offset = (void *)&__rseq_abi - rseq_thread_pointer(); rseq_size = sizeof(struct rseq_abi); rseq_flags = 0;