From patchwork Wed Jul 10 09:31:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 13729129 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3DAA4C3DA42 for ; Wed, 10 Jul 2024 09:33:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B31B610E160; Wed, 10 Jul 2024 09:33:24 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; secure) header.d=ffwll.ch header.i=@ffwll.ch header.b="WdXPFVCq"; dkim-atps=neutral Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7326110E160 for ; Wed, 10 Jul 2024 09:33:23 +0000 (UTC) Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-52a559e4429so894833e87.0 for ; Wed, 10 Jul 2024 02:33:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; t=1720604001; x=1721208801; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=GTHGZWFFIG2y8znG1jvML///poV3IrhnVzz1kC5uonU=; b=WdXPFVCqk0MBGZfFuQgbbGPpvT9XLTScyN36HYaulfhA7QgD1vcCeTOk3FoJvxXg/w AMidYNVyXoMNx2TnO+9JUKUxwvjFkWBRw2FeiViyxG9KZpLV7+6v+Cj4ZDl8RIRjPhfG yPiRHRlMh9/RsKGlsU+PlKavGUVwkgGf6AW5g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720604001; x=1721208801; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=GTHGZWFFIG2y8znG1jvML///poV3IrhnVzz1kC5uonU=; b=qXGyGLikmwxWCSmCraU8utDscQ8PWVqV9gO6TKHY0ML1cv1tW9+KAPphMCWR9zpaC2 XxSA2ZCEdDtHzbb3VcKSaicvkRK1inUp7P6S5E5242I/Mfd+Aobpa1IQY5QyvkdbZQe+ sPaLM3rqM/rlvFnKLZug0DkU8avpDi5RBKYQDkLeOzsikF7CI6hnFlC9mSYrfrw0HLEX 4Z7+qLYXrjfYydvXObWiTGmtlIi5ODVDou4u+ztsLGAi/xH6ldYmZ1G5c67dzeQdOqm4 8sa70lyVN8ydukyHu/zNf2bUftuLWXz2qn4YZQOBkG9s5DfFFGLAC+bnHB4NVfCgwjWc i1Rg== X-Gm-Message-State: AOJu0Yy7UYIRWHO9MfcOF3x5JQ1ZPpWWkW09SZ7yy1lA/h1BuEqhNPC/ qtsVCEeI3LpZn5u1CJ0RnKu4+XJ/YzHCc4vlZv9KO0RdU3kcmn3EbL7SYIGNNdE= X-Google-Smtp-Source: AGHT+IE53obXe9iAhMtu+VAErcsSEkowso2ZAWhhq6KbgW5hVFggamUEZCMm4iphO7D+n2JaklYQbA== X-Received: by 2002:a05:6512:10d2:b0:52e:9b18:9a7f with SMTP id 2adb3069b0e04-52eb9993c36mr3246261e87.2.1720604001546; Wed, 10 Jul 2024 02:33:21 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4266f6f5a27sm73448935e9.23.2024.07.10.02.33.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jul 2024 02:33:20 -0700 (PDT) From: Daniel Vetter To: DRI Development , LKML Cc: Intel Graphics Development , Daniel Vetter , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= , linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org Subject: [PATCH 1/2] drm: Add might_fault to drm_modeset_lock priming Date: Wed, 10 Jul 2024 11:31:16 +0200 Message-ID: <20240710093120.732208-1-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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 Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Thomas Zimmermann Cc: Sumit Semwal Cc: "Christian König" Cc: linux-media@vger.kernel.org Cc: linaro-mm-sig@lists.linaro.org Reviewed-by: Christian König . --- 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)