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 E992BC43217 for ; Thu, 24 Nov 2022 14:04:32 +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=dHU4heipcDnycPSWkaaeXNmp93Z+bw6AlHJpOJokiGs=; b=dd8JKOB9vEcXDl TmWE5T7ltOUnGQI7zRkL50fiWRyInKm9Mrpwbo+6bIKzo0KQIOwdZXpybioJOlXcyWJzxyWFwdE5v sDEJZSBAjkq0YW0+qWC6oY4/e6loOLTDnPaWc58iFs5nfdQ1ASyw05MxDjbfbv85Uqn70w6xEkIXa guejzdmbVnxky2cpTpWBHEwnx2vpITgDh1KA7ENsfHVaE+nMAIMd7c0yaMZDlTQxhnBn+fydn0UGf wYBnwexp6F62+kexGGyaGZlz6KJTj8P/UGYExlZ9qagIPo8/QXSr4ciJzEURUmp0osy8B4NKei/uy XqiFHTeludTxmy3pvX7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oyCoy-00956V-El; Thu, 24 Nov 2022 14:03:20 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oyCnm-0094gT-DW for linux-arm-kernel@lists.infradead.org; Thu, 24 Nov 2022 14:02:07 +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 0096F62162; Thu, 24 Nov 2022 14:02:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5CC8C43470; Thu, 24 Nov 2022 14:02:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669298525; bh=wvqE/T1V9IbXrPnUlQaSk6yjd7YxQHkwoMfGsXtCZK8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ocQFkRpYCKbNQHFNmKQKSEN4yueNX03qVnSNG8FuYhPb8hDWx/XQcdDNknqvPeuW2 c0CH/aLTsv/88Hsvd1gZSPgEx0UT3T5rRi37mVfSF1kyNoXTTcbCCJWnByj6Z4MBHV nFnrsQmQoWJSRTsSMK2bWNIIamlJcMvGTcqE2i4e0IVrKOZcvNLsDu4Dx1rNIS5Zsn 2OQNxbVQFh4+aBSY81HCC3KarxTK7p1jLMqI39pxpjqiuoZzQgwKCn7/1NYq0V2uX0 6oiSFgs4WHHpT+Msx9HXDOqOZbKcFtgrlbmqQylX6rG9Y6IfHR8yW38QDzrFJ5oIBm O0EyRKAt6/u8A== From: Mark Brown To: Catalin Marinas , Will Deacon Cc: linux-arm-kernel@lists.infradead.org, Mark Brown Subject: [PATCH v1 2/6] arm64/signal: Remove redundant size validation from parse_user_sigframe() Date: Thu, 24 Nov 2022 13:58:14 +0000 Message-Id: <20221124135818.282955-3-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=2699; i=broonie@kernel.org; h=from:subject; bh=wvqE/T1V9IbXrPnUlQaSk6yjd7YxQHkwoMfGsXtCZK8=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBjf3h2eRyv+MCrZrWn/o01bN7tEFFTKggkjZCCLt5U q72nlYaJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCY394dgAKCRAk1otyXVSH0P5fB/ 0cXCmTjdvmieC6ajlrToaUFBcJvUPkPpb3okAB7PznBxM621y/VkA6Mt+8Sp3YHmcetGdIOjd8uveA YdgF9YpmYRBGqpEnQnY8cYr1p35wPHJALs2SnBFw7nnZwSxM5w2LZcvVzOfS4md4EH92lUVzniBQ/F DG9RWfw5JwX1Iv2AcL/3528Ag8LnWTviE6+0D8/ZAOPhxpiq4ImSL8XL6GYFKuZNRo/fUR2LCkceU1 WYz1MqHMfY+PaD53gMi8PtvGNbvvTe3WGd6YJdsnHIvSp5XLJ0Lx4JdJObEs3hsc+5gzOoiNrTwdgm Qqyno4wnbbNINlIkqBAZlA6IOxR1m6 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_060206_588558_58A2771F X-CRM114-Status: GOOD ( 16.77 ) 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 There is some minimal size validation in parse_user_sigframe() however all of the individual parsing functions perform frame specific validation of the sizing information, remove the frame specific size checks in the core so that there isn't any confusion about what we validate for size. Since the checks in the SVE and ZA parsing are after we have read the relevant context and since they won't report an error if the frame is undersized they are adjusted to check for this before doing anything else. Signed-off-by: Mark Brown --- arch/arm64/kernel/signal.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index f9a98948a2c8..1840e26f3f54 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -270,6 +270,9 @@ static int restore_sve_fpsimd_context(struct user_ctxs *user) struct user_fpsimd_state fpsimd; struct sve_context sve; + if (sve.head.size < sizeof(*user->sve)) + return -EINVAL; + if (__copy_from_user(&sve, user->sve, sizeof(sve))) return -EFAULT; @@ -288,7 +291,7 @@ static int restore_sve_fpsimd_context(struct user_ctxs *user) if (sve.vl != vl) return -EINVAL; - if (sve.head.size <= sizeof(*user->sve)) { + if (sve.head.size == sizeof(*user->sve)) { clear_thread_flag(TIF_SVE); current->thread.svcr &= ~SVCR_SM_MASK; goto fpsimd_only; @@ -398,13 +401,16 @@ static int restore_za_context(struct user_ctxs *user) unsigned int vq; struct za_context za; + if (za.head.size == sizeof(*user->za)) + return -EINVAL; + if (__copy_from_user(&za, user->za, sizeof(za))) return -EFAULT; if (za.vl != task_get_sme_vl(current)) return -EINVAL; - if (za.head.size <= sizeof(*user->za)) { + if (za.head.size == sizeof(*user->za)) { current->thread.svcr &= ~SVCR_ZA_MASK; return 0; } @@ -507,9 +513,6 @@ static int parse_user_sigframe(struct user_ctxs *user, if (user->fpsimd) goto invalid; - if (size < sizeof(*user->fpsimd)) - goto invalid; - user->fpsimd = (struct fpsimd_context __user *)head; break; @@ -524,9 +527,6 @@ static int parse_user_sigframe(struct user_ctxs *user, if (user->sve) goto invalid; - if (size < sizeof(*user->sve)) - goto invalid; - user->sve = (struct sve_context __user *)head; break; @@ -537,9 +537,6 @@ static int parse_user_sigframe(struct user_ctxs *user, if (user->za) goto invalid; - if (size < sizeof(*user->za)) - goto invalid; - user->za = (struct za_context __user *)head; break; -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel