public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm: Add might_fault to drm_modeset_lock priming
@ 2024-07-10  9:31 Daniel Vetter
  2024-07-10  9:31 ` [PATCH 2/2] bcachefs: only console_trylock in bch2_print_string_as_lines Daniel Vetter
  2024-07-10 11:38 ` [PATCH 1/2] drm: Add might_fault to drm_modeset_lock priming Christian König
  0 siblings, 2 replies; 11+ messages in thread
From: Daniel Vetter @ 2024-07-10  9:31 UTC (permalink / raw)
  To: DRI Development, LKML
  Cc: Intel Graphics Development, Daniel Vetter, Daniel Vetter,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Sumit Semwal,
	Christian König, linux-media, linaro-mm-sig

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
---
 drivers/gpu/drm/drm_mode_config.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
index 568972258222..37d2e0a4ef4b 100644
--- a/drivers/gpu/drm/drm_mode_config.c
+++ b/drivers/gpu/drm/drm_mode_config.c
@@ -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)
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-07-15 10:08 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-10  9:31 [PATCH 1/2] drm: Add might_fault to drm_modeset_lock priming Daniel Vetter
2024-07-10  9:31 ` [PATCH 2/2] bcachefs: only console_trylock in bch2_print_string_as_lines Daniel Vetter
2024-07-10 11:02   ` John Ogness
2024-07-10 13:03   ` [PATCH] bcachefs: no console_lock " Daniel Vetter
2024-07-10 14:01     ` John Ogness
2024-07-10 14:13     ` John Ogness
2024-07-15  8:45       ` Daniel Vetter
2024-07-10 11:38 ` [PATCH 1/2] drm: Add might_fault to drm_modeset_lock priming Christian König
2024-07-10 11:58   ` Daniel Vetter
2024-07-10 12:40     ` Christian König
2024-07-15 10:08       ` Daniel Vetter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox