From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A793C433EF for ; Thu, 9 Sep 2021 16:56:09 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 14C0D6023D for ; Thu, 9 Sep 2021 16:56:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 14C0D6023D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=+Cw9/8UQDjbm7cY89ji0/JYlfwSrEEkpyRgdleogsaM=; b=CKsGKXY/SFacrI 0uATPmfLFXS/xJAGjTNMDsRG9b8reR2v2nswvYi7jP0VqfMtk3u2SOxuUqldjdSOXC6hlPmscwSSl TLgwNcwRzlEUqtER9BTNinjgb8UGjBQr6yc0qlf2tbLiOGzFhiUmmBCqlqUIHVeY/kqemv4uHQlCB F33aQcY9Ctphyx/Q8REzl0ambRzucfSIzSNOuBUWVPhiZVYnZxx53W5G3muTHN/acjZsKpgbGsTyn BCoh6HfksetaLB1Arg2VLPLftiOs5vXmBtBNCRuvt3LftdEe9voRMa1G5PzZed4y51FPxhUJD5shz KErZDEf1xQFKqwrUQckA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mONJx-00AQor-Du; Thu, 09 Sep 2021 16:54:41 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mONJr-00AQnR-39 for linux-arm-kernel@lists.infradead.org; Thu, 09 Sep 2021 16:54:36 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4659961100; Thu, 9 Sep 2021 16:54:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631206474; bh=NyhqwFXFDvlt69k+Qs0IGRTqIoLZfrQ3rHOSi8PkHn8=; h=From:To:Cc:Subject:Date:From; b=o8RKBBVf3SISU4KpilH7ZtCLGfLpAfa4ID54sZtkdG9GJJaIvFudTnamSCGkhG2uN jFZXgOoPLCnVa1jqJSLruWaLnKwspby0f583Gg3YwcYOuX8Lu8wA6PuZWYpNwFlg0M cpdM4DjfDNYAdLU+wTIGcQRpjhx425fIqO/znAFEfIvz4Dh8jhEn6t0i5e+V+xo/kj 5RmQx8IAuWBq7VihEfldzJhquoUrf4Nbio7BRf+GW2KEXUiKxVzcyJe0jKs91HBP2w VoGeg+jJbG6TKpiGj0Wv0hr+YqxTvEsxa68JUTHpWw2+q2emgGmiN9BhNOeJgi+kDu svshRLlW/G09g== From: Mark Brown To: Catalin Marinas , Will Deacon Cc: linux-arm-kernel@lists.infradead.org, Mark Brown , stable@vger.kernel.org Subject: [PATCH] arm64/sve: Use correct size when reinitialising SVE state Date: Thu, 9 Sep 2021 17:53:56 +0100 Message-Id: <20210909165356.10675-1-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1631; h=from:subject; bh=NyhqwFXFDvlt69k+Qs0IGRTqIoLZfrQ3rHOSi8PkHn8=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBhOjswYfKo1aT2/gRSLg+WC7LhYNeBGm9DX4JRX5tr Guc0JHqJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYTo7MAAKCRAk1otyXVSH0MV5B/ 464gq60JX0BC/90yiGZmi4JlxWNEez2vE9+gXaeNA3eh9ajPGO8YMknU4likmnbLV9RJEHWS7hrXuM zznfJ2w+tn/4ek1mjGYi+Zqa5mjJXRHEDkBarF8JTsqumIa9aASz2bUHXJxSWlHFvEdZSVtlXhCv/c fk1DSyn2EImQMslGvllt05VBTrGI+jUgOskT02CYmp6+bJ26vmDuFUcM5heTPEwGTqD9/Zn4qpPvW3 9S7jO8rjGb0ERkIJ/VoQ+Ej2eukFZnhNu8n2FcmnRyoYt+tvlEgmZfv7UcTGt5xT8p25FmgAiouoRH 978hVNTk42CD5rcA47Lxftp31lb/GE X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210909_095435_217205_778623BE X-CRM114-Status: GOOD ( 13.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When we need a buffer for SVE register state we call sve_alloc() to make sure that one is there. In order to avoid repeated allocations and frees we keep the buffer around unless we change vector length and just memset() it to ensure a clean register state. The function that deals with this takes the task to operate on as an argument, however in the case where we do a memset() we initialise using the SVE state size for the current task rather than the task passed as an argument. This is only an issue in the case where we are setting the register state for a task via ptrace and the task being configured has a different vector length to the task tracing it. In the case where the buffer is larger in the traced process we will leak old state from the traced process to itself, in the case where the buffer is smaller in the traced process we will overflow the buffer and corrupt memory. Fixes: bc0ee47603647 (arm64/sve: Core task context handling) Signed-off-by: Mark Brown Cc: stable@vger.kernel.org --- arch/arm64/kernel/fpsimd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c index 5a294f20e9de..ff4962750b3d 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c @@ -513,7 +513,7 @@ size_t sve_state_size(struct task_struct const *task) void sve_alloc(struct task_struct *task) { if (task->thread.sve_state) { - memset(task->thread.sve_state, 0, sve_state_size(current)); + memset(task->thread.sve_state, 0, sve_state_size(task)); return; } -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel