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 <[email protected]> > 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 <[email protected]> > Acked-by: Maxime Ripard <[email protected]> > Reviewed-by: Oarora Etimis <[email protected]> [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 configfs") > 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) > > fdev = config->dev->faux_dev; > > - 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 = 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. -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=2
