From patchwork Sat Oct 22 07:19:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7622 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1106905wrr; Sat, 22 Oct 2022 01:39:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM78n5SIMb2aik+7YCiF3d+SQ6OLs2CfgOqbu04vRmziK3INrZK7G8ec1ROLTJULhT4tzKl9 X-Received: by 2002:aa7:d357:0:b0:45b:dab5:9789 with SMTP id m23-20020aa7d357000000b0045bdab59789mr21801720edr.222.1666427963407; Sat, 22 Oct 2022 01:39:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666427963; cv=none; d=google.com; s=arc-20160816; b=L+KgJSKnNrBp2ps7Jl/p4I+3xs0VCmT5KABbE6QZk0R855ffvXlvOoj+uzg8fhSnyx V8yQoKvXqsCdUyLpDSt7TP0uf3bsqMiftpJ9YmJy5WZvnrI50i+JBOXEPdKs3uyKChlL d2nelZT2B3V8Of5ImxHj6nYSD0K1HRzB7JmsvT5LTszrzfW/+O4DHGhnbqASo3frfqof c9UsoPSG5Cf5PKMYG3T7heMx/xPv58s9eF7wkeJ0gHwObjazopzqVgquPsQ+felO6rt6 zQ5A2mmgRq/NLzAhQUpvnYdjYpZkYcogfYuA4izJIEpClYnTZ8rqVv/6p+gcvD6wRehZ 3QAw== 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=+uH/Vo+idfz9Hmqstjcr/fdnmcXIZlAAdPf86AVkVF8=; b=dBkSNwxwB+Et64Fhp1x3N7zaPkHCyHKFP3uzOlTDM8oHCW2ledI0wcO/1s3h62eCtF q7NlncGNGi6sxm7MJGKX3tGI0xIut6tuh7dF0jx5YXQ7ZoDb2fexBW3+PxlaqsL09dfC vZQ4P7zfnBaFMc4pgQ+LtUAr5PwJHqM/lKCIOlyg/fa8yMAvBP9hV5HIFCdbS9Ohs7Mg oPhchj+P7IrY/ApQjWAOvM8UF8gHbv+DMISFakfOhKGkJPeIvf2KuV+WLQvgROiXZLaE DOGYN2EP6fBfmQ8X7uuDdoFdv2JN+3aUMYOdD1HVM7j1q77FKxr83w3FOu6g98wt8C8A Bwgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="QtwyQed/"; 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 cs20-20020a170906dc9400b00791bcf8aa61si10904456ejc.505.2022.10.22.01.38.55; Sat, 22 Oct 2022 01:39:23 -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="QtwyQed/"; 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 S234367AbiJVIhh (ORCPT + 99 others); Sat, 22 Oct 2022 04:37:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233906AbiJVIbk (ORCPT ); Sat, 22 Oct 2022 04:31:40 -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 BE0D02E532D; Sat, 22 Oct 2022 01:03:28 -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 AE9D860AE8; Sat, 22 Oct 2022 07:38:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6EBAC433D7; Sat, 22 Oct 2022 07:38:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424308; bh=YbETp0ie27chZJgqXsmyTni1sjbuOpVN+srHS8SvM1s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QtwyQed/zH/44PY3WYIS48QgDE1aaNgfcpGvAa1eYtdDOYZ+9Da2+WFkjYrIRpDTy FaKFtGQ2Dm6lfOw84i2FqK2k2gYBTIInkq2PpABOoK4Dq3UuvxBrzqh2kyzRETqUrK Zu9zIKp8sCfTJ+WP9WWBuOUrqActiTge3iW3LqfQ= 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.19 067/717] drm/virtio: Check whether transferred 2D BO is shmem Date: Sat, 22 Oct 2022 09:19:06 +0200 Message-Id: <20221022072426.988879285@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747376368155839795?= X-GMAIL-MSGID: =?utf-8?q?1747376368155839795?= 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 @@ -595,7 +595,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);