From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 917AE606A681 for ; Wed, 2 Dec 2026 10:46:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JL8a3uAi Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 90F021120CA; Wed, 2 Dec 2026 10:46:48 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1D3A11120C9 for ; Wed, 2 Dec 2026 10:46:42 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id C67C9419A2; Wed, 2 Dec 2026 10:46:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B5A11F00896; Wed, 2 Dec 2026 10:46:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796208401; bh=nlK7YBGPHA+qwy0kJpeZ1T3OfKvnXs17oWgABNioBEA=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=JL8a3uAiAOTc4E2Bb+bCtDf/LJMS1jBH2plS48+qTpq5XwN9yIOxdwuZ1LujJ3apD tt2SsLnRCDL4f5mqTF0E7mDoP8DQn43UvjlQ3uVmU5x2BBhsNkJpFYGEvU03QkpU3N Y87Mem61SNeK0v6XQkms19DQZNCSUqSzDSyB03PjhqhhiIy3C689ZjE27TjAPidoGw 9fyKFJhhBZTNtu3DlppGKEyMEXkg2urKzeFfF5otWKBzcq/yUhL+mgWfVXfgx1Ngdn SNwnvMUrHNrBdm4L4EAhTFWVZuYXUis2mRYxTEx4mTIEainBlNAvs8Ob02M+lGMCG8 FYCse49UREBzQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v11 4/4] drm/virtio: wire blob ioctl creation to userptr objects To: "Honglei Huang" Cc: dri-devel@lists.freedesktop.org, virtualization@lists.linux.dev, "Michael S. Tsirkin" , "Eugenio Perez" In-Reply-To: <20261202101658.1209083-5-honghuan@amd.com> References: <20261202101658.1209083-1-honghuan@amd.com> <20261202101658.1209083-5-honghuan@amd.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 10:46:41 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] drm/virtio: out-of-bounds user page pinning in verify_blob() on size ALIGN() It also noticed 1 related pre-existing issue this patch does not introduce: - [Critical] drm/virtio: silent blob size truncation in verify_blob() [1] -- commit 47f959d0cfefd215bffd18078894e965cea40441 Author: Honglei Huang drm/virtio: wire blob ioctl creation to userptr objects This commit wires the blob resource creation ioctl to userptr objects, adds support for the VIRTIO_GPU_F_BLOB_READONLY feature, and adjusts blob size a= nd userptr alignment handling. > diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/vir= tio/virtgpu_ioctl.c > index 81e70a12b3569..454d0e9a7d59d 100644 > --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c > +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c [ ... ] > @@ -538,10 +565,16 @@ static int verify_blob(struct virtio_gpu_device *vg= dev, > params->blob =3D true; > params->blob_flags =3D rc_blob->blob_flags; > params->blob_hints =3D rc_blob->blob_hints; > + params->userptr =3D rc_blob->userptr; [Severity: Critical] This problem wasn't introduced by this patch, but does assigning the 64-bit rc_blob->size to params->size just above this [1] silently truncate blob sizes over 4 GB on 32-bit architectures? params->size is an unsigned long, so on 32-bit systems the upper 32 bits of rc_blob->size are discarded before alignment checks, allocation, and host command submission, allocating a smaller buffer than userspace requested. > - if (vgdev->has_blob_alignment && > - !IS_ALIGNED(params->size, vgdev->blob_alignment)) > - return -EINVAL; > + if (vgdev->has_blob_alignment) { > + params->size =3D ALIGN(params->size, > + max_t(uint32_t, vgdev->blob_alignment, > + PAGE_SIZE)); > + > + if (!IS_ALIGNED(params->userptr, vgdev->blob_alignment)) > + return -EINVAL; > + } > =20 > return 0; > } [Severity: High] When params->userptr is non-zero and vgdev->blob_alignment is larger than PAGE_SIZE, can rounding params->size up to vgdev->blob_alignment cause virtio_gpu_userptr_create() to pin guest pages past the end of the user-supplied buffer? Unlike shmem or VRAM blobs that allocate new backing storage of params->siz= e, virtio_gpu_userptr_init() sets userptr->npages =3D params->size >> PAGE_SHI= FT and virtio_gpu_userptr_get_pages() pins that many pages from current->mm starting at userptr->start. If userspace passes a userptr buffer whose size is not a multiple of vgdev->blob_alignment, the extra pages past rc_blob->userptr + rc_blob->size either fail in pin_user_pages_fast() with -EFAULT or pin and export unrelated pages from an adjacent VMA to the host device. [1] https://sashiko.dev/#/bug/linux-20577b57-1c85-44eb-8080-3e8c4e2bce2a --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202101658.1209= 083-1-honghuan@amd.com?part=3D4