Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2816298pxb; Mon, 25 Apr 2022 03:11:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3SQM+w4jsBqUD7SlAEo8OmFqLUbKXm6Jj9eoPLEB9c1zmcapIY5JT0xO+2F1fy5klweN7 X-Received: by 2002:a17:907:3e11:b0:6ef:78e3:8d9b with SMTP id hp17-20020a1709073e1100b006ef78e38d9bmr15627397ejc.373.1650881476555; Mon, 25 Apr 2022 03:11:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650881476; cv=none; d=google.com; s=arc-20160816; b=mMa7q3Az6vQLJkDdOLVOvmeaer2Okog+yLVjJaoSYUNjsA7fVhbJemi8ZIuRqOIHFQ CkETmQjg8vzfHiQMwE7yfH1VNCCUzxPkWvayBM5qGL4FZ+c4AwEeMYa04XTAyidNwYVL Z98oKxh5gP3CcTsCrBEX8PXUJinNtC6wP6z1HnxPskcFt0tDSnjDZqK8ivmGAjT+URDT nFMd1vsTB/An+Ne3vAYSjU/J8RQozMImHFAtSg4cPx2Kdhmg1lUkjn4y6AEbWkKnNEOg /hTNeClPJITj9HU/+wrnFGLgrz7GaRwVXbAGdrJwrc831zs8e7ljn/kjxxRx+DJWA7YW Cv/w== 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=vrAmA8KbTIkKDwhKLoXPF7fN+sgrU68oEfGthM9fIXg=; b=mVJTC4HUP3hpbiAzv6O1KOnln//T+gM7jyrcFFvZRiFVouypUbfp0lAwINvyFJTni4 f53gWnoxYN80JVuR+i7FNfX7papn1wF/KjN5fI/Fk+6b3qaK94hy8DcenfH1Bqil6oDF NdMSY4SLm/TAiMXaMHplcDcqlq2kc6u8Tiq3Va8aZU/DF4Jlam+AdoWm+0NWpQMTxM6k oujSKVd6ugE/uzl30R+4UHh6yxYteVd7RkZ2vobhV7fnfBHK7HLCQ7GwzVCQNxUSq5EW oSIBX2ub/jn2WsqzfzyIFTVx0FEw9CbhQ58p8JClC/dPFJo3OE2+l6wD6RAU0ihMZNuf jcDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=RYqZIrqV; 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 g7-20020a056402424700b0041d78c5d503si13938850edb.514.2022.04.25.03.10.52; Mon, 25 Apr 2022 03:11:16 -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=RYqZIrqV; 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 S237646AbiDXTH6 (ORCPT + 99 others); Sun, 24 Apr 2022 15:07:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237675AbiDXTHm (ORCPT ); Sun, 24 Apr 2022 15:07:42 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B731213977A for ; Sun, 24 Apr 2022 12:04:40 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dmitry.osipenko) with ESMTPSA id AEE281F44DAD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1650827079; bh=b2ST04zm/Wc2+g1oGHK3LnebsnkduuUXRdFzzBAvqNs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RYqZIrqV2Et/qyugz9gIMrhJiZsmfGJNjT6FM6SWwMyYOQV8s8YN/GSTtA2dGwp5u p49w6MWQWN428gleVaqnJ1Oo82dX//FO8P1Zgq/YGDXK4dmKMYyWANGnBx6kP/Hxgi bSztUra9mR26Yclfgj5wBKXQdHA8Kvi+j1N8DlblfXcMBEt/B+MbQC9dRahFw0PCKW hSu44gaH+pxgo6/kOVHnXUwr50a4jN7WeEKYvCT4vJy4WuUYkxqaOZ/TCAC7V7nKsn wdFIJxwP1nxignskSiJ7LARwKSbD4lyoqDMxSg+2CJNDCb8/fuVm1VNvyMAJIXCdmd qC2QwCBYTwYHg== 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?= Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Dmitry Osipenko , Dmitry Osipenko Subject: [PATCH v5 03/17] drm/virtio: Check whether transferred 2D BO is shmem Date: Sun, 24 Apr 2022 22:04:10 +0300 Message-Id: <20220424190424.540501-4-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220424190424.540501-1-dmitry.osipenko@collabora.com> References: <20220424190424.540501-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, UNPARSEABLE_RELAY,URIBL_BLOCKED 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.1