Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1652967ioo; Fri, 27 May 2022 13:25:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJye3NevEMzuW1kYv1UM43O7Wc6js8CivnJwDj5xmKgBUC+NylJiUyYkI29Sk4qjclVrsdzM X-Received: by 2002:a17:906:5d07:b0:6ff:40d2:1ff9 with SMTP id g7-20020a1709065d0700b006ff40d21ff9mr3590962ejt.435.1653683119238; Fri, 27 May 2022 13:25:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653683119; cv=none; d=google.com; s=arc-20160816; b=WWx2+jB/lf6y+CsEsyt1Kl+0NgN7XW8G5m4gkoRNra/lnPzlTeIVO9jXdiQGjBcofE fpgA9f5Pe5m52bzfgNQ7LkQbrrKwG/MipxoL7oXr5dR1h9NeKXDESwkFJ0zAk8AOzcHK 4VZmUqI7W5YRGBq6DTPO4Sa7nJbA11StBJg4FGf9PDBHXrDThfmz0DhAsoWeRANFgGbZ KYiCXR8wSUeOS58CAaO4pShcIe/4ebovVCoFxpW/yZi2rUoL9fY22KTrEI8mVaxKDxzn TovHvM4ZU9WxlLS8AFc2osEpNgOHX3ZjHeMdTyYO6UoOmF5MX0PFyuCsXvFForXBRb4l vl9g== 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=9kN3Suw/7rm5L+ENu/Z0rtqWr48FRW2dEWJLhb7L65I=; b=ehr+AESomAHeJTZO7eOVasE+psFRjcA0PgEqPguRgx1TbOD19l5tkrG8fOY1X6jZr3 GWSozBev5FsT/nfuxmfwoPU85IODZuBWVCwDnVxn4Ssq9gHMI1pYFerbZXIwgmHW+ukj QTlxdmvRQ7nFhrLBdhIp9TkfEGmZJBvWLuzTgZgN14SICBIEqUVS91FfktkWT57TSclv SQObA0f/5lavapFolOk1/C2N0CuM7+fymGonKLc5f76h7dulOmR3Q2/Y0M/wT/WC8ACZ rNbdqz7o3MEnqKEgjx3bywE4wjVjZc5ctakHatSlEPqIcRpBbdgEL4k/3gvQHTnTBWfi kqtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=E2dOSzH2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dd9-20020a1709069b8900b006fec955c743si2868556ejc.375.2022.05.27.13.24.53; Fri, 27 May 2022 13:25:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=E2dOSzH2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236438AbiEZXys (ORCPT + 99 others); Thu, 26 May 2022 19:54:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349642AbiEZXye (ORCPT ); Thu, 26 May 2022 19:54:34 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89A03EAD1C; Thu, 26 May 2022 16:54:28 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dmitry.osipenko) with ESMTPSA id 8F3AE1F40887 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1653609267; bh=xPahHFXhmzFRvwHWi9um3lr6dS/zSQQnyahtz13WrNk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E2dOSzH2bYscAM2yw+OsJQF6ASXzoHeHyCW2JAYd9BoRUHhbsYdmJ8LiEFfuw4PKg 9+sypQggxGc7h/M7vxZP9YcFWj+u2FkT5drukiTUXFiPtzBrkBwqGJLQAYK8ZZQPqC 3kIkbt0/wh1LzZa6jReVPQMdIoyAGL+sOirNZZxosMKbaVhSAEbSsQCPio5EaWc6g2 7WBVF1do7xnITJPp47lKbqvEd1BHUmph+ejBV/8nPwS+v5ywMOtUccLe0UFQInaddj TOuGZOeaBJhIkpw56yt4VLRZXcb/qMhwx6cBABDqhHh0pnxPh/p6ttBjiKP2QVO80L jV8dOkXnd5L5A== From: Dmitry Osipenko To: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Daniel Almeida , Gert Wollny , Gustavo Padovan , Daniel Stone , Tomeu Vizoso , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Rob Herring , Steven Price , Alyssa Rosenzweig , Rob Clark , Emil Velikov , Robin Murphy , Qiang Yu , Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , Thierry Reding , Tomasz Figa , Marek Szyprowski , Mauro Carvalho Chehab , Alex Deucher , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Dmitry Osipenko , Dmitry Osipenko , linux-tegra@vger.kernel.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, amd-gfx@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, kernel@collabora.com Subject: [PATCH v6 06/22] drm/virtio: Check whether transferred 2D BO is shmem Date: Fri, 27 May 2022 02:50:24 +0300 Message-Id: <20220526235040.678984-7-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220526235040.678984-1-dmitry.osipenko@collabora.com> References: <20220526235040.678984-1-dmitry.osipenko@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY 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 Transferred 2D BO always must be a shmem BO. Add check for that to prevent NULL dereference if userspace passes a VRAM BO. Cc: stable@vger.kernel.org Reviewed-by: Emil Velikov Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/virtio/virtgpu_vq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c index 7c052efe8836..2edf31806b74 100644 --- a/drivers/gpu/drm/virtio/virtgpu_vq.c +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c @@ -595,7 +595,7 @@ void virtio_gpu_cmd_transfer_to_host_2d(struct virtio_gpu_device *vgdev, bool use_dma_api = !virtio_has_dma_quirk(vgdev->vdev); struct virtio_gpu_object_shmem *shmem = to_virtio_gpu_shmem(bo); - if (use_dma_api) + if (virtio_gpu_is_shmem(bo) && use_dma_api) dma_sync_sgtable_for_device(vgdev->vdev->dev.parent, shmem->pages, DMA_TO_DEVICE); -- 2.35.3