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 C949F606A322 for ; Sat, 5 Dec 2026 00:35:09 +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=YWVCMHrj Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3354A10E131; Sat, 5 Dec 2026 00:35:04 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id E127A10E131 for ; Sat, 5 Dec 2026 00:34:57 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id EDC14600FB; Sat, 5 Dec 2026 00:34:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 979CB1F00A06; Sat, 5 Dec 2026 00:34:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796430896; bh=yLk62v/b+LwpQv5+ljDJOtEDS6m8yBDHe+6OG9rJl84=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=YWVCMHrjW4jfBNnHmxzMu9avNP6qUbs+5gQXyP1s89feGsPsIj/O/AbwUfbmg6ZLr AAP9GK15yau/g+r9Kyfz4U4UTk6CYT+iT0m2vtSYs0ePgwbx5hErEVZTydy2KWMMpE j9zq0BYinVEx2p21UoXXtxViIEfiNBJ20P9LbuPK8OaQDwNfYaW4mM1t128YkmP79w FeYNE+PqbfvrTx5xdH9ecue3b6oJc2lM34cdy+lyNsoIV87/LhXgVtNxZClkUfKvGq aBG85D7aGV3y0e6E4fX5vMo483uOdl8IJB1kZXj9rUn82X42d9n2QNpcnYvnBOLjxB LnCbOMjY6qRUQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 2/2] drm/vkms: Use drm_dev_unplug() for ConfigFS device removal To: "Sebastian Wick" , dri-devel@lists.freedesktop.org In-Reply-To: <20261205001701.1125045-3-sebastian.wick@redhat.com> References: <20261205001701.1125045-1-sebastian.wick@redhat.com> <20261205001701.1125045-3-sebastian.wick@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 00:34:56 +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=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,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 2 potential issues to consider: - [Medium] drm/vkms: vkms_set_crc_source() calls vkms_set_composer() after unplug - [Low] drm/vkms: missing Fixes trailer for ConfigFS device removal -- commit 57a470b7f9cf80c97a20880e3587763a2408a3b5 Author: Sebastian Wick > drm/vkms: Use drm_dev_unplug() for ConfigFS device removal > > VKMS ConfigFS devices can be disabled while userspace still holds open > file descriptors. Using drm_dev_unregister() leaves the device in a > state where ioctls are still accepted but internal locks can contend > with the teardown path. Specifically, drmModeGetConnector() triggers > fill_modes which acquires mode_config locks that contend with > drm_atomic_helper_shutdown(). > > Use drm_dev_unplug() instead, which marks the device as unplugged so > the ioctl layer rejects subsequent calls with -ENODEV. The previous > commit added drm_dev_enter()/drm_dev_exit() guards to vkms callbacks, > so synchronize_srcu() in drm_dev_unplug() properly waits for any > in-flight operations before the teardown proceeds. > > Signed-off-by: Sebastian Wick > Acked-by: Maxime Ripard > Reviewed-by: Oarora Etimis [Severity: Low] This fixes a ConfigFS teardown issue introduced when dynamic instance removal was added. Should this include: Fixes: 13fc9b9745cc ("drm/vkms: Add and remove VKMS instances via configf= s") > diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_= drv.c > index 5a640b531d88f..716f9c966c211 100644 > --- a/drivers/gpu/drm/vkms/vkms_drv.c > +++ b/drivers/gpu/drm/vkms/vkms_drv.c > @@ -259,7 +259,7 @@ void vkms_destroy(struct vkms_config *config) > =20 > fdev =3D config->dev->faux_dev; > =20 > - drm_dev_unregister(&config->dev->drm); > + drm_dev_unplug(&config->dev->drm); > drm_atomic_helper_shutdown(&config->dev->drm); > devres_release_group(&fdev->dev, NULL); > faux_device_destroy(fdev); [Severity: Medium] Can switching to drm_dev_unplug() cause a use-after-free of vkms_output and dev->vblank when a debugfs CRC file is closed during teardown? Once drm_dev_unplug() sets dev->unplugged, vkms_set_crc_source() takes the !drm_dev_enter() path and still calls vkms_set_composer(out, false) after drm_dev_enter() has released drm_unplug_srcu: drivers/gpu/drm/vkms/vkms_composer.c:vkms_set_crc_source() { ... if (!drm_dev_enter(crtc->dev, &idx)) { if (!enabled) vkms_set_composer(out, false); return -ENODEV; } ... } Closing the debugfs crc/data file invokes crtc_crc_release() through full_proxy_release(), which does not acquire debugfs_file_get() or hold a drm_device reference. Neither debugfs removal nor synchronize_srcu() waits for vkms_set_composer(out, false): CPU0 (ConfigFS teardown) CPU1 (debugfs crc/data close) vkms_destroy() full_proxy_release() drm_dev_unplug() crtc_crc_release() dev->unplugged =3D true vkms_set_crc_source(crtc, NULL) synchronize_srcu() drm_dev_enter() -> false drm_atomic_helper_shutdown() devres_release_group() drm_dev_put() drm_managed_release() free vkms_output/vblank vkms_set_composer(out, false) &out->lock <-- use-after-free Once no /dev/dri/cardN fd remains open, drm_managed_release() frees vkms_output and dev->vblank while vkms_set_composer() still touches out->lock and calls drm_crtc_vblank_put(&out->crtc). Returning -ENODEV directly when drm_dev_enter() fails avoids running vkms_set_composer() outside SRCU protection. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205001701.1125= 045-1-sebastian.wick@redhat.com?part=3D2