Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2502159pxb; Mon, 18 Apr 2022 01:31:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydOhoIFJHQ+h5jWZvIQt3zKk561yF2+SjUQJTP+5/qdYQuaaVCGwNrGVnljSuqZfQOwKSP X-Received: by 2002:a17:906:22d9:b0:6e8:89f7:c2a7 with SMTP id q25-20020a17090622d900b006e889f7c2a7mr8206411eja.486.1650270701832; Mon, 18 Apr 2022 01:31:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650270701; cv=none; d=google.com; s=arc-20160816; b=CX6bY+3GFuhsyTPPUucT5KvUX9Oo+apHdo3NBIm3qP9USrhC/NOIG8hJHT15yj1bmj 5TyxY/FRTo70j5J/kSdg38yT+aoaQxcmkG45eu1hZivyDhLH7DVuOqlRlRsgj5RSTyX5 bBQqZmIdyzFj3ZCHFS8hYQ6hcxenKkFg/xyDA+JwTjbIV6drdZ8JoS5eyOwyOwYNYuBB FjeIBvdE416UDpA5dsxL2kDaX4bwIZmZUtzOGrUuAeVBRLmbJ+AOgmMiEv8gT6QfvC62 FmroQtbUT519UwkDzpMMBMvT5LgotpYp98gqXN9Pvrw1fUwogpVyItC2LBVTApPobIbc 8gLw== 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=OJxUdInRYcT0sJPXwLgu1+YN1ry2eJZZdXd/7pGx4DWWKR+FEEHC9dsFPl+cFHrP8i +hzwrFA2iuPyaRYesaySy4yABsyQToSy1K+S+LG5G8s25BE5qy3rgZsgkxpMOC6QOLX+ V6hlFYjbADlIdxxuQwerVeK1gTiF84VjBu8inCLNheZfagfJuXXGnN0/hK1FS5cCFPVa z0Bv9sADpikDjOx9C3ziY+syOif/4nx+RAPKdzPhJJP9fQfUotsLXE/f/gp0bpP/t8tx YRJUDygtCknv4w3qWRX5rx2BP3OHmG02h9eneG9bvc8GB3OuXdrMRQi7WzlcQ3fn+oVV ClHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=euKGhV6w; 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 w13-20020a05640234cd00b0041d38202363si6737928edc.500.2022.04.18.01.31.17; Mon, 18 Apr 2022 01:31:41 -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=euKGhV6w; 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 S235168AbiDQWkQ (ORCPT + 99 others); Sun, 17 Apr 2022 18:40:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235156AbiDQWkK (ORCPT ); Sun, 17 Apr 2022 18:40:10 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE0FF17054 for ; Sun, 17 Apr 2022 15:37:32 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dmitry.osipenko) with ESMTPSA id 9CC111F40EAC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1650235051; bh=b2ST04zm/Wc2+g1oGHK3LnebsnkduuUXRdFzzBAvqNs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=euKGhV6wxe79vsD3qJH30txTOQOrY37yOEpfrrHVUQdDjFyaJExbfk/stNaCRyWTD WbDY8RClBWUS05jkcu12wxRZaeSYZ78lADZ6Vj3/N6PuJsldKqMr4AZB4C6vfQs9me uK1pbkKPzizLSSVRGvoFhH8WsLDB2cwhjg2QB+NyBWD1GJcVdFygBWcNlDl2LTZYca SCUw47f2MCUeTvNlBONGWeL7aCUQJLwl4cA+8EVcVdXF2NRDsyoh8fVfx0Za3ChkfE e6q+G6MbI1thP9t5uW0ccUJGQM6LJzF1qUdhVRaElgeHY1n/NqMevDqGgfEkPIr5yF DBK0QaBoP/Q+w== 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 Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Dmitry Osipenko , Dmitry Osipenko Subject: [PATCH v4 02/15] drm/virtio: Check whether transferred 2D BO is shmem Date: Mon, 18 Apr 2022 01:36:54 +0300 Message-Id: <20220417223707.157113-3-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220417223707.157113-1-dmitry.osipenko@collabora.com> References: <20220417223707.157113-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.1