Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2355005rwi; Tue, 11 Oct 2022 07:52:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4373VUTlUyFR7kHFlUvcJWS+WFapfwY7uYKyfRF8k7k4Foa3ZVYdmRhWOgzqUMqnkifXJg X-Received: by 2002:aa7:8f04:0:b0:563:1a66:9f with SMTP id x4-20020aa78f04000000b005631a66009fmr15880872pfr.75.1665499974784; Tue, 11 Oct 2022 07:52:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665499974; cv=none; d=google.com; s=arc-20160816; b=VqHx0O4yyMYeTD8LTen4EAEUKgiXiQdY6LiebXkX3vdrcYyitz3qfywWwonRL7G5Oi 8drz+Xfdlw7zqUPKbHOGcnsX+lCR4RG378EXXlcKlwwQqSoZIhkd8hclaXSBJMGmwMzh wp/eS90MVfGLzd1Z+nPX0qViAE6RejAX4Hg4LS5sII1xqXqGjmKhcIRi6Oz1lum7gDrQ +TAsONiHt+XFfGQO5XNUKDPSECY+b96omkLsBScV01B5idQV8alBHRa8HXo5yjchL33V x68OMwJ8cKvnPcOr7TRQoUdG+fRS19mBwoo/rW7ywZpswI39oNlqpGuSF11RNj51sGya oSqA== 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=gmNVKqHj52xvuWQOZbrsjyGqZ8EVspUwCPvyaLVnFyg=; b=w3MY7q3BuXn98rK76YcPQTLm0ARU0/B26BRbxXPsSHsDK8HACq4LWDauquyexkkazy B2SY9mjhGbMI6ec2xrd8uRc9tWRgg9MPROkDSK/CpHAuxDhQJcW+DwszaKddVLym5wjr bH8fRvQrPqVBRj6sb6a/UchOcwTvV4nPcV30Fp8sZrQpg07aCiWafN/yDcUaNBThcuVP KP/scoKM3LJc+j+4IZnHoB9VCGHlZ/xjjjlG7A7EFDsjDhZ9t4jDZpozvQ2vB1lF1BQC MOSmHLXkqiesOebAnU35VieNajA8Rfpwwf3n0Zgidjk9eppS7spqajxyUvjr+enYW3H8 4S1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oqyCg1Cs; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f65-20020a17090a704700b0020c4fd9306bsi11951611pjk.166.2022.10.11.07.52.41; Tue, 11 Oct 2022 07:52:54 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=oqyCg1Cs; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229882AbiJKOv2 (ORCPT + 99 others); Tue, 11 Oct 2022 10:51:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229984AbiJKOun (ORCPT ); Tue, 11 Oct 2022 10:50:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F0B498340; Tue, 11 Oct 2022 07:50:38 -0700 (PDT) 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 CD72A61198; Tue, 11 Oct 2022 14:50:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30F96C433C1; Tue, 11 Oct 2022 14:50:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665499837; bh=xlDA8pfPkFAaw/9xQEsxhHEEkQh9btgLLPQGvlm7iec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oqyCg1CsBkS3J0V+zznBQUGsjnNiqA7v5vK7MFsf/KfH9Jpke+wNX/KckEYazrU2m SkAARd0AOOWT2F5HtIZQKia3w3ES4sACwR/c+p6M9vPyTpYU6KGL4SvxTdnXqu+5BS pKU61dJ3xliAVCFOLkZ+IaOkEPlBnmB7TleMYE+cQhpV0D9wFR0K4NI1Mh06VNUQr+ bMjlj68Qj5LG7DNacJaDxgbX8gRBfedmEVBsYGRDX3WSDE04b3FMZNPmIGqCJzIrEa K+7qGVLYe75USITyTDS3/CfJ1Gdo1R/Rs/41hzRWZA2VxeU7ofbpPt20XwWzLhmwy4 bzK5oCeIdfurA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mark Brown , Catalin Marinas , Sasha Levin , will@kernel.org, shuah@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org Subject: [PATCH AUTOSEL 6.0 14/46] kselftest/arm64: Fix validatation termination record after EXTRA_CONTEXT Date: Tue, 11 Oct 2022 10:49:42 -0400 Message-Id: <20221011145015.1622882-14-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221011145015.1622882-1-sashal@kernel.org> References: <20221011145015.1622882-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Mark Brown [ Upstream commit 5c152c2f66f9368394b89ac90dc7483476ef7b88 ] When arm64 signal context data overflows the base struct sigcontext it gets placed in an extra buffer pointed to by a record of type EXTRA_CONTEXT in the base struct sigcontext which is required to be the last record in the base struct sigframe. The current validation code attempts to check this by using GET_RESV_NEXT_HEAD() to step forward from the current record to the next but that is a macro which assumes it is being provided with a struct _aarch64_ctx and uses the size there to skip forward to the next record. Instead validate_extra_context() passes it a struct extra_context which has a separate size field. This compiles but results in us trying to validate a termination record in completely the wrong place, at best failing validation and at worst just segfaulting. Fix this by passing the struct _aarch64_ctx we meant to into the macro. Signed-off-by: Mark Brown Link: https://lore.kernel.org/r/20220829160703.874492-4-broonie@kernel.org Signed-off-by: Catalin Marinas Signed-off-by: Sasha Levin --- tools/testing/selftests/arm64/signal/testcases/testcases.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/arm64/signal/testcases/testcases.c b/tools/testing/selftests/arm64/signal/testcases/testcases.c index 84c36bee4d82..d98828cb542b 100644 --- a/tools/testing/selftests/arm64/signal/testcases/testcases.c +++ b/tools/testing/selftests/arm64/signal/testcases/testcases.c @@ -33,7 +33,7 @@ bool validate_extra_context(struct extra_context *extra, char **err) return false; fprintf(stderr, "Validating EXTRA...\n"); - term = GET_RESV_NEXT_HEAD(extra); + term = GET_RESV_NEXT_HEAD(&extra->head); if (!term || term->magic || term->size) { *err = "Missing terminator after EXTRA context"; return false; -- 2.35.1