From patchwork Wed Oct 19 08:22:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4553 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp204498wrs; Wed, 19 Oct 2022 01:46:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6WGlLQexbl8n7fInXCObtru/UNUMog9boJJX/TyLthkyCw/7p+d1MslyMi7O138k2gn6Ml X-Received: by 2002:a17:90a:5914:b0:20a:ea11:2620 with SMTP id k20-20020a17090a591400b0020aea112620mr8619644pji.34.1666169177856; Wed, 19 Oct 2022 01:46:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666169177; cv=none; d=google.com; s=arc-20160816; b=CrDjoi1+xJdQX12ezUuSsExfLsYzwiABP37oa8oGrqCnH3zyZu7iOHIChJgCQYAvno UoIWwV5aGbiwVniZctBC1A8EfiOw06JebiOvlwAu2ewX8vo7qD/0vySsprTJvWkHK4SU 2jTv1NZbk9cw6qBTsT283VcqhpL6ARGIsgVqUev+X6OJcruTj9vz+aJ+1TXsx0bEqidc clZPPU78guD4s7w5PSPc21lAyopQnHFSRhkETYSbsr18kBdhdgMLUug1oDsKa53PDCDA rjeQDvE7GQp0UoxMHDkrNz6yOH5QrBGU+rb5yGhXAKEEJcMIhdd/AOtUelnrSDpsK1Zs E15Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xlAMPZN5+Rzh3w2HEHD7JCccyqo0eG99osSh/QTzy84=; b=I+NpmoOg7voD7wYX8eborJLX5lfFpY+lUD/QOSLB7uDwW7R8VkhKc9AYTGlL8t06Fc lJ+ePFMUedUFCttCqutiE02DNoO+rBzrjkirydbv5CO77yOBy940jJPbOoWpVJVgF98y 8k/qtBKtoPoLp2sJpeINYUdCOpLjnv+ev4Z3ebjKlazKqDCwvu9aorxBtGVQWIED4gXb 8d1gYHZey3bYWPDhJKNfQPH4QqRcK+K7uP2lnXDc9vNLW9JB9zZm1DnTsDb0IYxF/viM /84IDdN0FNXtVtdtjMiJpshzB37H0xkGMqoTRG9QwJEpGsV01Vjo6m6Ry3mdVX4mnVdn GvEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0NqDg3XW; 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=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w9-20020a631609000000b00458ce4748f6si17884307pgl.409.2022.10.19.01.46.05; Wed, 19 Oct 2022 01:46:17 -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=@linuxfoundation.org header.s=korg header.b=0NqDg3XW; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231389AbiJSIpw (ORCPT + 99 others); Wed, 19 Oct 2022 04:45:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231488AbiJSIoQ (ORCPT ); Wed, 19 Oct 2022 04:44:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DED1C167D1; Wed, 19 Oct 2022 01:43:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8725A617F7; Wed, 19 Oct 2022 08:42:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94BA8C433C1; Wed, 19 Oct 2022 08:42:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666168965; bh=al3TEvPjWVGD/y+h+KKD9gzbsKzSiEXqSPPLy5XTUTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0NqDg3XWm2GddXjoeMnO6vQmfeYGdxy4oieSa2dFk4XFSxmHnKrOLRmjWY1fMqtlI 5Nwdhz1xO215iwE7SgkTbkvbpsEIdWE3WECvAG1EUkywLGD6cMJ19Vz2hxSrtV25D6 zhDx3KFmXg2QZ3+mBLjbcFUA8EzxQ1BvGaEvd2fQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Emil Velikov , Dmitry Osipenko , Gerd Hoffmann Subject: [PATCH 6.0 074/862] drm/virtio: Check whether transferred 2D BO is shmem Date: Wed, 19 Oct 2022 10:22:41 +0200 Message-Id: <20221019083253.201327292@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747105011730884067?= X-GMAIL-MSGID: =?utf-8?q?1747105011730884067?= From: Dmitry Osipenko commit e473216b42aa1fd9fc6b94b608b42c210c655908 upstream. 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 Link: http://patchwork.freedesktop.org/patch/msgid/20220630200726.1884320-3-dmitry.osipenko@collabora.com Signed-off-by: Gerd Hoffmann Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/virtio/virtgpu_vq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- 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( 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);