From patchwork Mon Oct 24 11:33:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9811 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp554937wru; Mon, 24 Oct 2022 09:58:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM49JnXex0S88+L6SsGPJoP/AiIw54Uq+Zo3xX0gm8UheUbY6SrOYm9Db6QPxk3cOQtVahnM X-Received: by 2002:a17:903:1c2:b0:185:47ce:f4d2 with SMTP id e2-20020a17090301c200b0018547cef4d2mr34912789plh.101.1666630711800; Mon, 24 Oct 2022 09:58:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666630711; cv=none; d=google.com; s=arc-20160816; b=VZnrfsCGH8FyNFGVUGGO18CeqJSZzU/5jQVr2zUXzJKcNOR26edByC0Dh4cqAVGlo7 ZhlALI7rmtdlZgIzFJFwKWMHP4YIc8peD2v0yML+osEFCGoz7vy9tG256dBcTw07bw5i ZQiPLBAcTfPTpWlqwUaRvToajaL34MOK33RNYtZ63UPuRwUwzCLIZ7XzqZWb4upk8KSq hgh9HARcBzq7PGjEK31foVo4x+ANv9Qf/h8mFpbwIJGPWZ0jhuf8jnsqPkBLo/RUAifb t9OzKjxjx6H00yPxb+cPNPSAIwWwfPZEATEbmo1PyvfyjaQF8jWR7RsH3fe+dy2WhN7Q bUgQ== 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=zWddo4ILfjBGMpJmUV/4NXJTcrJpUB7wTox1fOIldVM=; b=VfgTJfZRx3PjoTHzFuEazOmmwfbKrjXCH9SCT0CFrbJAYDGh5yHybtq2yiQUq9fQ9b G+2bCFTcmMGBSdzuoJT6bU23oZvUX9xLPT0c4Asuf1IxjzMbATqwMozPaDC4wsGjtL7w 2YKa2d/cikQqiLtiEcLBCyXBjQo1o6rlN+4L7YoWxNWnYXJPP04x31JqG95xo0clBWV7 q9gK9zc4VMA5eA056MBTt2G6CyRcU/w83eDR1lgyATikR7+EbpxnrHrNcnhgEFDrKSfH e3ViMnuC99/sTzN1cneqOg2S5z9ztmbvFhze0Lq8GycNpk/lDeDJWIhZ+LW9OKVUodl0 el4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fFe6nw5i; 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 a72-20020a63904b000000b0046ed15a820esi8549355pge.385.2022.10.24.09.58.08; Mon, 24 Oct 2022 09:58:31 -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=fFe6nw5i; 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 S230296AbiJXQvo (ORCPT + 99 others); Mon, 24 Oct 2022 12:51:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235030AbiJXQs5 (ORCPT ); Mon, 24 Oct 2022 12:48:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B9355E641; Mon, 24 Oct 2022 08:31:57 -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 ams.source.kernel.org (Postfix) with ESMTPS id 705CCB818B0; Mon, 24 Oct 2022 12:53:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA0B0C433D6; Mon, 24 Oct 2022 12:53:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666616016; bh=fgtAklnDLR1JN+ODD7wtKDjNHXOdOQ/XtHwoAJz+gmc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fFe6nw5iTusBmBTUDM23pCzyfyBZTHKTsZYhBo5+SXvqhbUbcUpier/c2+6jFOEAV z5dj1Ecg7Ib9P5imI+ubHrJZfQ+auEsGnhHm81c4uOGFGFxj3PG8T97b0EOkWDJZ36 Vi2lCM/uMBjKuX1F2bxg5oaJGDIbkpTAzaEaKoYw= 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.15 470/530] kselftest/arm64: Fix validatation termination record after EXTRA_CONTEXT Date: Mon, 24 Oct 2022 13:33:34 +0200 Message-Id: <20221024113106.326334405@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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?1747588964822445474?= X-GMAIL-MSGID: =?utf-8?q?1747588964822445474?= 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 8c2a57fc2f9c..341b3d5200bd 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;