Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1373359rwb; Wed, 26 Jul 2023 11:25:26 -0700 (PDT) X-Google-Smtp-Source: APBJJlFcXU/eimiQ+SUEYcjeO0g50ENDKuSyH9wkm0+b+eDAa5+Gn44gVEfZE2f/uT7heKTJOAjB X-Received: by 2002:a19:915e:0:b0:4fe:54f:6cdb with SMTP id y30-20020a19915e000000b004fe054f6cdbmr1983095lfj.33.1690395926072; Wed, 26 Jul 2023 11:25:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690395926; cv=none; d=google.com; s=arc-20160816; b=IsQp+hTwnZ87zfYIAzTMLKcJ8AcpwKJprh8Qa+rrVuzYh4cqkynr5Hwz5JsSGqAYV2 klxN1XqrInvdjJ5Xr1k723Txfb9lcY+n5fwxwAdFJ0TyiuNGWCpcfz5qrxPxx2ck32DJ JWzD/N9Jfk3IqeMwkPordQEBuuq8CRCtbJxOEGHWogVXafXIJJSfxQ58IPJoQs7h80q0 jJuFK0qksrGL9nq8kAu4jKo+K9Y+KSYdubCG/fd5rWwYaYr1/1B51zpt5QKUjgC4mnRD MvKYD87jBg14GSxqvh7NT+ZD5YAcHMYGyTvC4CjQ8io7dejF5Uz+OZdovrFOrVSHIwMK 9B8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=SST1Gowbuatt0r6NTTpiZ1baCndRlrwLDbES8WK6FKA=; fh=Vj/LG1gv3YQ5dZ15hVFaHycjoSsk5HdqbpSKUYZbd3A=; b=EmKLbvToupWHzYhsmMezKYoOLigf5jQek3n5pq6+QiUG76IcgpRij9u9Emxxod2izO yE3CGbldfkB66Llvg15bFb72K4Yprcn2+UN33OfFwL+BthvYEg7EqVWauhxS0chZImwN nm2V2SVUaYh5rbhgJY1/fLMxNcnfhnIMcvu0ZUdUD2cL+JjJM9opXA7svhVjVbDXK/Xe X3bStvRLpjt6uJIOcXFRLPhMPruWar+u9RPl0iNgl9sdjtMQk90L1NX2pJN7eECFy6pO 04Lbkju4ONnINOd9B5DzpTQNA93jyq5HKw4pP8jS9C78mLz/YzkFNVJc989qRbGLlx/Z 1+FQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s22-20020a1709067b9600b00993a37b5e5csi9672188ejo.394.2023.07.26.11.25.00; Wed, 26 Jul 2023 11:25:26 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230301AbjGZRhh (ORCPT + 99 others); Wed, 26 Jul 2023 13:37:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232569AbjGZRhf (ORCPT ); Wed, 26 Jul 2023 13:37:35 -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 7CDA62727 for ; Wed, 26 Jul 2023 10:37:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DE46C61B91 for ; Wed, 26 Jul 2023 17:37:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7731BC433C8; Wed, 26 Jul 2023 17:37:29 +0000 (UTC) Date: Wed, 26 Jul 2023 18:37:26 +0100 From: Catalin Marinas To: Mark Brown Cc: Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] arm64/sme: Set new vector length before reallocating Message-ID: References: <20230726-arm64-fix-sme-fix-v1-1-7752ec58af27@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230726-arm64-fix-sme-fix-v1-1-7752ec58af27@kernel.org> X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 On Wed, Jul 26, 2023 at 01:12:26PM +0100, Mark Brown wrote: > As part of fixing the allocation of the buffer for SVE state when changing > SME vector length we introduced an immediate reallocation of the SVE state, > this is also done when changing the SVE vector length for consistency. > Unfortunately this reallocation is done prior to writing the new vector > length to the task struct, meaning the allocation is done with the old > vector length and can lead to memory corruption due to an undersized buffer > being used. > > Move the update of the vector length before the allocation to ensure that > the new vector length is taken into account. > > For some reason this isn't triggering any problems when running tests on > the arm64 fixes branch (even after repeated tries) but is triggering > issues very often after merge into mainline. > > Fixes: d4d5be94a878 ("arm64/fpsimd: Ensure SME storage is allocated after SVE VL changes") > Signed-off-by: Mark Brown I'll add a cc stable here since the above commit was fixing code that went in for 5.19. -- Catalin