Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2451175rdb; Thu, 21 Sep 2023 21:17:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEM5REkpOe7TDtK4xHnYBDbVLEFtAEMWnQTvPc6Wio+7CKwJUVC8DiptUzoTz232e4FG8kU X-Received: by 2002:a17:90b:118a:b0:268:ac3:b1f6 with SMTP id gk10-20020a17090b118a00b002680ac3b1f6mr6791810pjb.24.1695356247100; Thu, 21 Sep 2023 21:17:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695356247; cv=none; d=google.com; s=arc-20160816; b=NbJ008Hot5sc15WzZo6rlSIpJCFkgVWiuQt0pYXEOJW3qAyf65nku9A2mCH2VtLLY2 y0E+UYV3qVsIE9ExtxuRfjuc2S/vDT/cs5gPrBpj9WT9T/OHSuby3x4H72zgPWuCOurM uIn8a9YLY/DtvK6xmnAltI8hdKKobNJYJNmwYl3Baer1O3Xd58EOX9GR7WhZAVCl9rIa gxHSE9YdddrCN4p0WNfHf4NkKOEgwzIZOgx9U0aExkWeaugyiWPshMQLOQwIHcKf+OAU x6Ay1v+26wxUMlcD4tHKSqvYQYCggtWTOAN9RVQzp9dDYTfGPDCj/+xpWmQGVBhW/32+ SLiA== 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=/re3vPWoYJ/6xHLpunyVTZgfJ3oWhQoot3M15Xf93m8=; fh=a4j0VewvT2hKE5plEC9nWvrQHtBT6GynD5BDsGrJ0BA=; b=zc+hBr8O9+9jBh5FsmRAGhQ24ICC80K5yO4bwyOGc9Srb1LpLb2zwDBK1hGGap5tmM krJdH3erA6d6/nzNG07fIq6IrXaZwkiMOG2pFIJxH9Bttg0Ml17uPhnOMssOxpUUsfY9 6jpcJzR9PM63Oy+n0DI1GswHluOw+VQFNqQ+pKK41pDCMJfgXvyfgGt0yLdLMwhNSnmW JhUBZVvEeFsTsdWgvz7sg8R2voInGSZJfQL92uQO5DjYq9IE1YOzIVTFZfil7PlhE8SO HIWcQyNLrkskn6zMLtY1UyOIBvbAvViSE6xwKO+ZOm7FK+Y98LZn5clpsyLR57m8x+ug DNTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fun9RKCV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id rj2-20020a17090b3e8200b0024e4ace1a41si3278307pjb.183.2023.09.21.21.17.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 21:17:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fun9RKCV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id BD79B8021E3D; Wed, 20 Sep 2023 05:38:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236063AbjITMiW (ORCPT + 99 others); Wed, 20 Sep 2023 08:38:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236064AbjITMiU (ORCPT ); Wed, 20 Sep 2023 08:38:20 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90AACDD for ; Wed, 20 Sep 2023 05:37:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695213446; 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=/re3vPWoYJ/6xHLpunyVTZgfJ3oWhQoot3M15Xf93m8=; b=fun9RKCVYIFO2NpscfgqRbewk7rWIr4IcMr0+xs1le64fQaaoai57DN0QqxYOjR07SuBy8 4Gi0Z3qSX7cF4BEqgTSbTXauwOc/zwltUc7VE2Ij+9JUu8HfOSZJbnYdbIMsAKsuicGX3A CNDyu86JF11RjZ76wAFybIhjKgXFhcg= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-537-ZPzisAiJNOi39mfhGckCng-1; Wed, 20 Sep 2023 08:37:25 -0400 X-MC-Unique: ZPzisAiJNOi39mfhGckCng-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-9a9cd336c9cso154954366b.1 for ; Wed, 20 Sep 2023 05:37:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695213444; x=1695818244; 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=/re3vPWoYJ/6xHLpunyVTZgfJ3oWhQoot3M15Xf93m8=; b=lxqmH0dmAsRYOWZ0uzYC0hZPVehCe0w6tfWGfRHZSaF1QpLcnyx4Giku3NoFhNo5gR 6Ys3qe8JuPLTLYfqOzl8RdRNHkq/IOWDQ+9tKyX6JGS2nWMixjc2H0rucHleSwpbUX67 9Fi1exFeM2aCSNbifjKP4XONQLvPYhPT0Euh6ua/GaePXFZRpO6uG3/JPNMS1vwr9rRM ctmk4uFrhmP5WkoF8CHvArzKky8XnrjIKrOCqp5MJUSKGVEebQjMHeDApY1OidqTvRDV CStik6QwVdIOYkZIcvhnJ4hlRJ35a9wD1CbuOPiZNUcDivy8Jft8YTAW2UsyzxaBbdHW ErMA== X-Gm-Message-State: AOJu0YxAJswF1tek89Yuj6woZbSzo7TXY6yOnP5x5i9yexG08KQ03nrq IJ16jIvvBY7twiq/R4liixEdQtqhsYrmDCeBCI/szRU6WbK5rjosypSHhaLJp7Srkni9OqsS9BE ODj3TWdDzchHp6D4JiXLsn3MQ X-Received: by 2002:a17:906:1d4:b0:9ad:f4d9:f6f2 with SMTP id 20-20020a17090601d400b009adf4d9f6f2mr1978098ejj.5.1695213444578; Wed, 20 Sep 2023 05:37:24 -0700 (PDT) X-Received: by 2002:a17:906:1d4:b0:9ad:f4d9:f6f2 with SMTP id 20-20020a17090601d400b009adf4d9f6f2mr1978090ejj.5.1695213444350; Wed, 20 Sep 2023 05:37:24 -0700 (PDT) Received: from fedorinator.. ([2a01:599:906:7772:a505:d891:dcff:9565]) by smtp.gmail.com with ESMTPSA id h11-20020a170906854b00b0099ccee57ac2sm9233184ejy.194.2023.09.20.05.37.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 05:37:19 -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 5/5] drm: vmgfx_surface.c: copy user-array safely Date: Wed, 20 Sep 2023 14:36:13 +0200 Message-ID: <20230920123612.16914-7-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=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email 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 (fry.vger.email [0.0.0.0]); Wed, 20 Sep 2023 05:38:22 -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/vmwgfx/vmwgfx_surface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c index 5db403ee8261..9be185b094cb 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c @@ -777,9 +777,9 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data, sizeof(metadata->mip_levels)); metadata->num_sizes = num_sizes; metadata->sizes = - memdup_user((struct drm_vmw_size __user *)(unsigned long) + memdup_array_user((struct drm_vmw_size __user *)(unsigned long) req->size_addr, - sizeof(*metadata->sizes) * metadata->num_sizes); + metadata->num_sizes, sizeof(*metadata->sizes)); if (IS_ERR(metadata->sizes)) { ret = PTR_ERR(metadata->sizes); goto out_no_sizes; -- 2.41.0