From mboxrd@z Thu Jan 1 00:00:00 1970 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 EC2BDC61DA4 for ; Thu, 2 Feb 2023 17:31:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231277AbjBBRbF (ORCPT ); Thu, 2 Feb 2023 12:31:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232402AbjBBRbC (ORCPT ); Thu, 2 Feb 2023 12:31:02 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28FFF74A44 for ; Thu, 2 Feb 2023 09:31:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 34561CE2BC0 for ; Thu, 2 Feb 2023 17:30:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D86B4C4339B; Thu, 2 Feb 2023 17:30:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675359057; bh=HBlP0wcnp/+JrNDOEhaP33s+WQfaCxZo9WTl7vVK7vg=; h=From:Date:Subject:To:Cc:From; b=q2ljD1kxocQF/nl4qMrqmUi5Hc9qmASoXVpFRoNOzD+Tl7hGwquzamPTpIqb7SoVk a0K1HG8N566jqMI6R5Q301wn/eCP2nYkfU5sIHho1nwvLkqmbTylgdDRbuP1ODM67Z 4HTicBl+LqGXdoLNaH9guKEZr5dmnJV/q5CMHsPFPFt7FzF+wYJgYOBxv6DcF8HcMf ZpBPEBAOmR/N3h4z6areRi+stnGmLr1YgVZzqFY53DQ7NSxK2GqbDYUFLysDeW0iTM pJcDUZNa6tMAt5VcMAS+7erH6mEBSTkel3fHlvBVu5fMEXbf+IyOqbCcmnWeq3rrKU 01ofeb+WMqklQ== From: Mark Brown Date: Thu, 02 Feb 2023 17:30:44 +0000 Subject: [PATCH] kselftest/arm64: Copy whole EXTRA context MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230201-arm64-kselftest-full-extra-v1-1-93741f32dd29@kernel.org> X-B4-Tracking: v=1; b=H4sIAEPz22MC/x2NQQrCMBAAv1L27EISQxW/Ih42dWNDYyq7UQulf zf1OHOYWUFZEitcuhWEP0nTXBrYQwfDSOXBmO6NwRl3NM5YJHn2HiflHCtrxfjOGXmpQmh7H4j 4dPbWQQsEUsYgVIZxT3xnmXb9Eo5p+T+vt237AZpBU/aDAAAA To: Catalin Marinas , Will Deacon , Shuah Khan Cc: linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1940; i=broonie@kernel.org; h=from:subject:message-id; bh=HBlP0wcnp/+JrNDOEhaP33s+WQfaCxZo9WTl7vVK7vg=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBj2/NO09R3EZtPvx1OVlcd9Lywq7oOw4x7HUpuEEsm asqnSX+JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCY9vzTgAKCRAk1otyXVSH0E+8B/ 49tVnF1MloBear5LimWYzTtIPaYaCMCP9QE0KbtJBuctWpxeCcipK1etooDkmj3vZmu4c3ssW1EUq4 B70rWrBPiiAL06SHh0m7nGyHqUtpuECAg18NLRPaHZvtTg+a7olqfQP1PJWR2PGHNbjYtztDxFoa1d HyKlYZAw6nQpZqrVVQ2lW7stNxmm+VLcKeqc8HbO3EDvOc547CafJX8Tzz0UBCYvw9j0w2xYF/1PUz xV0jyUUUUxhmsfwIzWSiH2W+7XFxPrU17D0AMMPCiyJi4iW1FwUe66h3+Q2H/7cpjZhpiy80YdHCFj UQji4H4kz3vQlZK2C6HEbS9tMz76z0 X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org When copying the EXTRA context our calculation of the amount of data we need to copy is incorrect, we only calculate the amount of data needed within uc_mcontext.__reserved, not taking account of the fixed portion of the context. Add in the offset of the reserved data so that we copy everything we should. This will only cause test failures in cases where the last context in the EXTRA context is smaller than the missing data since we don't currently validate any of the register data and all the buffers we copy into are statically allocated so default to zero meaning that if we walk beyond the end of what we copied we'll encounter what looks like a context with magic and length both 0 which is a valid terminator record. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/signal/test_signals_utils.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/arm64/signal/test_signals_utils.c b/tools/testing/selftests/arm64/signal/test_signals_utils.c index 308e229e58ab..746a4f70f082 100644 --- a/tools/testing/selftests/arm64/signal/test_signals_utils.c +++ b/tools/testing/selftests/arm64/signal/test_signals_utils.c @@ -192,8 +192,10 @@ static bool handle_signal_copyctx(struct tdescr *td, * in the copy, this was previously validated in * ASSERT_GOOD_CONTEXT(). */ - to_copy = offset + sizeof(struct extra_context) + 16 + - extra->size; + to_copy = __builtin_offsetof(ucontext_t, + uc_mcontext.__reserved); + to_copy += offset + sizeof(struct extra_context) + 16; + to_copy += extra->size; copied_extra = (struct extra_context *)&(td->live_uc->uc_mcontext.__reserved[offset]); } else { copied_extra = NULL; --- base-commit: b7bfaa761d760e72a969d116517eaa12e404c262 change-id: 20230201-arm64-kselftest-full-extra-164baae78412 Best regards, -- Mark Brown From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E18CEC05027 for ; Thu, 2 Feb 2023 17:32:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Message-Id:MIME-Version:Subject: Date:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=mZZjmzwCdzu6j46wS69TLLShaZk07J2S4tMeOG/pgMs=; b=k1nwYnB4yJjHuY prM/deMD6bztP2IlT9xO9bg9IWGbJbDdQiLH9WlhjcJ1D2e3VpKkxALBUjsqu1JBaP61peYZZvgtS WRmb/BIuJl3y0hQWT/O1Vb0lS2TyqExE21s+lAEGHiXi6mImsVo3bwX6oPWbccMExvnJ1f/EhN1qG Gufx0xmbnVBA0yfE4OSpZ1jwwXKfRef6VU14go2PgLwxMtkOdNa1zfkiEOsh3YtN4Cv07sX7cGix+ e/CUY+F6GalSWJs5i9EeUXyxa1IvJN9Dvb8vfzOskgmcxdOoiA4iOtYtfPOxN/kCJW9k5ggSch0yF Dgidl91zYj8yoGa+RBuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNdQO-00GnZZ-2r; Thu, 02 Feb 2023 17:31:04 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNdQI-00GnXw-Sl for linux-arm-kernel@lists.infradead.org; Thu, 02 Feb 2023 17:31:00 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7C81961A8D; Thu, 2 Feb 2023 17:30:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D86B4C4339B; Thu, 2 Feb 2023 17:30:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675359057; bh=HBlP0wcnp/+JrNDOEhaP33s+WQfaCxZo9WTl7vVK7vg=; h=From:Date:Subject:To:Cc:From; b=q2ljD1kxocQF/nl4qMrqmUi5Hc9qmASoXVpFRoNOzD+Tl7hGwquzamPTpIqb7SoVk a0K1HG8N566jqMI6R5Q301wn/eCP2nYkfU5sIHho1nwvLkqmbTylgdDRbuP1ODM67Z 4HTicBl+LqGXdoLNaH9guKEZr5dmnJV/q5CMHsPFPFt7FzF+wYJgYOBxv6DcF8HcMf ZpBPEBAOmR/N3h4z6areRi+stnGmLr1YgVZzqFY53DQ7NSxK2GqbDYUFLysDeW0iTM pJcDUZNa6tMAt5VcMAS+7erH6mEBSTkel3fHlvBVu5fMEXbf+IyOqbCcmnWeq3rrKU 01ofeb+WMqklQ== From: Mark Brown Date: Thu, 02 Feb 2023 17:30:44 +0000 Subject: [PATCH] kselftest/arm64: Copy whole EXTRA context MIME-Version: 1.0 Message-Id: <20230201-arm64-kselftest-full-extra-v1-1-93741f32dd29@kernel.org> X-B4-Tracking: v=1; b=H4sIAEPz22MC/x2NQQrCMBAAv1L27EISQxW/Ih42dWNDYyq7UQulf zf1OHOYWUFZEitcuhWEP0nTXBrYQwfDSOXBmO6NwRl3NM5YJHn2HiflHCtrxfjOGXmpQmh7H4j 4dPbWQQsEUsYgVIZxT3xnmXb9Eo5p+T+vt237AZpBU/aDAAAA To: Catalin Marinas , Will Deacon , Shuah Khan Cc: linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1940; i=broonie@kernel.org; h=from:subject:message-id; bh=HBlP0wcnp/+JrNDOEhaP33s+WQfaCxZo9WTl7vVK7vg=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBj2/NO09R3EZtPvx1OVlcd9Lywq7oOw4x7HUpuEEsm asqnSX+JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCY9vzTgAKCRAk1otyXVSH0E+8B/ 49tVnF1MloBear5LimWYzTtIPaYaCMCP9QE0KbtJBuctWpxeCcipK1etooDkmj3vZmu4c3ssW1EUq4 B70rWrBPiiAL06SHh0m7nGyHqUtpuECAg18NLRPaHZvtTg+a7olqfQP1PJWR2PGHNbjYtztDxFoa1d HyKlYZAw6nQpZqrVVQ2lW7stNxmm+VLcKeqc8HbO3EDvOc547CafJX8Tzz0UBCYvw9j0w2xYF/1PUz xV0jyUUUUxhmsfwIzWSiH2W+7XFxPrU17D0AMMPCiyJi4iW1FwUe66h3+Q2H/7cpjZhpiy80YdHCFj UQji4H4kz3vQlZK2C6HEbS9tMz76z0 X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230202_093059_055497_DB9D3E3F X-CRM114-Status: GOOD ( 13.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When copying the EXTRA context our calculation of the amount of data we need to copy is incorrect, we only calculate the amount of data needed within uc_mcontext.__reserved, not taking account of the fixed portion of the context. Add in the offset of the reserved data so that we copy everything we should. This will only cause test failures in cases where the last context in the EXTRA context is smaller than the missing data since we don't currently validate any of the register data and all the buffers we copy into are statically allocated so default to zero meaning that if we walk beyond the end of what we copied we'll encounter what looks like a context with magic and length both 0 which is a valid terminator record. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/signal/test_signals_utils.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/arm64/signal/test_signals_utils.c b/tools/testing/selftests/arm64/signal/test_signals_utils.c index 308e229e58ab..746a4f70f082 100644 --- a/tools/testing/selftests/arm64/signal/test_signals_utils.c +++ b/tools/testing/selftests/arm64/signal/test_signals_utils.c @@ -192,8 +192,10 @@ static bool handle_signal_copyctx(struct tdescr *td, * in the copy, this was previously validated in * ASSERT_GOOD_CONTEXT(). */ - to_copy = offset + sizeof(struct extra_context) + 16 + - extra->size; + to_copy = __builtin_offsetof(ucontext_t, + uc_mcontext.__reserved); + to_copy += offset + sizeof(struct extra_context) + 16; + to_copy += extra->size; copied_extra = (struct extra_context *)&(td->live_uc->uc_mcontext.__reserved[offset]); } else { copied_extra = NULL; --- base-commit: b7bfaa761d760e72a969d116517eaa12e404c262 change-id: 20230201-arm64-kselftest-full-extra-164baae78412 Best regards, -- Mark Brown _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel