Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp879123rwi; Wed, 19 Oct 2022 04:14:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7RZHoR2vSKm4864ZoKP+iyJdkOgU6F7jWi7A4Vp6ECUUvYMmIR+qRXD6WT4bhBxPoOGJix X-Received: by 2002:a17:906:7314:b0:791:a45a:bc84 with SMTP id di20-20020a170906731400b00791a45abc84mr4105269ejc.394.1666178040313; Wed, 19 Oct 2022 04:14:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666178040; cv=none; d=google.com; s=arc-20160816; b=W8NwoIW/CO5gMjczAeYthZ/4mYSHcbSm4sgWRHJ9kmBNe+4+y0YnfJJPXTOUAaKbyu 7+jtJ6cKc0vQKftf/djceeNJX9KiDG9Lk4Ti9jXFK31giXjsvGzO+7YADT4yc4ENT61W SHrAJ59zcTpw++FOi9aN/vgk6KE6bi9Jd6s14paSu/EIzNSGtrJIW/W2/0vehflL/9X2 lO8JuM2HEKcxWUKch0QRGKRW2zyC3MB7da8+kRCez2BsKf7vhlX7ma0KYJ2TC3B9GglM uwy1rwNwBE2s5RU0O3MtTYqNoSJ9iEYZAN0Q0JwXV48OzbDo6RjE7cHFnI/43N8bUtcK OSUw== 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=fwc/1sAr24uHFRZ3cxb3alhfUVJk1hmBJ8sME0sdAHGi5tSjXGeJ3Mkp3tV7dBYHT2 wd14/b+09rRFIuVvCqHsFskS84W46/412E771PZjmhRB1pzkgoZoaMts/pJ4dU/HNdI4 eOTnUhcJczLSbmOIxThYCjw4Xv7KMewpqvObKrKtvWCwYQGUw1dPFwLnzYTQ6ug4qQU2 UX5mqqJ79UnpKchz1TF6jwbvwuUWBme/TDK7m2+KhnpiHitTjOFPJQHPcQIP6vT+uOiY NC+K7xvU8eLCkmbr7iOx6MAWApz3cgtYWHAnOXgA1zzNOafjWoDZr70oU0JsO18x1c1u XsXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ui9SckBF; 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 mp9-20020a1709071b0900b0078e28a52d58si13530302ejc.874.2022.10.19.04.13.34; Wed, 19 Oct 2022 04:14:00 -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=ui9SckBF; 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 S232058AbiJSKsQ (ORCPT + 99 others); Wed, 19 Oct 2022 06:48:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233167AbiJSKqU (ORCPT ); Wed, 19 Oct 2022 06:46:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7691C15A304; Wed, 19 Oct 2022 03:21:29 -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 1D397B824D8; Wed, 19 Oct 2022 09:12:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73C1FC433B5; Wed, 19 Oct 2022 09:12:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170771; bh=xlDA8pfPkFAaw/9xQEsxhHEEkQh9btgLLPQGvlm7iec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ui9SckBFtthvRN75uh4fZUPkSFwxxilsF6swk5Vr6PM+qKp1eO3NH0Um5LM3zPyNn kU0T75RUc+ILCe4RtwPfO/5/3QwLeJKeTqU9NKX8wymFqEdLfrFFRsrKBxK6XJtE/2 f2uwKXdweAPaeR82bPdyB/BIsL6FFlMjL2ApAyoU= 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 6.0 779/862] kselftest/arm64: Fix validatation termination record after EXTRA_CONTEXT Date: Wed, 19 Oct 2022 10:34:26 +0200 Message-Id: <20221019083324.327191199@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@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.4 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