Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp809453pxb; Tue, 12 Apr 2022 14:03:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwB5Dx08BkDdhcyQJBYH8rRIZKdyKZu6JUf9dDpPVPzzLr9m4RMsAEh9uGnWrkUwuO7RVph X-Received: by 2002:a17:902:8217:b0:156:9c4f:90eb with SMTP id x23-20020a170902821700b001569c4f90ebmr38524655pln.121.1649797435396; Tue, 12 Apr 2022 14:03:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649797435; cv=none; d=google.com; s=arc-20160816; b=TTLHQER8iUVoj4j9e0gP1mrsy+2JqxMaxIOHr6+Ca5HQwlD9P4QiPHRc0N12d81JZ1 i+1HIBwJX5oJ0cuBb8Qg4i+Pi3dCoGjngDVoWNgKQ6V7zBwB6VPrAFqVvniMkrCSbCPP e+4pz4yWRoqpui7T493+WunD3GGk6mxU+LYLWhpL+AyODlLpbYWvnCoCkaCdNTWjZqwL Bsscad10KqHlBZYxWyoug/7tXYvYf/wx10MoJmfYzLhYPAz9SQg2kdtAF+IxjCrNl2dK 9xvATXoLygxmpjMlcdEEF49+BNc7o9o4RshQyKptOURNlMTy2slz0CGV4q1Fmnuih1Cl ofMA== 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=tegJaHhpyTIUVX2RbkG057ViI8FxSVzXTGkLbAlmE5/PAoq1iCdyEcRTQaCrb6v1tK MKrdT/k6cMfxESXPaf9Yvr98BwlBTyLrEg8Z99Ypjgv2RMOe7FoDCo+HRx3juxiT6C2M /Kdie2HoB5XGAzT1mEzzjrUEA/CRd+mfMHM1stD1htfEKe8kXpT//i5BmiVYzGbuFk3M TuMh70I67xlJlMfubr9Q8mvCxXTQlHzNnIFGBZSl8RUYOg6zwv+CEQGxYHTlK7J48lEn OVHdVzKeUJPcZIkb43rcFJpZiNqhVILN32TZtLEspR1/Vm2EvsSS6WL8KZ9eht1sq93s W8SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=g7Vr1Jab; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e4-20020a17090301c400b001587170b013si6079936plh.546.2022.04.12.14.03.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 14:03:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=g7Vr1Jab; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CF8D4DAFD6; Tue, 12 Apr 2022 13:24:24 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350355AbiDKWDU (ORCPT + 99 others); Mon, 11 Apr 2022 18:03:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350373AbiDKWCk (ORCPT ); Mon, 11 Apr 2022 18:02:40 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9697426C for ; Mon, 11 Apr 2022 15:00:20 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dmitry.osipenko) with ESMTPSA id 317931F43C7E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1649714419; bh=b2ST04zm/Wc2+g1oGHK3LnebsnkduuUXRdFzzBAvqNs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g7Vr1Jabyms1/C+YkMzYjic/knwWRp5rQrjPhU5jgjsKz9oIu0/hHqi1yo/dKxXWU yv7z+M5b+R346aIkcH9+n04Ze/4g5NF3EpqcGyXto5Ee7q0K9sV2JH8wDKW0JBBIoD FIJpv3eBpRAK4zsLr4kaEKVVwQGPTn11rxAUYl+cUDoIbMoTQZItG0r5gM5IM2DIo7 OUxZT8q7rm7CvZtW+psCVue6hHR93wQ7LXsKlpMTbv7uKSgf1JvLlaRyxS/Ie5K3sz orcjZPHqmsd9yjrpGKFiNJBUzXtYyRJDpc0eNbaRwV58OhUMfsOalXoFkUVEzzGdTO L75y98aim+A/A== From: Dmitry Osipenko To: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Daniel Almeida , Gert Wollny , Tomeu Vizoso , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Rob Herring , Steven Price , Alyssa Rosenzweig , Rob Clark Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Gustavo Padovan , Daniel Stone , virtualization@lists.linux-foundation.org, Dmitry Osipenko , Dmitry Osipenko Subject: [PATCH v3 02/15] drm/virtio: Check whether transferred 2D BO is shmem Date: Tue, 12 Apr 2022 00:59:24 +0300 Message-Id: <20220411215937.281655-3-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220411215937.281655-1-dmitry.osipenko@collabora.com> References: <20220411215937.281655-1-dmitry.osipenko@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=no 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