From patchwork Mon Oct 24 11:27:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8999 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp440031wru; Mon, 24 Oct 2022 06:03:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4E5TtpKBZ23ImpOr7kjivMw6GgnKi/KiowxuxtA11nKpqXExbx32Bd7Y9JnknD7NtkrSrr X-Received: by 2002:a17:902:768c:b0:186:b136:187a with SMTP id m12-20020a170902768c00b00186b136187amr2804571pll.94.1666616620014; Mon, 24 Oct 2022 06:03:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666616620; cv=none; d=google.com; s=arc-20160816; b=0wWF2rx4hP1Kkqj/3XVy6unbIaUieVFvKz4X4yY0j1PevxQXe7N6DsVQ0eCVLtz164 mtm+SGWNkqlrLH+Yc/PAFB7mJSuY0SVbIJw42DyxB3uzEDSezs9XxWZ3BbIdJp8gXzD6 ZCqNN7xeF8923H/mABfTdYHsgJ0KdwhwP/D9+lGsN+WykMYY+mS+nHRuinz8tQEv1i7P sa9/YiH7gGQifhFtvH7ql2gBjXdbZriz0xuZ3Gvg5l0MtAJUfwJXsS6tmxaW+siHWsy1 2VgfSAVqIJU5gPJL5/bOGypfup+HbviHXWuzMnuoKYmXhtdZoZsEsDws/D8QZE58VMRL XZMg== 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=b4qccJppdpzrYQ15KlsdNnHH9IFLyUHbGt/CyKf2LV0=; b=ZP39EP5+iDoZ0WyK/AriDBCk8xgEq+qnMQmg+yA9QR5iH4U/NTPaudaEmCdKYCp7sS jedyaL/pldBOdH8+EDum0W7QdJ/BEc1B+wGjgKclzJLQx2XBl72nSMPOpRpy9hEIsVAn lDFbjl48tILNh8V4UXr+FE72q7j6TH3QdC80pbGipYVNRSXZ7sF26ajXImz3+RKMdChm igcu9XTrNpi0D+xnbUBoxfYiGfAwzyJdOdXX52qdErNJeOo0NECRGfAtUrlq4PqTlR2a 9LiZF9/nRLkj5AdvCG5FuHcUl+NMXy6MKFhY4pdFxemnm3qEVZGmS/UUmJdfHflxgXJJ 3gtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ztJWsFYT; 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 q29-20020a635c1d000000b0045131d08c18si36655532pgb.244.2022.10.24.06.03.24; Mon, 24 Oct 2022 06:03:39 -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=ztJWsFYT; 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 S235052AbiJXNCq (ORCPT + 99 others); Mon, 24 Oct 2022 09:02:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235184AbiJXM7e (ORCPT ); Mon, 24 Oct 2022 08:59:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01D279AC0E; Mon, 24 Oct 2022 05:18:45 -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 2FBC96127C; Mon, 24 Oct 2022 12:17:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47357C433D7; Mon, 24 Oct 2022 12:17:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613855; bh=rFx6IledfGJHPDeud7Kp7IvT8JMftQdELoVzKu025jY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ztJWsFYTYO00keghj96qiGErgULdPEpVkm14lZbzEsjOlj2JpjQ5LvY6UloDPYoPe i5Xak0GAlQc2UBVhEcCMlZtste2gwWjDf3jJ66UjMY4duMVQ1lQPJlI5LIY0JThSc0 zW+r4QzFd6YRQi1UVPthJfBlKbqZZlFALpE7Sw50= 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 5.10 039/390] drm/virtio: Check whether transferred 2D BO is shmem Date: Mon, 24 Oct 2022 13:27:16 +0200 Message-Id: <20221024113024.266842727@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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?1747574188729241293?= X-GMAIL-MSGID: =?utf-8?q?1747574188729241293?= 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 @@ -601,7 +601,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);