Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1584414rdb; Wed, 20 Sep 2023 13:24:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH+n1CxkYUKX66Jkc48nE2H5pksi/dS+1IxSlK5hHa8O+9vqMgcPf32vgfwyHfDTzViY5+Y X-Received: by 2002:a05:6870:4686:b0:1d6:790e:ddf8 with SMTP id a6-20020a056870468600b001d6790eddf8mr3724573oap.5.1695241461958; Wed, 20 Sep 2023 13:24:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695241461; cv=none; d=google.com; s=arc-20160816; b=ZxyLJRjamofOLeNSYYnpxobrQPhWebmBjl/zgtDLRmeMBLommwNAq1JCHajfXghlDB mhKTo+vL0EDmapgWnU14SQDczDdJnyBhrFW5t5HJCGTlRNfT6HBDdxC9Yl16+D+edvER t1928GurPOvNhRhZifrhbfdNqS2qimnLb0+VBr/3kqNVW/7i0iY4CWAMvAdyzB0AFy9W 62tsSMIAVt6dLleUApucqUVSokECfEH0flS6NgnC/Uf7bxgCv4gpm0RDdcYKmLJsFVUs D/Z3mWHd/JGbfo25zKf3dlkeLvlQ/oZ2mki0Dg8iusQPjrg2x3ffTO9743z0ke5I5BbU 4I3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7KRPqkETTBVBC/zv1aXEUiiiXJ1Cft936yka0iGNazc=; fh=a4j0VewvT2hKE5plEC9nWvrQHtBT6GynD5BDsGrJ0BA=; b=FhhHJaw+D/BL0Sp+slhiStBEf/QGhSlmXEjKNkrg6m+tdEym6RIUoxLXC7MTPxiB47 OhdoLMRQTaBz8sYxUTm2t5crEapupouJTpYEz9P2ZoTz1PkrDsG1tJq0vCUSzQ1M2X/a F8xNzKYHAuD3ZQ9x0Nh94iN05QMwH+cz3w5HZ3w4rRTf/A5bnhxoAoC5HP8InkpBYNb8 MOA1U+rfSlJ8II9VsOzp2tguVCDIqDcczLpIQ4F4xR9XpKLv2tTDA0tlu6L/tW1oq1IR F8CunSmX3X+XbHi6rJdJlJIhB8br090Y8PJ+ncnOYoLQPuJGEkieOAxKJy7UBbdVw3o+ Lpkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NsQNVBVv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id s9-20020a63ff49000000b005698cf29f75si12403238pgk.222.2023.09.20.13.24.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 13:24:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NsQNVBVv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 6DAD1820E512; Wed, 20 Sep 2023 05:38:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236088AbjITMiK (ORCPT + 99 others); Wed, 20 Sep 2023 08:38:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236049AbjITMiF (ORCPT ); Wed, 20 Sep 2023 08:38:05 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA7CD8F for ; Wed, 20 Sep 2023 05:37:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695213432; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7KRPqkETTBVBC/zv1aXEUiiiXJ1Cft936yka0iGNazc=; b=NsQNVBVvn8cHPjczHEd+ce2WPl1ngK2pnhiyVc5PtQmWoQ8d+Py5Z8jmz44+yOYavYNmvm GWyQO5jYZh4eydeAyxzk8JDq0QT5L4jsUe495Rdh4Q4RvcX9PvlHJTQMnRNrKQOs76hVvA 3NXHExGLPza5WyCqKStB0fDDqnXyRbM= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-638-4e45YJ1yNf2nIe3wTP_STg-1; Wed, 20 Sep 2023 08:37:10 -0400 X-MC-Unique: 4e45YJ1yNf2nIe3wTP_STg-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-404fc59b8acso13443825e9.0 for ; Wed, 20 Sep 2023 05:37:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695213429; x=1695818229; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7KRPqkETTBVBC/zv1aXEUiiiXJ1Cft936yka0iGNazc=; b=lVMTfTHCdqXVUxa/8BdisZ3vrnHMjeJe31bjz85LUpA6zZPXvzYVpay6b9EWKf1bCP aAlgT6FQUmkeJxKvQd/td/c8KK9EALcy/7Xjr5nvf78DfevPQWljROmiz9PEtWbMJ+JQ aRGXUoD5KTQpBFxFkE6foRv5w4UmVLsBT4Ww8ZgkxrF58AqMthqC4egIw4DhmFHGd67y 8jz933qFEwccVk2M+gZmgFZIgla+KU4uVKPO+hGHHHxXp6lWd1XJr8OotPSLLg87JdB2 rW1akAabgynh+AT0mJg8mxLPqJxo3RUyRUGF3482MhHAegpZl4sarfVSVgLlDCGjWq3z Nawg== X-Gm-Message-State: AOJu0YxIf/THX7695kz5EcI/pHzK6QXppN5rprGiotD8b1U6ITKS7Ozs wNeDX2DkAGkIAo0a7Os6leL95bxo3WOWobGWqxvf3XBmmIjOLokxrAxwWoKtTlIk/g3XrL6uYW3 uJrhRHjHo4gRQhc/q3oa7+lsf X-Received: by 2002:adf:ec48:0:b0:317:630d:1e8e with SMTP id w8-20020adfec48000000b00317630d1e8emr2031480wrn.2.1695213429376; Wed, 20 Sep 2023 05:37:09 -0700 (PDT) X-Received: by 2002:adf:ec48:0:b0:317:630d:1e8e with SMTP id w8-20020adfec48000000b00317630d1e8emr2031462wrn.2.1695213429120; Wed, 20 Sep 2023 05:37:09 -0700 (PDT) Received: from fedorinator.. ([2a01:599:906:7772:a505:d891:dcff:9565]) by smtp.gmail.com with ESMTPSA id lg13-20020a170906f88d00b009ad88839665sm9297787ejb.70.2023.09.20.05.37.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 05:37:03 -0700 (PDT) From: Philipp Stanner To: Kees Cook , Andy Shevchenko , Eric Biederman , Christian Brauner , David Disseldorp , Luis Chamberlain , Siddh Raman Pant , Nick Alcock , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Zack Rusin Cc: VMware Graphics Reviewers , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-hardening@vger.kernel.org, Philipp Stanner , David Airlie Subject: [PATCH v3 4/5] drm_lease.c: copy user-array safely Date: Wed, 20 Sep 2023 14:36:12 +0200 Message-ID: <20230920123612.16914-6-pstanner@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230920123612.16914-2-pstanner@redhat.com> References: <20230920123612.16914-2-pstanner@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 20 Sep 2023 05:38:08 -0700 (PDT) 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 --- 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 150fe1555068..94375c6a5425 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.41.0