From patchwork Sat Oct 22 07:28:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7795 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1124375wrr; Sat, 22 Oct 2022 02:36:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6CVvxqund7+ywt0fdO7UoI7iDk8Y+FRVHkUS+GzgZSlp4Do/RZplScMVcrXOv7i0BC4zIZ X-Received: by 2002:a17:907:a068:b0:78d:cbcf:f7bc with SMTP id ia8-20020a170907a06800b0078dcbcff7bcmr19093955ejc.519.1666431375763; Sat, 22 Oct 2022 02:36:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666431375; cv=none; d=google.com; s=arc-20160816; b=uqJZRpNpMcKQF19Ymco7hLwpdb2QGFJa4/oJpDxlcsDWY71VP3qR87+3soyiMlB/ZH b8rVt5kNATxvJ3mT3P3mhiPXZaM5l8vYxFWc2q9ccTfF5i5VKupb/L+73NzPzF+Yw5WC 657mPaUi1TzsJXKpTVMoPuVCo3w3gOemfwi9dzHB7e9K3THkfIxH2B02eIQpZPaRDfSd HFXsui1WoJQVjxWabarON3eglMm5H4/bJQS359hS7ICO/iprIxWkROTcpFeu5+5eaD5x VkL1m6cq9dXsSPhsxGo5SHsW7xQPrkjwhXSzTusTjxgzVssp0/6eTJLsc/0EAqV8gfak /ULg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jl25-20020a17090775d900b0078d9c7451c4si20110202ejc.718.2022.10.22.02.35.51; Sat, 22 Oct 2022 02:36:15 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747379945892688496?= X-GMAIL-MSGID: =?utf-8?q?1747379945892688496?= 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;