Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 31BEDC433FE for ; Thu, 24 Nov 2022 14:07:41 +0000 (UTC) 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:References:In-Reply-To: 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: List-Owner; bh=QXADawfOYt9QRa5L4C50xzs8wvre0S/WsIkcBmEXC74=; b=S3o7duhotkHsQd o9jPzyXjo8hRk0ZlU2VDUHJYKog9AuWJ4uvezPDo3GHL5x6SSDGj3wYd5jKQHq31rgVGaxXzHQ7a2 RWr96G4IMTK4zHom/txOwtN/Wi+N0uYtQXU1v+YjL9vBtwDnM5gerBbvXu6vVzIvc/gvvLgJ8WTNh aSUwghohJFQlWcXJBJ7i6ylLrJadcWZjYx6Swed+CHCLBHDbSBkxm2K3CPO6+rxA/DZrefqjgBwgi TKMgurrj0oF12HhMzBplMq/uxbzCPODrdd/4bntyIBejCT1I8Gtig2Ldrq5ZmIb4cvsJPFH73P0z1 qguJdtLAQ2Aqplk9mvlQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oyCs1-0096LP-3T; Thu, 24 Nov 2022 14:06:29 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oyCnu-0094k4-B2 for linux-arm-kernel@lists.infradead.org; Thu, 24 Nov 2022 14:02:15 +0000 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 DD4DB62166; Thu, 24 Nov 2022 14:02:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C40AC43470; Thu, 24 Nov 2022 14:02:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669298532; bh=qwteO0L3RD1/xu+T18PR++TU5qc/s3WJhQUHL5lD6U8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BC2Iasy+6jh83F0i0mMwpp2/Q2edp8rymDu22X0fBo1RegVJnKYnkqxl5d3+nIBdg TzzNCeuI17bj+h3whyLZw0zNviW9pCvJZbsK0mOTtKJJXmTyBRSV0T+pbjvdbFISv8 vyo3FWwCn7I73B3bWwwmLPRs42y871CQYJFjQrRhDoBaC8U8cpK+sxKo4W2iX2rGxt YDkNgRVmAh2XBwVcoUe7Q1kDUFyqKHUKQP1cBHpUrHK/GRxQ6J4C6o8XVZ9p68sBzb Y+sseJXYSzd6FNiBPD7unUeBB40eUPqfi/P3zAc/PO+HHUc18HNo3c8UPD0assj3NY 1yussLWtlvr0A== From: Mark Brown To: Catalin Marinas , Will Deacon Cc: linux-arm-kernel@lists.infradead.org, Mark Brown Subject: [PATCH v1 6/6] arm64/signal: Only read new data when parsing the ZA context Date: Thu, 24 Nov 2022 13:58:18 +0000 Message-Id: <20221124135818.282955-7-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221124135818.282955-1-broonie@kernel.org> References: <20221124135818.282955-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1539; i=broonie@kernel.org; h=from:subject; bh=qwteO0L3RD1/xu+T18PR++TU5qc/s3WJhQUHL5lD6U8=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBjf3h6EmQwiOuhKyUk6c6xn0ImX77WmQBPs33ckK37 QIIm6wiJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCY394egAKCRAk1otyXVSH0OTfB/ 9rGF3uNrQs7kFaBWWfWPow18iULZDv/ZMuweVDx+hKQAgBE1c4CojBNYU9o8wyo6o6gxqMqPtHHBXy H+uRx2bnrBn5rqFyiUAmtNAt3KLfgPtcR67peZVzZciiKjXz6eiJ9eKdUcdoDrrp0ihz+7qtmRn6n4 PNqDwsm0fXklOV6VGZjngKBXmlwIpTjseOx5MTuCJgbz+B5MqkD/bO0a75ax2X8N91VITEkAsisO4A HByH3JEtF2VRACvbu/Liq0zRhZcI5RQYw0my3O/iMv1yZJXmVaZi5xW8F9pdmZQRFOmmi9LegP4pDN BJnfEPohtRAj4Fnz7vmeYdXT7Dtxem 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-20221124_060214_462165_54F6DC3E X-CRM114-Status: GOOD ( 16.12 ) 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 parse the ZA signal context we read the entire context from userspace, including the generic signal context header which was already read by parse_user_sigframe() and padding bytes that we ignore. Avoid the possibility of relying on the second read of the data read twice by only reading the data which we are actually going to use. Signed-off-by: Mark Brown --- arch/arm64/kernel/signal.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index f7b24213818a..4faaa5c6a249 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -398,17 +398,18 @@ static int preserve_za_context(struct za_context __user *ctx) static int restore_za_context(struct user_ctxs *user) { - int err; + int err = 0; unsigned int vq; - struct za_context za; + u16 user_vl; if (user->za_size < sizeof(*user->za)) return -EINVAL; - if (__copy_from_user(&za, user->za, sizeof(za))) - return -EFAULT; + __get_user_error(user_vl, &(user->za->vl), err); + if (err) + return err; - if (za.vl != task_get_sme_vl(current)) + if (user_vl != task_get_sme_vl(current)) return -EINVAL; if (user->za_size == sizeof(*user->za)) { @@ -416,7 +417,7 @@ static int restore_za_context(struct user_ctxs *user) return 0; } - vq = sve_vq_from_vl(za.vl); + vq = sve_vq_from_vl(user_vl); if (user->za_size < ZA_SIG_CONTEXT_SIZE(vq)) return -EINVAL; -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel