From patchwork Wed Aug 30 13:45:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Stanner X-Patchwork-Id: 13370274 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 D813FC6FA8F for ; Wed, 30 Aug 2023 13:46:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9FE1D10E52A; Wed, 30 Aug 2023 13:46:53 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7415810E524 for ; Wed, 30 Aug 2023 13:46:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693403202; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=w7XXAxDLUmZdx81fESQwCFLbPlVQDp3wBmzbmeWO24M=; b=OE5ECJrGM24DknbMl8BDqzUVlOCcJaJBNR/KILwZGxOcYr01HdpI6VJdrifdL6V86Y5v18 Mp4Glq8+2pTE0ZpPoaFo5OQMLEuISOr7yTwc1oZxuMTuFrosIR1lkcHq6zE/nI64MertCD GNl8vZ3RMPx3aotlnrVz95m5v2yKuWw= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-67-9N7VVQerMf-XxJ-wc9O_5w-1; Wed, 30 Aug 2023 09:46:41 -0400 X-MC-Unique: 9N7VVQerMf-XxJ-wc9O_5w-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-94a342f1703so87948966b.0 for ; Wed, 30 Aug 2023 06:46:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693403200; x=1694008000; 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=w7XXAxDLUmZdx81fESQwCFLbPlVQDp3wBmzbmeWO24M=; b=GaZtZCaq5Ofw7vdYzv1hx8QLCzO/5jsPiZkv5ylaR1sZLdW8EbSSvrQ821CQlTevYr BOHYWN/Pj2wzQ49nRHMb7LQ7yHBdWiciJg8oKiJxsekIvqu9WPBqMzUvNzEQnd3UhcFA bzFGI6y+akuVVEbukzocrWkN35hKRAXm1fksXPtw9T654eSaSmqXcqJaKXKIRNOaWSOH nhwOFQ25FhOHWljDpsg45zGyzkarn7bWPC6yyHUEGQOkcTudujAp7xCbXAIoUnKOy9Zq WZBFqCu4v/Flamjrd/MbnSWLTffz6T1lGK9sVg+8uaA4eGbkqjcwfrstwSdXMGZM61c2 aNoQ== X-Gm-Message-State: AOJu0Yxkzi1vXj6cTq1EUmJiMcHJk1v/cBSssATBclqYpaAYl63OSEnJ eBPqLFF2G5VgaSd/maigtuiJflZhjof9bu5bKyNz8xMjDNnjvnaneFIx1rIcpqWmPmqyYpCnGrO 9n5IJcQfwbYG2Cpf4aa05iHwT9al5 X-Received: by 2002:a17:906:1011:b0:9a1:aea8:cb5a with SMTP id 17-20020a170906101100b009a1aea8cb5amr1574499ejm.1.1693403200683; Wed, 30 Aug 2023 06:46:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEFovveJ1gRkNa/hbpuOdO660EpmuFNfSfZvj7MduSJ07LTCEG5M6k7oeDfsA0MPBedrGa9vw== X-Received: by 2002:a17:906:1011:b0:9a1:aea8:cb5a with SMTP id 17-20020a170906101100b009a1aea8cb5amr1574480ejm.1.1693403200487; Wed, 30 Aug 2023 06:46:40 -0700 (PDT) Received: from fedorinator.fritz.box ([2001:9e8:32e4:1500:aa40:e745:b6c9:7081]) by smtp.gmail.com with ESMTPSA id gy25-20020a170906f25900b0098951bb4dc3sm7218566ejb.184.2023.08.30.06.46.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Aug 2023 06:46:40 -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 Subject: [PATCH 5/5] drm: vmgfx_surface.c: copy user-array safely Date: Wed, 30 Aug 2023 15:45:56 +0200 Message-ID: <6f9397d6af919b7e8325c2945385c13aaa3dc5f1.1693386602.git.pstanner@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: Philipp Stanner , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, VMware Graphics Reviewers , linux-hardening@vger.kernel.org, David Airlie Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 --- 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;