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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D50E9C4167B for ; Tue, 7 Nov 2023 12:30:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234793AbjKGMaY (ORCPT ); Tue, 7 Nov 2023 07:30:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234564AbjKGM3v (ORCPT ); Tue, 7 Nov 2023 07:29:51 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26B1D28FF6; Tue, 7 Nov 2023 04:20:12 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FD44C4339A; Tue, 7 Nov 2023 12:20:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699359611; bh=EAin0Iz7HjJBvD7enrdAOQwKVvCQ/htBJNRVoA2Zma4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UHQDL95uaFfREXFxGjHPSyG2F3LdTaJO+82SfgvjXk83480joxK+d6V2CPsaxJZIR rrJxXyY6pLBv33e64GaEAjk8DANJYS/g2glDpdqhbFUG+zUplJIhwQt1QI7g63UgT1 X0pT3NjxpfL3YLk5jmia6mbqG6acjNwRVHJu1K7HFufhLxl/gANdMtRoWwrKvF/MY9 WkCQF2EhFa7a7BQgw9DqAJ9w6F9hJI/MKE2yx522yHbnfp/GHkE2WB1/4AW90AUDwD UxzjapYCflcsBHzvyyiEWm9O/tZ+Yy3R26/46txjRerJUIuLy+I2xOt5GhOlZ4HOPy L7dC3dbP45Xww== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Philipp Stanner , David Airlie , Kees Cook , Zack Rusin , Sasha Levin , maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, daniel@ffwll.ch, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 6.6 17/40] drm_lease.c: copy user-array safely Date: Tue, 7 Nov 2023 07:16:19 -0500 Message-ID: <20231107121837.3759358-17-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231107121837.3759358-1-sashal@kernel.org> References: <20231107121837.3759358-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.6 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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 150fe15550680..94375c6a54256 100644 --- a/drivers/gpu/drm/drm_lease.c +++ b/drivers/gpu/drm/drm_lease.c @@ -510,8 +510,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