Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6406988rwb; Tue, 22 Nov 2022 12:58:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf5ae0WojmVOG2ZCMgJaS3hMpkMfbySJX92+mbhyTVEz7/htiJCpEtYgshiEpkA+uTHCLih3 X-Received: by 2002:a05:6a00:10cd:b0:572:5c03:f7ad with SMTP id d13-20020a056a0010cd00b005725c03f7admr27020087pfu.17.1669150715619; Tue, 22 Nov 2022 12:58:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669150715; cv=none; d=google.com; s=arc-20160816; b=RseyXwU14qNbbnor5Nq0giyo3EWi+leL+WGScpe1djAd3zo2c03cKqe11O1DRfmHf2 1LKA39+wbAJlRhvTDmcyQNjj5S/DShpBEaVXP09Rs0WRK7VcdoCULion04x3PGvd3PG6 jtQcP+Sd0o26dthtsL/tkHYSyU2imLFyh129EgOjrqu0lM4p6NNP3vb8hpniib5tql28 582rRZGhgihpBKSjjsob3sJKkcIfVOwh2Uc1LFrJcZwFxz2u9zn+JVGmrJL9oWG0xLVX SgsM5+wVm6GIkU/QxIeglcMHw6+UQ9eArIsg6mxTvtP9hoCLyYt3IrwqCB3QorjUnKYy 0nYA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c29-20020a631c1d000000b00474a832fd53si494963pgc.261.2022.11.22.12.58.23; Tue, 22 Nov 2022 12:58:35 -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 + 90 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 Content-Transfer-Encoding: 8bit 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 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; -- 2.25.1