Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp966662iog; Thu, 30 Jun 2022 14:01:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sMLzofV/8RZgwgyaGMqc6sj8UkBEbAw7eBkNbM1IFsocelTweJAyquuRrfokgEjlCi/qHE X-Received: by 2002:a63:8848:0:b0:40d:e25:dd99 with SMTP id l69-20020a638848000000b0040d0e25dd99mr9039971pgd.603.1656622900470; Thu, 30 Jun 2022 14:01:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656622900; cv=none; d=google.com; s=arc-20160816; b=GQRJRVwXsXzOr+Xnb9vCpZAi2wDZfAlmr5ICU1qrbqaLuJH8HOmmr7JPrtTZfKJnMn /dmzVCRyclVymOc3YSPpju9FYUc4TMKxkt6Lsdralq3oE9efi8rC1ocvQsi9t2kABGUS 0fAmxDWD+QvSRKYgj23ipFhe/RwaICR9yAog3QBSDPj+rxFH4nqZTu8eegYFy8+6UMBv v/llgNUTKpiDUozBK16GIex5zwdVMv7RRQpRLzmvul00tBkEpBqeJ1FvvTvvO00KNIKL 5kFLwnIGJYVhWVQwEnYbrDOGZw60stRQAVwnnfi5OnU1g95NaIEeAILooZ4Ggd7v74wa vHmw== 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=zGv7Lkqze2mHOe7NuNe8HL2z1ZyJ6I9nD568Hkm0z8Q=; b=nS/Xaxbfny7WOCLDQp1zOnTLz1FBFVy6ZNetUUs+5XI2rYGFpdCKBb6/HF0aMmO8JR O7J1QjGXoh5fwgK6UVq29vS+vaXhZKxrxH77tA3Z219UIxd5ZRA4+UPNobkzzDhghwZ1 EYGsplRjJfrx0lFYvNliHl5nx5Y++G6dQCEEfpCrDtmlDM9T84n0rU6JEpY4BDkaOpzt 4MXE2OYbO0NgAtGR53/jX7+gbPOPqxRcDq0pMtUEXg3koJiSH1YxW/Q1TWpe84m3fU5V YJF1UTc89rdKUkVcqC61PTOAzeHVfcX3nbHELTl+utGTj1Y4meSNA4xOqGimi+TBAVRW LkBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=DxkqE4B1; 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 l191-20020a6391c8000000b0040d4a4adb72si27103741pge.560.2022.06.30.14.01.27; Thu, 30 Jun 2022 14:01:40 -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=DxkqE4B1; 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 S237044AbiF3UIA (ORCPT + 99 others); Thu, 30 Jun 2022 16:08:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237029AbiF3UH4 (ORCPT ); Thu, 30 Jun 2022 16:07:56 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23F414477D for ; Thu, 30 Jun 2022 13:07:56 -0700 (PDT) Received: from dimapc.. (109-252-118-164.nat.spd-mgts.ru [109.252.118.164]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dmitry.osipenko) by madras.collabora.co.uk (Postfix) with ESMTPSA id 0FB426601986; Thu, 30 Jun 2022 21:07:53 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1656619675; bh=RJ86DMSaOO7AVg96MzDPxQsREOUycec8sRHQCChEvxI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DxkqE4B1wkW0KN/8C6iubGusFgKuQg6nt0yw+1sP/4LfL9+If7TdEx1jHNpz6dIld 7lp2YVfr5UQNjnwKVm5crMPCQcI+vMs1ooTGDJXbkLGn5IqBSaPfsMS4KI5as0hEmh dFL017OMV22Rw5Sp0bB7jZA2PtAqZbzcYH0ui0kkFvUzz9M7cp1DOW+rGTrrBGJO3j 40HUsSBFM/vSRwyW6vadAJuAWrjUE7WslONQsdy8RDViIyA5uVNKP0su5TmKGj0dAQ 8npP7ZqrJiw/HslxN6djBBsyho98pFt7JxzL0hG0b8IvgNAEYoZh7YFIeJ3yAn3a1p 2v8CwD4b9XaRw== From: Dmitry Osipenko To: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Thomas Zimmermann , Emil Velikov , Robin Murphy , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Dmitry Osipenko , kernel@collabora.com Subject: [PATCH v7 2/9] drm/virtio: Check whether transferred 2D BO is shmem Date: Thu, 30 Jun 2022 23:07:19 +0300 Message-Id: <20220630200726.1884320-3-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220630200726.1884320-1-dmitry.osipenko@collabora.com> References: <20220630200726.1884320-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_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 b7529b2b9883..1262fd0b3bef 100644 --- a/drivers/gpu/drm/virtio/virtgpu_vq.c +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c @@ -597,7 +597,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.36.1