Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3965090rwi; Sat, 22 Oct 2022 03:02:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6aeJv1fzxjE4p1aN8OFYCXjBltRtPolRSGONN8cffdylPSVxyO6JrTbwqM6TApJlL5VNP9 X-Received: by 2002:a17:906:99c1:b0:6fe:b01d:134 with SMTP id s1-20020a17090699c100b006feb01d0134mr19325375ejn.598.1666432928551; Sat, 22 Oct 2022 03:02:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666432928; cv=none; d=google.com; s=arc-20160816; b=A6wGVyCgdDkGpKkg5Jx7dDWaeDIzghzDCtEopYkAvnPrZo1nmBr1QpthA1E4xNyI7q mE5UyNbyMgSXk3MwCjjuqrAa8pNHlqhwn5j70BTPmisrK0feR/FjzoPFXOcRJkFJinvY j/QPVFUp5T25ac1Jg86S8/34pK9qEeKkPCDfgQSswaODKcCMSH3IrS5GQhl/J65AIjvv WpQqOmMPSr6Vfr6p5i7se30IxlCCr1ZJOWNrdbuKKu4RUDFplKN38aAI4EHhYcCM9v2G 5Dka4Q5BYgajta7wjOm9KrxqFb9SILICDgH8NPgehFq0uLhMh2fzZ9ECaDdu4vxZMwum Y0ng== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gmNVKqHj52xvuWQOZbrsjyGqZ8EVspUwCPvyaLVnFyg=; b=Of2a8vIQBu8J+hTqKxIUyBgQ4aTGOa4l8RYYG+IONq4MpsFPwpD8rgYaAnKlidIofR /wM0YO5stpZZBIG8JkBBZaHTWri75qdxcUwiDmewKKAZfSou3Fth0dpIMfpqdw5K9CzF JQD8py8c/IOeUDeYuyWJRLbM1B8NdnXg2Cy9G0UyvanUzT9/1n1fHynyWPj379ojpnUi WJfeLbdzH/Oj02pbzea9wmhnQrKluDm2Q00HnKrl8TfHij12mcpSZI3eo+El0GQeMMyQ kOZwo3PG8RPkCFxXQg7kV3iFMWjnQZtlq7OaRCskQcOcH476iqmCp5NekRUtykL9AVgT yCiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UO3opyeN; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg36-20020a170907972400b007a00aaf659csi1779378ejc.198.2022.10.22.03.01.42; Sat, 22 Oct 2022 03:02:08 -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=@linuxfoundation.org header.s=korg header.b=UO3opyeN; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230098AbiJVJVP (ORCPT + 99 others); Sat, 22 Oct 2022 05:21:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230070AbiJVJUq (ORCPT ); Sat, 22 Oct 2022 05:20:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8540FAE6A; Sat, 22 Oct 2022 01:34:36 -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 21BD460B90; Sat, 22 Oct 2022 08:04:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D7CCC433D6; Sat, 22 Oct 2022 08:04:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425859; bh=xlDA8pfPkFAaw/9xQEsxhHEEkQh9btgLLPQGvlm7iec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UO3opyeNqpkRbFo8uZv86FTAJ+jr3Cia1hkvDLM5JoW+Bvqff9c6faL0KRUPjNr4v lqeA76u8TJDpJmHYCMD1goxN6qJfP6zzpAD4fOj5zqMD7Tv1ULSsrPsWuKM0KOtE9t VPsTAlRfjAMDzHeaOXVxOq96PdduTiVM4bwIfzww= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Brown , Catalin Marinas , Sasha Levin Subject: [PATCH 5.19 639/717] kselftest/arm64: Fix validatation termination record after EXTRA_CONTEXT Date: Sat, 22 Oct 2022 09:28:38 +0200 Message-Id: <20221022072526.690184750@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.3 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