]> git.infradead.org Git - users/hch/misc.git/commitdiff
drm: Add might_fault to drm_modeset_lock priming
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 10 Jul 2024 09:31:16 +0000 (11:31 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 18 Jul 2024 13:39:54 +0000 (15:39 +0200)
We already teach lockdep that dma_resv nests within drm_modeset_lock,
but there's a lot more: All drm kms ioctl rely on being able to
put/get_user while holding modeset locks, so we really need a
might_fault in there too to complete the picture. Add it.

Motivated by a syzbot report that blew up on bcachefs doing an
unconditional console_lock way deep in the locking hierarchy, and
lockdep only noticing the depency loop in a drm ioctl instead of much
earlier. This annotation will make sure such issues have a much harder
time escaping.

References: https://lore.kernel.org/dri-devel/00000000000073db8b061cd43496@google.com/
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: linux-media@vger.kernel.org
Cc: linaro-mm-sig@lists.linaro.org
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20240710093120.732208-1-daniel.vetter@ffwll.ch
drivers/gpu/drm/drm_mode_config.c

index 568972258222af09207b15eafe4d65ad96406fdd..37d2e0a4ef4be2239c0276e9443094d456878311 100644 (file)
@@ -456,6 +456,8 @@ int drmm_mode_config_init(struct drm_device *dev)
                if (ret == -EDEADLK)
                        ret = drm_modeset_backoff(&modeset_ctx);
 
+               might_fault();
+
                ww_acquire_init(&resv_ctx, &reservation_ww_class);
                ret = dma_resv_lock(&resv, &resv_ctx);
                if (ret == -EDEADLK)