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 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 61476C4167B for ; Tue, 7 Nov 2023 12:28:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B9C7710E592; Tue, 7 Nov 2023 12:28:32 +0000 (UTC) Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1174510E592 for ; Tue, 7 Nov 2023 12:28:31 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 71A89CE0F1F; Tue, 7 Nov 2023 12:28:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A84CC433CC; Tue, 7 Nov 2023 12:28:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699360108; bh=e7p5a03pSCO9byzAK2+njv6CMdRA/EG/kpKAQ1Fbfos=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TXIHpHpXtUuKaBHfMsmvRTsV5RrbLf3jJoKYA+wCsOx04Mx/qsQsEOaaomtaxJZhU XV/mhp0CV2EVze2whkJuRZNslFbv/3t1aZeY4PJ9IZW3ws9RIOWP2+WiuiYqs+4MOV Y5vy6Qq2xm8/BCUD8sBz9NMait3NUBXFkKst7k6sjTkZXm3HNNF/aFnatpGOJ4lC6B ucsAKOu/4ztpiiWYy/ZY6gbiTQeUiYBpG7o8JyZ8MjM4rdOSGnGCu9oZCE2FTMfb6b NiLShWgdjLlmJQPJO5tg8CJPBTwCPvnTZGZe/D1QONxTNDeqcfqCu+rwrYQNhMIX4/ k5hYeY3Xt8AjA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH AUTOSEL 6.1 10/25] drm_lease.c: copy user-array safely Date: Tue, 7 Nov 2023 07:26:49 -0500 Message-ID: <20231107122745.3761613-10-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231107122745.3761613-1-sashal@kernel.org> References: <20231107122745.3761613-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.61 Content-Transfer-Encoding: 8bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sasha Levin , Kees Cook , Philipp Stanner , mripard@kernel.org, dri-devel@lists.freedesktop.org, tzimmermann@suse.de, David Airlie Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Philipp Stanner [ Upstream commit f37d63e219c39199a59b8b8a211412ff27192830 ] Currently, there is no overflow-check with memdup_user(). Use the new function memdup_array_user() instead of memdup_user() for duplicating the user-space array safely. Suggested-by: David Airlie Signed-off-by: Philipp Stanner Reviewed-by: Kees Cook Reviewed-by: Zack Rusin Signed-off-by: Dave Airlie Link: https://patchwork.freedesktop.org/patch/msgid/20230920123612.16914-6-pstanner@redhat.com Signed-off-by: Sasha Levin --- drivers/gpu/drm/drm_lease.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_lease.c b/drivers/gpu/drm/drm_lease.c index d72c2fac0ff1a..b7362356e5448 100644 --- a/drivers/gpu/drm/drm_lease.c +++ b/drivers/gpu/drm/drm_lease.c @@ -507,8 +507,8 @@ int drm_mode_create_lease_ioctl(struct drm_device *dev, /* Handle leased objects, if any */ idr_init(&leases); if (object_count != 0) { - object_ids = memdup_user(u64_to_user_ptr(cl->object_ids), - array_size(object_count, sizeof(__u32))); + object_ids = memdup_array_user(u64_to_user_ptr(cl->object_ids), + object_count, sizeof(__u32)); if (IS_ERR(object_ids)) { ret = PTR_ERR(object_ids); idr_destroy(&leases); -- 2.42.0