Skip to contentSkip to conversation

drm: address potential UAF bugs with drm_master ptrs

PATCH In review Desmond Cheong Zhi Xi 3 participants 14 messages Jul 12, 2021 – Jul 22, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v8 cover drm: address potential UAF bugs with drm_master ptrs

Hi,

In the previous thread on this series we decided to remove a patch that was violating a lockdep requirement in drm_lease. In addition to this change, I took a closer look at the CI logs for the Basic Acceptance Tests and noticed that another regression was introduced. The new patch 2 is a response to this.

Overall, this series addresses potential use-after-free errors when dereferencing pointers to struct drm_master. These were identified after one such bug was caught by Syzbot in drm_getunique():
https://syzkaller.appspot.com/bug?id=148d2f1dfac64af52ffd27b661981a540724f803

The series is broken up into five patches:

1. Move a call to drm_is_current_master() out from a section locked by &dev->mode_config.mutex in drm_mode_getconnector(). This patch does not apply to stable.

2. Move a call to drm_is_current_master() out from the RCU read-side critical section in drm_clients_info().

3. Implement a locked version of drm_is_current_master() function that's used within drm_auth.c.

4. Serialize drm_file.master by introducing a new spinlock that's held whenever the value of drm_file.master changes.

5. Identify areas in drm_lease.c where pointers to struct drm_master are dereferenced, and ensure that the master pointers are not freed during use.

v7 -> v8:
- Remove the patch that moves the call to _drm_lease_held out from the section locked by &dev->mode_config.idr_mutex in __drm_mode_object_find. This patch violated an existing lockdep requirement as reported by the intel-gfx CI.
- Added a new patch that moves a call to drm_is_current_master out from the RCU critical section in drm_clients_info. This was reported by the intel-gfx CI.

v6 -> v7:
- Modify code alignment as suggested by the intel-gfx CI.
- Add a new patch to the series that adds a new lock to serialize drm_file.master, in response to the lockdep splat by the intel-gfx CI.
- Update drm_file_get_master to use the new drm_file.master_lock instead of drm_device.master_mutex, in response to the lockdep splat by the intel-gfx CI.

v5 -> v6:
- Add a new patch to the series that moves the call to _drm_lease_held out from the section locked by &dev->mode_config.idr_mutex in __drm_mode_object_find.
- Clarify the kerneldoc for dereferencing drm_file.master, as suggested by Daniel Vetter.
- Refactor error paths with goto labels so that each function only has a single drm_master_put(), as suggested by Emil Velikov.
- Modify comparisons to NULL into "!master", as suggested by the intel-gfx CI.

v4 -> v5:
- Add a new patch to the series that moves the call to drm_is_current_master in drm_mode_getconnector out from the section locked by &dev->mode_config.mutex.
- Additionally, added a missing semicolon to the patch, caught by the intel-gfx CI.

v3 -> v4:
- Move the call to drm_is_current_master in drm_mode_getconnector out from the section locked by &dev->mode_config.mutex. As suggested by Daniel Vetter. This avoids a circular lock lock dependency as reported here https://patchwork.freedesktop.org/patch/440406/
- Inside drm_is_current_master, instead of grabbing &fpriv->master->dev->master_mutex, we grab &fpriv->minor->dev->master_mutex to avoid dereferencing a null ptr if fpriv->master is not set.
- Modify kerneldoc formatting for drm_file.master, as suggested by Daniel Vetter.
- Additionally, add a file_priv->master NULL check inside drm_file_get_master, and handle the NULL result accordingly in drm_lease.c. As suggested by Daniel Vetter.

v2 -> v3:
- Move the definition of drm_is_current_master and the _locked version higher up in drm_auth.c to avoid needing a forward declaration of drm_is_current_master_locked. As suggested by Daniel Vetter.
- Instead of leaking drm_device.master_mutex into drm_lease.c to protect drm_master pointers, add a new drm_file_get_master() function that returns drm_file->master while increasing its reference count, to prevent drm_file->master from being freed. As suggested by Daniel Vetter.

v1 -> v2:
- Move the lock and assignment before the DRM_DEBUG_LEASE in drm_mode_get_lease_ioctl, as suggested by Emil Velikov.

Desmond Cheong Zhi Xi (5):
drm: avoid circular locks in drm_mode_getconnector
drm: avoid blocking in drm_clients_info's rcu section
drm: add a locked version of drm_is_current_master
drm: serialize drm_file.master with a new spinlock
drm: protect drm_master pointers in drm_lease.c

 drivers/gpu/drm/drm_auth.c      | 93 ++++++++++++++++++++++++---------
 drivers/gpu/drm/drm_connector.c |  5 +-
 drivers/gpu/drm/drm_debugfs.c   |  3 +-
 drivers/gpu/drm/drm_file.c      |  1 +
 drivers/gpu/drm/drm_lease.c     | 81 +++++++++++++++++++++-------
 include/drm/drm_auth.h          |  1 +
 include/drm/drm_file.h          | 18 +++++--
 7 files changed, 152 insertions(+), 50 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v8 1/5 drm: avoid circular locks in drm_mode_getconnector

In preparation for a future patch to take a lock on drm_device.master_mutex inside drm_is_current_master(), we first move the call to drm_is_current_master() in drm_mode_getconnector out from the section locked by &dev->mode_config.mutex. This avoids creating a circular lock dependency.

Failing to avoid this lock dependency produces the following lockdep splat:

======================================================
WARNING: possible circular locking dependency detected 5.13.0-rc7-CI-CI_DRM_10254+ #1 Not tainted
------------------------------------------------------
kms_frontbuffer/1087 is trying to acquire lock:
ffff88810dcd01a8 (&dev->master_mutex){+.+.}-{3:3}, at: drm_is_current_master+0x1b/0x40 but task is already holding lock:
ffff88810dcd0488 (&dev->mode_config.mutex){+.+.}-{3:3}, at: drm_mode_getconnector+0x1c6/0x4a0 which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #2 (&dev->mode_config.mutex){+.+.}-{3:3}:

       __mutex_lock+0xab/0x970
       drm_client_modeset_probe+0x22e/0xca0
       __drm_fb_helper_initial_config_and_unlock+0x42/0x540
       intel_fbdev_initial_config+0xf/0x20 [i915]
       async_run_entry_fn+0x28/0x130
       process_one_work+0x26d/0x5c0
       worker_thread+0x37/0x380
       kthread+0x144/0x170
       ret_from_fork+0x1f/0x30
-> #1 (&client->modeset_mutex){+.+.}-{3:3}:
       __mutex_lock+0xab/0x970
       drm_client_modeset_commit_locked+0x1c/0x180
       drm_client_modeset_commit+0x1c/0x40
       __drm_fb_helper_restore_fbdev_mode_unlocked+0x88/0xb0
       drm_fb_helper_set_par+0x34/0x40
       intel_fbdev_set_par+0x11/0x40 [i915]
       fbcon_init+0x270/0x4f0
       visual_init+0xc6/0x130
       do_bind_con_driver+0x1e5/0x2d0
       do_take_over_console+0x10e/0x180
       do_fbcon_takeover+0x53/0xb0
       register_framebuffer+0x22d/0x310
       __drm_fb_helper_initial_config_and_unlock+0x36c/0x540
       intel_fbdev_initial_config+0xf/0x20 [i915]
       async_run_entry_fn+0x28/0x130
       process_one_work+0x26d/0x5c0
       worker_thread+0x37/0x380
       kthread+0x144/0x170
       ret_from_fork+0x1f/0x30
-> #0 (&dev->master_mutex){+.+.}-{3:3}:
       __lock_acquire+0x151e/0x2590
       lock_acquire+0xd1/0x3d0
       __mutex_lock+0xab/0x970
       drm_is_current_master+0x1b/0x40
       drm_mode_getconnector+0x37e/0x4a0
       drm_ioctl_kernel+0xa8/0xf0
       drm_ioctl+0x1e8/0x390
       __x64_sys_ioctl+0x6a/0xa0
       do_syscall_64+0x39/0xb0
       entry_SYSCALL_64_after_hwframe+0x44/0xae
other info that might help us debug this:
Chain exists of: &dev->master_mutex --> &client->modeset_mutex --> &dev->mode_config.mutex
 Possible unsafe locking scenario:
       CPU0                    CPU1
       ----                    ----
  lock(&dev->mode_config.mutex);
                               lock(&client->modeset_mutex);
                               lock(&dev->mode_config.mutex);
  lock(&dev->master_mutex);
*** DEADLOCK ***
1 lock held by kms_frontbuffer/1087:
 #0: ffff88810dcd0488 (&dev->mode_config.mutex){+.+.}-{3:3}, at: drm_mode_getconnector+0x1c6/0x4a0
stack backtrace:
CPU: 7 PID: 1087 Comm: kms_frontbuffer Not tainted 5.13.0-rc7-CI-CI_DRM_10254+ #1
Hardware name: Intel Corporation Ice Lake Client Platform/IceLake U DDR4 SODIMM PD RVP TLC, BIOS ICLSFWR1.R00.3234.A01.1906141750 06/14/2019
Call Trace:
 dump_stack+0x7f/0xad
 check_noncircular+0x12e/0x150
 __lock_acquire+0x151e/0x2590
 lock_acquire+0xd1/0x3d0
 __mutex_lock+0xab/0x970
 drm_is_current_master+0x1b/0x40
 drm_mode_getconnector+0x37e/0x4a0
 drm_ioctl_kernel+0xa8/0xf0
 drm_ioctl+0x1e8/0x390
 __x64_sys_ioctl+0x6a/0xa0
 do_syscall_64+0x39/0xb0
 entry_SYSCALL_64_after_hwframe+0x44/0xae
---
 drivers/gpu/drm/drm_connector.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_connector.c +4 -1
index da39e7ff6965..2ba257b1ae20 100644
@@ -2414,6 +2414,7 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
 	struct drm_mode_modeinfo u_mode;
 	struct drm_mode_modeinfo __user *mode_ptr;
 	uint32_t __user *encoder_ptr;
+	bool is_current_master;
 
 	if (!drm_core_check_feature(dev, DRIVER_MODESET))
 		return -EOPNOTSUPP;
@@ -2444,9 +2445,11 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
 	out_resp->connector_type = connector->connector_type;
 	out_resp->connector_type_id = connector->connector_type_id;
 
+	is_current_master = drm_is_current_master(file_priv);
+
 	mutex_lock(&dev->mode_config.mutex);
 	if (out_resp->count_modes == 0) {
-		if (drm_is_current_master(file_priv))
+		if (is_current_master)
 			connector->funcs->fill_modes(connector,
 						     dev->mode_config.max_width,
 						     dev->mode_config.max_height);
Signature · 1 line
2.25.1
#2 lore raw

PATCH v8 2/5 drm: avoid blocking in drm_clients_info's rcu section

In reply to Desmond Cheong Zhi Xi

Inside drm_clients_info, the rcu_read_lock is held to lock pid_task()->comm. However, within this protected section, a call to drm_is_current_master is made, which involves a mutex lock in a future patch. However, this is illegal because the mutex lock might block while in the RCU read-side critical section.

Since drm_is_current_master isn't protected by rcu_read_lock, we avoid this by moving it out of the RCU critical section.

The following report came from intel-gfx ci's
igt@debugfs_test@read_all_entries testcase:

=============================
[ BUG: Invalid wait context ]
5.13.0-CI-Patchwork_20515+ #1 Tainted: G W
-----------------------------
debugfs_test/1101 is trying to lock:
ffff888132d901a8 (&dev->master_mutex){+.+.}-{3:3}, at:
drm_is_current_master+0x1e/0x50
other info that might help us debug this:
context-{4:4}
3 locks held by debugfs_test/1101:
#0: ffff88810fdffc90 (&p->lock){+.+.}-{3:3}, at:

 seq_read_iter+0x53/0x3b0
 #1: ffff888132d90240 (&dev->filelist_mutex){+.+.}-{3:3}, at:
 drm_clients_info+0x63/0x2a0
 #2: ffffffff82734220 (rcu_read_lock){....}-{1:2}, at:
 drm_clients_info+0x1b1/0x2a0
stack backtrace:
CPU: 8 PID: 1101 Comm: debugfs_test Tainted: G        W
5.13.0-CI-Patchwork_20515+ #1
Hardware name: Intel Corporation CometLake Client Platform/CometLake S
UDIMM (ERB/CRB), BIOS CMLSFWR1.R00.1263.D00.1906260926 06/26/2019
Call Trace:
 dump_stack+0x7f/0xad
 __lock_acquire.cold.78+0x2af/0x2ca
 lock_acquire+0xd3/0x300
 ? drm_is_current_master+0x1e/0x50
 ? __mutex_lock+0x76/0x970
 ? lockdep_hardirqs_on+0xbf/0x130
 __mutex_lock+0xab/0x970
 ? drm_is_current_master+0x1e/0x50
 ? drm_is_current_master+0x1e/0x50
 ? drm_is_current_master+0x1e/0x50
 drm_is_current_master+0x1e/0x50
 drm_clients_info+0x107/0x2a0
 seq_read_iter+0x178/0x3b0
 seq_read+0x104/0x150
 full_proxy_read+0x4e/0x80
 vfs_read+0xa5/0x1b0
 ksys_read+0x5a/0xd0
 do_syscall_64+0x39/0xb0
 entry_SYSCALL_64_after_hwframe+0x44/0xae
---
 drivers/gpu/drm/drm_debugfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_debugfs.c +2 -1
index 3d7182001004..b0a826489488 100644
@@ -91,6 +91,7 @@ static int drm_clients_info(struct seq_file *m, void *data)
 	mutex_lock(&dev->filelist_mutex);
 	list_for_each_entry_reverse(priv, &dev->filelist, lhead) {
 		struct task_struct *task;
+		bool is_current_master = drm_is_current_master(priv);
 
 		rcu_read_lock(); /* locks pid_task()->comm */
 		task = pid_task(priv->pid, PIDTYPE_PID);
@@ -99,7 +100,7 @@ static int drm_clients_info(struct seq_file *m, void *data)
 			   task ? task->comm : "<unknown>",
 			   pid_vnr(priv->pid),
 			   priv->minor->index,
-			   drm_is_current_master(priv) ? 'y' : 'n',
+			   is_current_master ? 'y' : 'n',
 			   priv->authenticated ? 'y' : 'n',
 			   from_kuid_munged(seq_user_ns(m), uid),
 			   priv->magic);
Signature · 1 line
2.25.1
#3 lore raw

PATCH v8 3/5 drm: add a locked version of drm_is_current_master

In reply to Desmond Cheong Zhi Xi

While checking the master status of the DRM file in drm_is_current_master(), the device's master mutex should be held. Without the mutex, the pointer fpriv->master may be freed concurrently by another process calling drm_setmaster_ioctl(). This could lead to use-after-free errors when the pointer is subsequently dereferenced in drm_lease_owner().

The callers of drm_is_current_master() from drm_auth.c hold the device's master mutex, but external callers do not. Hence, we implement drm_is_current_master_locked() to be used within drm_auth.c, and modify drm_is_current_master() to grab the device's master mutex before checking the master status.

---
 drivers/gpu/drm/drm_auth.c | 51 ++++++++++++++++++++++++--------------
 1 file changed, 32 insertions(+), 19 deletions(-)
drivers/gpu/drm/drm_auth.c +32 -19
index f00e5abdbbf4..ab1863c5a5a0 100644
@@ -61,6 +61,35 @@
  * trusted clients.
  */
 
+static bool drm_is_current_master_locked(struct drm_file *fpriv)
+{
+	lockdep_assert_held_once(&fpriv->minor->dev->master_mutex);
+
+	return fpriv->is_master && drm_lease_owner(fpriv->master) == fpriv->minor->dev->master;
+}
+
+/**
+ * drm_is_current_master - checks whether @priv is the current master
+ * @fpriv: DRM file private
+ *
+ * Checks whether @fpriv is current master on its device. This decides whether a
+ * client is allowed to run DRM_MASTER IOCTLs.
+ *
+ * Most of the modern IOCTL which require DRM_MASTER are for kernel modesetting
+ * - the current master is assumed to own the non-shareable display hardware.
+ */
+bool drm_is_current_master(struct drm_file *fpriv)
+{
+	bool ret;
+
+	mutex_lock(&fpriv->minor->dev->master_mutex);
+	ret = drm_is_current_master_locked(fpriv);
+	mutex_unlock(&fpriv->minor->dev->master_mutex);
+
+	return ret;
+}
+EXPORT_SYMBOL(drm_is_current_master);
+
 int drm_getmagic(struct drm_device *dev, void *data, struct drm_file *file_priv)
 {
 	struct drm_auth *auth = data;
@@ -223,7 +252,7 @@ int drm_setmaster_ioctl(struct drm_device *dev, void *data,
 	if (ret)
 		goto out_unlock;
 
-	if (drm_is_current_master(file_priv))
+	if (drm_is_current_master_locked(file_priv))
 		goto out_unlock;
 
 	if (dev->master) {
@@ -272,7 +301,7 @@ int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
 	if (ret)
 		goto out_unlock;
 
-	if (!drm_is_current_master(file_priv)) {
+	if (!drm_is_current_master_locked(file_priv)) {
 		ret = -EINVAL;
 		goto out_unlock;
 	}
@@ -321,7 +350,7 @@ void drm_master_release(struct drm_file *file_priv)
 	if (file_priv->magic)
 		idr_remove(&file_priv->master->magic_map, file_priv->magic);
 
-	if (!drm_is_current_master(file_priv))
+	if (!drm_is_current_master_locked(file_priv))
 		goto out;
 
 	drm_legacy_lock_master_cleanup(dev, master);
@@ -342,22 +371,6 @@ void drm_master_release(struct drm_file *file_priv)
 	mutex_unlock(&dev->master_mutex);
 }
 
-/**
- * drm_is_current_master - checks whether @priv is the current master
- * @fpriv: DRM file private
- *
- * Checks whether @fpriv is current master on its device. This decides whether a
- * client is allowed to run DRM_MASTER IOCTLs.
- *
- * Most of the modern IOCTL which require DRM_MASTER are for kernel modesetting
- * - the current master is assumed to own the non-shareable display hardware.
- */
-bool drm_is_current_master(struct drm_file *fpriv)
-{
-	return fpriv->is_master && drm_lease_owner(fpriv->master) == fpriv->minor->dev->master;
-}
-EXPORT_SYMBOL(drm_is_current_master);
-
 /**
  * drm_master_get - reference a master pointer
  * @master: &struct drm_master
Signature · 1 line
2.25.1
#4 lore raw

PATCH v8 4/5 drm: serialize drm_file.master with a new spinlock

In reply to Desmond Cheong Zhi Xi

Currently, drm_file.master pointers should be protected by drm_device.master_mutex when being dereferenced. This is because drm_file.master is not invariant for the lifetime of drm_file. If drm_file is not the creator of master, then drm_file.is_master is false, and a call to drm_setmaster_ioctl will invoke drm_new_set_master, which then allocates a new master for drm_file and puts the old master.

Thus, without holding drm_device.master_mutex, the old value of drm_file.master could be freed while it is being used by another concurrent process.

However, it is not always possible to lock drm_device.master_mutex to dereference drm_file.master. Through the fbdev emulation code, this might occur in a deep nest of other locks. But drm_device.master_mutex is also the outermost lock in the nesting hierarchy, so this leads to potential deadlocks.

To address this, we introduce a new spin lock at the bottom of the lock hierarchy that only serializes drm_file.master. With this change, the value of drm_file.master changes only when both drm_device.master_mutex and drm_file.master_lookup_lock are held. Hence, any process holding either of those locks can ensure that the value of drm_file.master will not change concurrently.

Since no lock depends on the new drm_file.master_lookup_lock, when drm_file.master is dereferenced, but drm_device.master_mutex cannot be held, we can safely protect the master pointer with drm_file.master_lookup_lock.

---
 drivers/gpu/drm/drm_auth.c | 17 +++++++++++------
 drivers/gpu/drm/drm_file.c |  1 +
 include/drm/drm_file.h     | 12 +++++++++---
 3 files changed, 21 insertions(+), 9 deletions(-)
drivers/gpu/drm/drm_auth.c +11 -6
index ab1863c5a5a0..30a239901b36 100644
@@ -164,16 +164,18 @@ static void drm_set_master(struct drm_device *dev, struct drm_file *fpriv,
 static int drm_new_set_master(struct drm_device *dev, struct drm_file *fpriv)
 {
 	struct drm_master *old_master;
+	struct drm_master *new_master;
 
 	lockdep_assert_held_once(&dev->master_mutex);
 
 	WARN_ON(fpriv->is_master);
 	old_master = fpriv->master;
-	fpriv->master = drm_master_create(dev);
-	if (!fpriv->master) {
-		fpriv->master = old_master;
+	new_master = drm_master_create(dev);
+	if (!new_master)
 		return -ENOMEM;
-	}
+	spin_lock(&fpriv->master_lookup_lock);
+	fpriv->master = new_master;
+	spin_unlock(&fpriv->master_lookup_lock);
 
 	fpriv->is_master = 1;
 	fpriv->authenticated = 1;
@@ -332,10 +334,13 @@ int drm_master_open(struct drm_file *file_priv)
 	 * any master object for render clients
 	 */
 	mutex_lock(&dev->master_mutex);
-	if (!dev->master)
+	if (!dev->master) {
 		ret = drm_new_set_master(dev, file_priv);
-	else
+	} else {
+		spin_lock(&file_priv->master_lookup_lock);
 		file_priv->master = drm_master_get(dev->master);
+		spin_unlock(&file_priv->master_lookup_lock);
+	}
 	mutex_unlock(&dev->master_mutex);
 
 	return ret;
drivers/gpu/drm/drm_file.c +1 -0
index d4f0bac6f8f8..ceb1a9723855 100644
@@ -176,6 +176,7 @@ struct drm_file *drm_file_alloc(struct drm_minor *minor)
 	init_waitqueue_head(&file->event_wait);
 	file->event_space = 4096; /* set aside 4k for event buffer */
 
+	spin_lock_init(&file->master_lookup_lock);
 	mutex_init(&file->event_read_lock);
 
 	if (drm_core_check_feature(dev, DRIVER_GEM))
include/drm/drm_file.h +9 -3
index b81b3bfb08c8..9b82988e3427 100644
@@ -226,15 +226,21 @@ struct drm_file {
 	/**
 	 * @master:
 	 *
-	 * Master this node is currently associated with. Only relevant if
-	 * drm_is_primary_client() returns true. Note that this only
-	 * matches &drm_device.master if the master is the currently active one.
+	 * Master this node is currently associated with. Protected by struct
+	 * &drm_device.master_mutex, and serialized by @master_lookup_lock.
+	 *
+	 * Only relevant if drm_is_primary_client() returns true. Note that
+	 * this only matches &drm_device.master if the master is the currently
+	 * active one.
 	 *
 	 * See also @authentication and @is_master and the :ref:`section on
 	 * primary nodes and authentication <drm_primary_node>`.
 	 */
 	struct drm_master *master;
 
+	/** @master_lock: Serializes @master. */
+	spinlock_t master_lookup_lock;
+
 	/** @pid: Process that opened this file. */
 	struct pid *pid;
 
Signature · 1 line
2.25.1
#5 lore raw

PATCH v8 5/5 drm: protect drm_master pointers in drm_lease.c

In reply to Desmond Cheong Zhi Xi

drm_file->master pointers should be protected by drm_device.master_mutex or drm_file.master_lookup_lock when being dereferenced.

However, in drm_lease.c, there are multiple instances where drm_file->master is accessed and dereferenced while neither lock is held. This makes drm_lease.c vulnerable to use-after-free bugs.

We address this issue in 2 ways:

1. Add a new drm_file_get_master() function that calls drm_master_get on drm_file->master while holding on to drm_file.master_lookup_lock. Since drm_master_get increments the reference count of master, this prevents master from being freed until we unreference it with drm_master_put.

2. In each case where drm_file->master is directly accessed and eventually dereferenced in drm_lease.c, we wrap the access in a call to the new drm_file_get_master function, then unreference the master pointer once we are done using it.

---
 drivers/gpu/drm/drm_auth.c  | 25 ++++++++++++
 drivers/gpu/drm/drm_lease.c | 81 ++++++++++++++++++++++++++++---------
 include/drm/drm_auth.h      |  1 +
 include/drm/drm_file.h      |  6 +++
 4 files changed, 93 insertions(+), 20 deletions(-)
drivers/gpu/drm/drm_auth.c +25 -0
index 30a239901b36..f00354bec3fb 100644
@@ -389,6 +389,31 @@ struct drm_master *drm_master_get(struct drm_master *master)
 }
 EXPORT_SYMBOL(drm_master_get);
 
+/**
+ * drm_file_get_master - reference &drm_file.master of @file_priv
+ * @file_priv: DRM file private
+ *
+ * Increments the reference count of @file_priv's &drm_file.master and returns
+ * the &drm_file.master. If @file_priv has no &drm_file.master, returns NULL.
+ *
+ * Master pointers returned from this function should be unreferenced using
+ * drm_master_put().
+ */
+struct drm_master *drm_file_get_master(struct drm_file *file_priv)
+{
+	struct drm_master *master = NULL;
+
+	spin_lock(&file_priv->master_lookup_lock);
+	if (!file_priv->master)
+		goto unlock;
+	master = drm_master_get(file_priv->master);
+
+unlock:
+	spin_unlock(&file_priv->master_lookup_lock);
+	return master;
+}
+EXPORT_SYMBOL(drm_file_get_master);
+
 static void drm_master_destroy(struct kref *kref)
 {
 	struct drm_master *master = container_of(kref, struct drm_master, refcount);
drivers/gpu/drm/drm_lease.c +61 -20

214 lines not on this page · raw message

include/drm/drm_auth.h +1 -0
index 6bf8b2b78991..f99d3417f304 100644
@@ -107,6 +107,7 @@ struct drm_master {
 };
 
 struct drm_master *drm_master_get(struct drm_master *master);
+struct drm_master *drm_file_get_master(struct drm_file *file_priv);
 void drm_master_put(struct drm_master **master);
 bool drm_is_current_master(struct drm_file *fpriv);
 
include/drm/drm_file.h +6 -0
index 9b82988e3427..726cfe0ff5f5 100644
@@ -233,6 +233,12 @@ struct drm_file {
 	 * this only matches &drm_device.master if the master is the currently
 	 * active one.
 	 *
+	 * When dereferencing this pointer, either hold struct
+	 * &drm_device.master_mutex for the duration of the pointer's use, or
+	 * use drm_file_get_master() if struct &drm_device.master_mutex is not
+	 * currently held and there is no other need to hold it. This prevents
+	 * @master from being freed during use.
+	 *
 	 * See also @authentication and @is_master and the :ref:`section on
 	 * primary nodes and authentication <drm_primary_node>`.
 	 */
Signature · 1 line
2.25.1
#6 lore raw

[Intel-gfx] ✓ Fi.CI.BAT: success for drm: address potential UAF bugs with drm_master ptrs

In reply to Desmond Cheong Zhi Xi
== Series Details ==

== Series Details ==

Series: drm: address potential UAF bugs with drm_master ptrs
URL : https://patchwork.freedesktop.org/series/92439/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_10334 -> Patchwork_20576
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/index.html

Known issues
------------

Here are the changes found in Patchwork_20576 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@core_hotunplug@unbind-rebind:
- fi-bdw-5557u: NOTRUN -> [WARN][1] ([i915#3718])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/fi-bdw-5557u/igt@[email protected]

* igt@gem_huc_copy@huc-copy:
- fi-cfl-8109u: NOTRUN -> [SKIP][2] ([fdo#109271] / [i915#2190])
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/fi-cfl-8109u/igt@[email protected]

* igt@kms_chamelium@dp-crc-fast:
- fi-bdw-5557u: NOTRUN -> [SKIP][3] ([fdo#109271] / [fdo#111827]) +8 similar issues
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/fi-bdw-5557u/igt@[email protected]

* igt@kms_chamelium@hdmi-hpd-fast:
- fi-cfl-8109u: NOTRUN -> [SKIP][4] ([fdo#109271] / [fdo#111827]) +8 similar issues
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/fi-cfl-8109u/igt@[email protected]

* igt@kms_pipe_crc_basic@compare-crc-sanitycheck-pipe-d:
- fi-cfl-8109u: NOTRUN -> [SKIP][5] ([fdo#109271] / [i915#533])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/fi-cfl-8109u/igt@[email protected]

* igt@kms_psr@cursor_plane_move:
- fi-bdw-5557u: NOTRUN -> [SKIP][6] ([fdo#109271]) +9 similar issues
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/fi-bdw-5557u/igt@kms_psr@cursor_plane_move.html

* igt@kms_psr@primary_mmap_gtt:
- fi-cfl-8109u: NOTRUN -> [SKIP][7] ([fdo#109271]) +6 similar issues
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/fi-cfl-8109u/igt@kms_psr@primary_mmap_gtt.html

* igt@runner@aborted:
- fi-cfl-8109u: NOTRUN -> [FAIL][8] ([i915#2722] / [i915#3363] / [i915#3744])
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/fi-cfl-8109u/igt@[email protected]

* igt@vgem_basic@unload:
- fi-cfl-8109u: NOTRUN -> [INCOMPLETE][9] ([i915#3744])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/fi-cfl-8109u/igt@[email protected]
- fi-bdw-5557u: NOTRUN -> [INCOMPLETE][10] ([i915#3744])
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/fi-bdw-5557u/igt@[email protected]

#### Possible fixes ####

* igt@gem_exec_suspend@basic-s0:
- fi-cfl-8109u: [INCOMPLETE][11] ([i915#155]) -> [PASS][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/fi-cfl-8109u/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/fi-cfl-8109u/igt@[email protected]

* igt@gem_exec_suspend@basic-s3:
- {fi-tgl-1115g4}: [FAIL][13] ([i915#1888]) -> [PASS][14]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/fi-tgl-1115g4/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/fi-tgl-1115g4/igt@[email protected]

#### Warnings ####

* igt@runner@aborted:
- fi-bdw-5557u: [FAIL][15] ([i915#1602] / [i915#2029]) -> [FAIL][16] ([i915#2722] / [i915#3744])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/fi-bdw-5557u/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/fi-bdw-5557u/igt@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[i915#155]: https://gitlab.freedesktop.org/drm/intel/issues/155
[i915#1602]: https://gitlab.freedesktop.org/drm/intel/issues/1602
[i915#1888]: https://gitlab.freedesktop.org/drm/intel/issues/1888
[i915#2029]: https://gitlab.freedesktop.org/drm/intel/issues/2029
[i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
[i915#2722]: https://gitlab.freedesktop.org/drm/intel/issues/2722
[i915#3363]: https://gitlab.freedesktop.org/drm/intel/issues/3363
[i915#3718]: https://gitlab.freedesktop.org/drm/intel/issues/3718
[i915#3744]: https://gitlab.freedesktop.org/drm/intel/issues/3744
[i915#533]: https://gitlab.freedesktop.org/drm/intel/issues/533

Participating hosts (40 -> 39)
------------------------------

Missing (1): fi-bdw-samus

Build changes
-------------

* Linux: CI_DRM_10334 -> Patchwork_20576

CI-20190529: 20190529
CI_DRM_10334: 22eab2dac772b5eea4613e351d2f323c23912c53 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_6134: cd63c83e23789eb194d38b8d272247a88122f2f6 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_20576: 5f2666f1141e93a44842a7069f4545a8e354cd41 @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

5f2666f1141e drm: protect drm_master pointers in drm_lease.c 252b70084bd9 drm: serialize drm_file.master with a new spinlock d4ef2688f236 drm: add a locked version of drm_is_current_master 4157f7d20a99 drm: avoid blocking in drm_clients_info's rcu section c7f0401559e7 drm: avoid circular locks in drm_mode_getconnector

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/index.html

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#7 lore raw

[Intel-gfx] ✗ Fi.CI.IGT: failure for drm: address potential UAF bugs with drm_master ptrs

In reply to Desmond Cheong Zhi Xi
== Series Details ==

== Series Details ==

Series: drm: address potential UAF bugs with drm_master ptrs
URL : https://patchwork.freedesktop.org/series/92439/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_10334_full -> Patchwork_20576_full
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_20576_full absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_20576_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in Patchwork_20576_full:

### IGT changes ###

#### Possible regressions ####

* igt@i915_pm_dc@dc5-dpms:
- shard-iclb: [PASS][1] -> [DMESG-FAIL][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-iclb6/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-iclb3/igt@[email protected]

#### Suppressed ####

The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.

* igt@kms_ccs@pipe-a-bad-aux-stride-yf_tiled_ccs:
- {shard-rkl}: [FAIL][3] ([i915#3678]) -> [SKIP][4] +3 similar issues
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-rkl-5/igt@kms_ccs@pipe-a-bad-aux-stride-yf_tiled_ccs.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-rkl-6/igt@kms_ccs@pipe-a-bad-aux-stride-yf_tiled_ccs.html

* igt@kms_dither@fb-8bpc-vs-panel-6bpc:
- {shard-rkl}: NOTRUN -> [SKIP][5]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-rkl-1/igt@[email protected]

Known issues
------------

Here are the changes found in Patchwork_20576_full that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@drm_import_export@flink:
- shard-glk: [PASS][6] -> [INCOMPLETE][7] ([i915#2369])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-glk4/igt@[email protected]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-glk8/igt@[email protected]

* igt@gem_ctx_persistence@legacy-engines-mixed:
- shard-snb: NOTRUN -> [SKIP][8] ([fdo#109271] / [i915#1099]) +4 similar issues
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-snb2/igt@[email protected]

* igt@gem_exec_fair@basic-none-share@rcs0:
- shard-iclb: NOTRUN -> [FAIL][9] ([i915#2842])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-iclb5/igt@gem_exec_fair@[email protected]

* igt@gem_exec_fair@basic-none@vcs0:
- shard-kbl: [PASS][10] -> [FAIL][11] ([i915#2842]) +2 similar issues
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-kbl1/igt@gem_exec_fair@[email protected]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-kbl2/igt@gem_exec_fair@[email protected]

* igt@gem_exec_fair@basic-pace@bcs0:
- shard-tglb: [PASS][12] -> [FAIL][13] ([i915#2842])
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-tglb3/igt@gem_exec_fair@[email protected]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-tglb6/igt@gem_exec_fair@[email protected]

* igt@gem_exec_fair@basic-throttle@rcs0:
- shard-iclb: [PASS][14] -> [FAIL][15] ([i915#2849])
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-iclb6/igt@gem_exec_fair@[email protected]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-iclb2/igt@gem_exec_fair@[email protected]

* igt@gem_exec_whisper@basic-forked:
- shard-glk: [PASS][16] -> [DMESG-WARN][17] ([i915#118] / [i915#95]) +1 similar issue
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-glk1/igt@[email protected]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-glk5/igt@[email protected]

* igt@gem_huc_copy@huc-copy:
- shard-tglb: [PASS][18] -> [SKIP][19] ([i915#2190])
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-tglb3/igt@[email protected]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-tglb6/igt@[email protected]

* igt@gem_pwrite@basic-exhaustion:
- shard-snb: NOTRUN -> [WARN][20] ([i915#2658])
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-snb2/igt@[email protected]

* igt@gem_userptr_blits@vma-merge:
- shard-snb: NOTRUN -> [FAIL][21] ([i915#2724])
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-snb2/igt@[email protected]

* igt@gen9_exec_parse@batch-without-end:
- shard-iclb: NOTRUN -> [SKIP][22] ([fdo#112306])
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-iclb3/igt@[email protected]

* igt@i915_pm_rc6_residency@rc6-fence:
- shard-iclb: NOTRUN -> [WARN][23] ([i915#1804] / [i915#2684])
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-iclb3/igt@[email protected]

* igt@kms_big_fb@yf-tiled-max-hw-stride-64bpp-rotate-0:
- shard-apl: NOTRUN -> [SKIP][24] ([fdo#109271]) +186 similar issues
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-apl2/igt@[email protected]

* igt@kms_chamelium@hdmi-hpd-enable-disable-mode:
- shard-snb: NOTRUN -> [SKIP][25] ([fdo#109271] / [fdo#111827]) +23 similar issues
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-snb5/igt@[email protected]

* igt@kms_chamelium@vga-edid-read:
- shard-apl: NOTRUN -> [SKIP][26] ([fdo#109271] / [fdo#111827]) +17 similar issues
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-apl7/igt@[email protected]

* igt@kms_chamelium@vga-hpd:
- shard-skl: NOTRUN -> [SKIP][27] ([fdo#109271] / [fdo#111827]) +3 similar issues
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-skl4/igt@[email protected]

* igt@kms_chamelium@vga-hpd-without-ddc:
- shard-iclb: NOTRUN -> [SKIP][28] ([fdo#109284] / [fdo#111827]) +1 similar issue
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-iclb5/igt@[email protected]

* igt@kms_color_chamelium@pipe-d-ctm-blue-to-red:
- shard-glk: NOTRUN -> [SKIP][29] ([fdo#109271] / [fdo#111827]) +1 similar issue
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-glk7/igt@[email protected]
- shard-iclb: NOTRUN -> [SKIP][30] ([fdo#109278] / [fdo#109284] / [fdo#111827])
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-iclb3/igt@[email protected]

* igt@kms_color_chamelium@pipe-d-ctm-negative:
- shard-kbl: NOTRUN -> [SKIP][31] ([fdo#109271] / [fdo#111827]) +3 similar issues
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-kbl7/igt@[email protected]

* igt@kms_content_protection@atomic:
- shard-kbl: NOTRUN -> [TIMEOUT][32] ([i915#1319])
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-kbl2/igt@[email protected]
- shard-iclb: NOTRUN -> [SKIP][33] ([fdo#109300] / [fdo#111066])
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-iclb3/igt@[email protected]

* igt@kms_content_protection@lic:
- shard-apl: NOTRUN -> [TIMEOUT][34] ([i915#1319]) +2 similar issues
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-apl6/igt@[email protected]

* igt@kms_cursor_crc@pipe-a-cursor-64x64-random:
- shard-apl: NOTRUN -> [FAIL][35] ([i915#3444])
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-apl8/igt@[email protected]

* igt@kms_cursor_crc@pipe-b-cursor-128x42-random:
- shard-skl: [PASS][36] -> [FAIL][37] ([i915#3444])
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-skl6/igt@[email protected]
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-skl8/igt@[email protected]

* igt@kms_cursor_crc@pipe-c-cursor-32x10-onscreen:
- shard-kbl: NOTRUN -> [SKIP][38] ([fdo#109271]) +34 similar issues
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-kbl7/igt@[email protected]

* igt@kms_cursor_crc@pipe-c-cursor-512x512-random:
- shard-iclb: NOTRUN -> [SKIP][39] ([fdo#109278] / [fdo#109279])
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-iclb3/igt@[email protected]

* igt@kms_cursor_crc@pipe-d-cursor-512x170-offscreen:
- shard-iclb: NOTRUN -> [SKIP][40] ([fdo#109278]) +5 similar issues
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-iclb5/igt@[email protected]

* igt@kms_flip@flip-vs-suspend-interruptible@a-dp1:
- shard-apl: NOTRUN -> [INCOMPLETE][41] ([i915#180])
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-apl2/igt@kms_flip@[email protected]

* igt@kms_flip@flip-vs-suspend@a-edp1:
- shard-skl: [PASS][42] -> [INCOMPLETE][43] ([i915#146] / [i915#198] / [i915#2910])
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-skl8/igt@kms_flip@[email protected]
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-skl4/igt@kms_flip@[email protected]

* igt@kms_flip@plain-flip-fb-recreate-interruptible@c-edp1:
- shard-skl: [PASS][44] -> [FAIL][45] ([i915#2122]) +1 similar issue
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-skl5/igt@kms_flip@[email protected]
[45]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-skl1/igt@kms_flip@[email protected]

* igt@kms_flip_scaled_crc@flip-32bpp-ytileccs-to-64bpp-ytile:
- shard-snb: NOTRUN -> [SKIP][46] ([fdo#109271]) +459 similar issues
[46]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-snb6/igt@[email protected]

* igt@kms_flip_scaled_crc@flip-64bpp-ytile-to-32bpp-ytilercccs:
- shard-skl: NOTRUN -> [SKIP][47] ([fdo#109271] / [i915#2672])
[47]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-skl4/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbc-2p-scndscrn-pri-indfb-draw-blt:
- shard-skl: NOTRUN -> [SKIP][48] ([fdo#109271]) +68 similar issues
[48]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-skl4/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbcpsr-2p-pri-indfb-multidraw:
- shard-glk: NOTRUN -> [SKIP][49] ([fdo#109271]) +12 similar issues
[49]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-glk7/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbcpsr-2p-shrfb-fliptrack-mmap-gtt:
- shard-iclb: NOTRUN -> [SKIP][50] ([fdo#109280]) +3 similar issues
[50]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-iclb5/igt@[email protected]

* igt@kms_hdr@bpc-switch-suspend:
- shard-kbl: [PASS][51] -> [DMESG-WARN][52] ([i915#180]) +4 similar issues
[51]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-kbl4/igt@[email protected]
[52]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-kbl1/igt@[email protected]

* igt@kms_pipe_crc_basic@nonblocking-crc-pipe-d-frame-sequence:
- shard-apl: NOTRUN -> [SKIP][53] ([fdo#109271] / [i915#533]) +1 similar issue
[53]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-apl6/igt@[email protected]

* igt@kms_plane_alpha_blend@pipe-a-alpha-opaque-fb:
- shard-apl: NOTRUN -> [FAIL][54] ([fdo#108145] / [i915#265]) +2 similar issues
[54]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-apl6/igt@[email protected]

* igt@kms_psr2_sf@overlay-plane-update-sf-dmg-area-1:
- shard-kbl: NOTRUN -> [SKIP][55] ([fdo#109271] / [i915#658]) +2 similar issues
[55]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-kbl2/igt@[email protected]
- shard-iclb: NOTRUN -> [SKIP][56] ([i915#658])
[56]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-iclb3/igt@[email protected]
- shard-glk: NOTRUN -> [SKIP][57] ([fdo#109271] / [i915#658])
[57]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-glk7/igt@[email protected]

* igt@kms_psr2_sf@overlay-primary-update-sf-dmg-area-5:
- shard-apl: NOTRUN -> [SKIP][58] ([fdo#109271] / [i915#658]) +2 similar issues
[58]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-apl7/igt@[email protected]

* igt@kms_psr2_sf@primary-plane-update-sf-dmg-area-3:
- shard-skl: NOTRUN -> [SKIP][59] ([fdo#109271] / [i915#658])
[59]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-skl4/igt@[email protected]

* igt@kms_psr@psr2_cursor_plane_onoff:
- shard-iclb: [PASS][60] -> [SKIP][61] ([fdo#109441]) +1 similar issue
[60]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-iclb2/igt@kms_psr@psr2_cursor_plane_onoff.html
[61]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-iclb8/igt@kms_psr@psr2_cursor_plane_onoff.html

* igt@kms_psr@psr2_primary_mmap_cpu:
- shard-iclb: NOTRUN -> [SKIP][62] ([fdo#109441])
[62]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-iclb3/igt@kms_psr@psr2_primary_mmap_cpu.html

* igt@kms_sysfs_edid_timing:
- shard-apl: NOTRUN -> [FAIL][63] ([IGT#2])
[63]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-apl8/igt@kms_sysfs_edid_timing.html

* igt@kms_vblank@pipe-a-ts-continuation-suspend:
- shard-kbl: [PASS][64] -> [DMESG-WARN][65] ([i915#180] / [i915#295])
[64]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-kbl7/igt@[email protected]
[65]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-kbl1/igt@[email protected]

* igt@kms_vblank@pipe-b-ts-continuation-suspend:
- shard-apl: [PASS][66] -> [DMESG-WARN][67] ([i915#180])
[66]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-apl8/igt@[email protected]
[67]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-apl3/igt@[email protected]

* igt@kms_writeback@writeback-pixel-formats:
- shard-apl: NOTRUN -> [SKIP][68] ([fdo#109271] / [i915#2437])
[68]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-apl7/igt@[email protected]

* igt@nouveau_crc@pipe-c-ctx-flip-detection:
- shard-iclb: NOTRUN -> [SKIP][69] ([i915#2530])
[69]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-iclb3/igt@[email protected]

* igt@prime_nv_api@i915_nv_double_export:
- shard-iclb: NOTRUN -> [SKIP][70] ([fdo#109291])
[70]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-iclb3/igt@prime_nv_api@i915_nv_double_export.html

* igt@sysfs_clients@recycle:
- shard-apl: NOTRUN -> [SKIP][71] ([fdo#109271] / [i915#2994]) +1 similar issue
[71]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-apl7/igt@[email protected]

* igt@vgem_basic@unload:
- shard-snb: NOTRUN -> [INCOMPLETE][72] ([i915#3744])
[72]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-snb2/igt@[email protected]

#### Possible fixes ####

* igt@fbdev@info:
- {shard-rkl}: [SKIP][73] ([i915#2582]) -> [PASS][74]
[73]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-rkl-5/igt@[email protected]
[74]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-rkl-6/igt@[email protected]

* igt@gem_eio@in-flight-contexts-10ms:
- {shard-rkl}: [TIMEOUT][75] ([i915#3063]) -> [PASS][76]
[75]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-rkl-1/igt@[email protected]
[76]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-rkl-2/igt@[email protected]

* igt@gem_eio@unwedge-stress:
- shard-tglb: [TIMEOUT][77] ([i915#2369] / [i915#3063] / [i915#3648]) -> [PASS][78]
[77]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-tglb3/igt@[email protected]
[78]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-tglb2/igt@[email protected]

* igt@gem_exec_fair@basic-pace-solo@rcs0:
- shard-iclb: [FAIL][79] ([i915#2842]) -> [PASS][80]
[79]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-iclb7/igt@gem_exec_fair@[email protected]
[80]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-iclb1/igt@gem_exec_fair@[email protected]
- shard-glk: [FAIL][81] ([i915#2842]) -> [PASS][82] +1 similar issue
[81]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-glk2/igt@gem_exec_fair@[email protected]
[82]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-glk4/igt@gem_exec_fair@[email protected]

* igt@gem_exec_fair@basic-pace@vcs0:
- shard-kbl: [SKIP][83] ([fdo#109271]) -> [PASS][84]
[83]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-kbl6/igt@gem_exec_fair@[email protected]
[84]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-kbl3/igt@gem_exec_fair@[email protected]

* igt@gem_exec_fair@basic-throttle@rcs0:
- {shard-rkl}: [FAIL][85] ([i915#2842]) -> [PASS][86]
[85]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-rkl-1/igt@gem_exec_fair@[email protected]
[86]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-rkl-2/igt@gem_exec_fair@[email protected]

* igt@gem_exec_schedule@submit-early-slice@vecs0:
- shard-skl: [INCOMPLETE][87] -> [PASS][88]
[87]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-skl7/igt@gem_exec_schedule@[email protected]
[88]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-skl2/igt@gem_exec_schedule@[email protected]

* igt@gem_mmap_offset@clear:
- {shard-rkl}: [FAIL][89] ([i915#3160]) -> [PASS][90]
[89]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-rkl-1/igt@[email protected]
[90]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-rkl-2/igt@[email protected]

* igt@i915_selftest@live@gt_pm:
- {shard-rkl}: [DMESG-FAIL][91] ([i915#1021]) -> [PASS][92]
[91]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-rkl-6/igt@i915_selftest@live@gt_pm.html
[92]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-rkl-1/igt@i915_selftest@live@gt_pm.html

* igt@kms_async_flips@alternate-sync-async-flip:
- shard-skl: [FAIL][93] ([i915#2521]) -> [PASS][94]
[93]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-skl8/igt@[email protected]
[94]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-skl2/igt@[email protected]

* igt@kms_big_fb@linear-64bpp-rotate-0:
- {shard-rkl}: [SKIP][95] ([i915#3638]) -> [PASS][96] +2 similar issues
[95]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-rkl-2/igt@[email protected]
[96]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-rkl-6/igt@[email protected]

* igt@kms_big_fb@linear-max-hw-stride-32bpp-rotate-0:
- {shard-rkl}: [SKIP][97] ([i915#3721]) -> [PASS][98] +5 similar issues
[97]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-rkl-5/igt@[email protected]
[98]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-rkl-6/igt@[email protected]

* igt@kms_big_fb@y-tiled-32bpp-rotate-90:
- {shard-rkl}: [SKIP][99] ([fdo#111614]) -> [PASS][100]
[99]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-rkl-5/igt@[email protected]
[100]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-rkl-6/igt@[email protected]

* igt@kms_ccs@pipe-b-ccs-on-another-bo-y_tiled_gen12_rc_ccs_cc:
- {shard-rkl}: [FAIL][101] ([i915#3678]) -> [PASS][102] +5 similar issues
[101]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-rkl-5/igt@kms_ccs@pipe-b-ccs-on-another-bo-y_tiled_gen12_rc_ccs_cc.html
[102]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-rkl-6/igt@kms_ccs@pipe-b-ccs-on-another-bo-y_tiled_gen12_rc_ccs_cc.html

* igt@kms_color@pipe-b-ctm-0-25:
- shard-skl: [DMESG-WARN][103] ([i915#1982]) -> [PASS][104]
[103]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-skl10/igt@[email protected]
[104]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-skl10/igt@[email protected]

* igt@kms_color@pipe-c-ctm-negative:
- {shard-rkl}: [SKIP][105] ([i915#1149] / [i915#1849]) -> [PASS][106] +2 similar issues
[105]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-rkl-5/igt@[email protected]
[106]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-rkl-6/igt@[email protected]

* igt@kms_cursor_crc@pipe-b-cursor-256x85-random:
- {shard-rkl}: [SKIP][107] ([fdo#112022]) -> [PASS][108] +7 similar issues
[107]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-rkl-5/igt@[email protected]
[108]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-rkl-6/igt@[email protected]

* igt@kms_cursor_crc@pipe-c-cursor-256x85-random:
- shard-iclb: [FAIL][109] -> [PASS][110] +1 similar issue
[109]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-iclb3/igt@[email protected]
[110]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-iclb6/igt@[email protected]

* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-atomic:
- {shard-rkl}: [SKIP][111] ([fdo#111825]) -> [PASS][112] +4 similar issues
[111]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-rkl-5/igt@[email protected]
[112]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-rkl-6/igt@[email protected]

* igt@kms_draw_crc@draw-method-rgb565-blt-untiled:
- {shard-rkl}: [SKIP][113] ([fdo#111314]) -> [PASS][114] +7 similar issues
[113]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-rkl-5/igt@[email protected]
[114]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-rkl-6/igt@[email protected]

* igt@kms_flip@flip-vs-expired-vblank@a-edp1:
- shard-skl: [FAIL][115] ([i915#79]) -> [PASS][116]
[115]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-skl10/igt@kms_flip@[email protected]
[116]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-skl7/igt@kms_flip@[email protected]

* igt@kms_flip@plain-flip-ts-check-interruptible@a-hdmi-a1:
- shard-glk: [FAIL][117] ([i915#2122]) -> [PASS][118]
[117]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-glk4/igt@kms_flip@[email protected]
[118]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-glk7/igt@kms_flip@[email protected]

* igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-spr-indfb-fullscreen:
- {shard-rkl}: [SKIP][119] ([i915#1849]) -> [PASS][120] +31 similar issues
[119]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-rkl-5/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-spr-indfb-fullscreen.html
[120]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-rkl-6/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-spr-indfb-fullscreen.html

* igt@kms_hdr@bpc-switch-suspend:
- {shard-rkl}: [SKIP][121] ([i915#1845]) -> [PASS][122] +12 similar issues
[121]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-rkl-5/igt@[email protected]
[122]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-rkl-6/igt@[email protected]
- shard-skl: [FAIL][123] ([i915#1188]) -> [PASS][124]
[123]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-skl1/igt@[email protected]
[124]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-skl8/igt@[email protected]

* igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
- shard-kbl: [DMESG-WARN][125] ([i915#180]) -> [PASS][126] +1 similar issue
[125]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-kbl2/igt@[email protected]
[126]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-kbl7/igt@[email protected]

* igt@kms_plane@plane-position-hole-dpms@pipe-b-planes:
- {shard-rkl}: [SKIP][127] ([i915#3558]) -> [PASS][128] +1 similar issue
[127]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-rkl-5/igt@kms_plane@[email protected]
[128]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-rkl-6/igt@kms_plane@[email protected]

* igt@kms_plane_alpha_blend@pipe-c-coverage-7efc:
- shard-skl: [FAIL][129] ([fdo#108145] / [i915#265]) -> [PASS][130] +1 similar issue
[129]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-skl8/igt@[email protected]
[130]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-skl1/igt@[email protected]

* igt@kms_plane_multiple@atomic-pipe-b-tiling-x:
- {shard-rkl}: [SKIP][131] ([i915#1849] / [i915#3558]) -> [PASS][132]
[131]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-rkl-5/igt@[email protected]
[132]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-rkl-6/igt@[email protected]

* igt@kms_psr2_su@frontbuffer:
- shard-iclb: [SKIP][133] ([fdo#109642] / [fdo#111068] / [i915#658]) -> [PASS][134]
[133]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-iclb6/igt@[email protected]
[134]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-iclb2/igt@[email protected]

* igt@kms_psr@psr2_cursor_blt:
- shard-iclb: [SKIP][135] ([fdo#109441]) -> [PASS][136]
[135]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-iclb5/igt@kms_psr@psr2_cursor_blt.html
[136]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-iclb2/igt@kms_psr@psr2_cursor_blt.html

* igt@kms_vblank@pipe-c-accuracy-idle:
- shard-glk: [FAIL][137] ([i915#43]) -> [PASS][138]
[137]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-glk6/igt@[email protected]
[138]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-glk9/igt@[email protected]

* igt@perf@polling-parameterized:
- shard-glk: [FAIL][139] ([i915#1542]) -> [PASS][140]
[139]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-glk2/igt@[email protected]
[140]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-glk4/igt@[email protected]
- shard-skl: [FAIL][141] ([i915#1542]) -> [PASS][142]
[141]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-skl4/igt@[email protected]
[142]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-skl3/igt@[email protected]

#### Warnings ####

* igt@gem_exec_fair@basic-none-solo@rcs0:
- shard-tglb: [FAIL][143] ([i915#2849]) -> [FAIL][144] ([i915#2842])
[143]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10334/shard-tglb2/igt@gem_exec_fair@[email protected]
[144]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/shard-tglb1/igt@gem_exec_fair@[email protected]

* igt@gem_exec_fair@basic-pace@rcs0:
- shard-kbl: [SKIP][145] ([fdo#109271]) -> [FAIL][146] ([i915#2842]

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20576/index.html

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#8 lore raw
In reply to Desmond Cheong Zhi Xi
Quoted 44 lines · Desmond Cheong Zhi Xi

Hi,

In the previous thread on this series we decided to remove a patch that was violating a lockdep requirement in drm_lease. In addition to this change, I took a closer look at the CI logs for the Basic Acceptance Tests and noticed that another regression was introduced. The new patch 2 is a response to this.

Overall, this series addresses potential use-after-free errors when dereferencing pointers to struct drm_master. These were identified after one such bug was caught by Syzbot in drm_getunique():
https://syzkaller.appspot.com/bug?id=148d2f1dfac64af52ffd27b661981a540724f803

The series is broken up into five patches:

1. Move a call to drm_is_current_master() out from a section locked by &dev->mode_config.mutex in drm_mode_getconnector(). This patch does not apply to stable.

2. Move a call to drm_is_current_master() out from the RCU read-side critical section in drm_clients_info().

3. Implement a locked version of drm_is_current_master() function that's used within drm_auth.c.

4. Serialize drm_file.master by introducing a new spinlock that's held whenever the value of drm_file.master changes.

5. Identify areas in drm_lease.c where pointers to struct drm_master are dereferenced, and ensure that the master pointers are not freed during use.

v7 -> v8:
- Remove the patch that moves the call to _drm_lease_held out from the section locked by &dev->mode_config.idr_mutex in __drm_mode_object_find. This patch violated an existing lockdep requirement as reported by the intel-gfx CI.
- Added a new patch that moves a call to drm_is_current_master out from the RCU critical section in drm_clients_info. This was reported by the intel-gfx CI.

v6 -> v7:
- Modify code alignment as suggested by the intel-gfx CI.
- Add a new patch to the series that adds a new lock to serialize drm_file.master, in response to the lockdep splat by the intel-gfx CI.
- Update drm_file_get_master to use the new drm_file.master_lock instead of drm_device.master_mutex, in response to the lockdep splat by the intel-gfx CI.

v5 -> v6:
- Add a new patch to the series that moves the call to _drm_lease_held out from the section locked by &dev->mode_config.idr_mutex in __drm_mode_object_find.
- Clarify the kerneldoc for dereferencing drm_file.master, as suggested by Daniel Vetter.
- Refactor error paths with goto labels so that each function only has a single drm_master_put(), as suggested by Emil Velikov.
- Modify comparisons to NULL into "!master", as suggested by the intel-gfx CI.

v4 -> v5:
- Add a new patch to the series that moves the call to drm_is_current_master in drm_mode_getconnector out from the section locked by &dev->mode_config.mutex.
- Additionally, added a missing semicolon to the patch, caught by the intel-gfx CI.

v3 -> v4:
- Move the call to drm_is_current_master in drm_mode_getconnector out from the section locked by &dev->mode_config.mutex. As suggested by Daniel Vetter. This avoids a circular lock lock dependency as reported here https://patchwork.freedesktop.org/patch/440406/
- Inside drm_is_current_master, instead of grabbing &fpriv->master->dev->master_mutex, we grab &fpriv->minor->dev->master_mutex to avoid dereferencing a null ptr if fpriv->master is not set.
- Modify kerneldoc formatting for drm_file.master, as suggested by Daniel Vetter.
- Additionally, add a file_priv->master NULL check inside drm_file_get_master, and handle the NULL result accordingly in drm_lease.c. As suggested by Daniel Vetter.

Quoted 6 lines

v2 -> v3:
- Move the definition of drm_is_current_master and the _locked version higher up in drm_auth.c to avoid needing a forward declaration of drm_is_current_master_locked. As suggested by Daniel Vetter.
- Instead of leaking drm_device.master_mutex into drm_lease.c to protect drm_master pointers, add a new drm_file_get_master() function that returns drm_file->master while increasing its reference count, to prevent drm_file->master from being freed. As suggested by Daniel Vetter.

v1 -> v2:
- Move the lock and assignment before the DRM_DEBUG_LEASE in drm_mode_get_lease_ioctl, as suggested by Emil Velikov.

Apologies for the delay, I missed your series. Maybe just ping next time around there's silence.

Looks all great, merged to drm-misc-next. Given how complex this was I'm vary of just pushing this to -fixes without some solid testing.

One thing I noticed is that drm_is_current_master could just use the spinlock, since it's only doing a read access. Care to type up that patch?

Also, do you plan to look into that idea we've discussed to flush pending access when we revoke a master or a lease? I think that would be really nice improvement here.
-Daniel

Quoted 20 lines

Desmond Cheong Zhi Xi (5):
drm: avoid circular locks in drm_mode_getconnector
drm: avoid blocking in drm_clients_info's rcu section
drm: add a locked version of drm_is_current_master
drm: serialize drm_file.master with a new spinlock
drm: protect drm_master pointers in drm_lease.c

 drivers/gpu/drm/drm_auth.c      | 93 ++++++++++++++++++++++++---------
 drivers/gpu/drm/drm_connector.c |  5 +-
 drivers/gpu/drm/drm_debugfs.c   |  3 +-
 drivers/gpu/drm/drm_file.c      |  1 +
 drivers/gpu/drm/drm_lease.c     | 81 +++++++++++++++++++++-------
 include/drm/drm_auth.h          |  1 +
 include/drm/drm_file.h          | 18 +++++--
 7 files changed, 152 insertions(+), 50 deletions(-)
Signature · 1 line
2.25.1
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
#9 lore raw
Quoted 49 lines · Daniel Vetter
Quoted 48 lines · Desmond Cheong Zhi Xi

Hi,

In the previous thread on this series we decided to remove a patch that was violating a lockdep requirement in drm_lease. In addition to this change, I took a closer look at the CI logs for the Basic Acceptance Tests and noticed that another regression was introduced. The new patch 2 is a response to this.

Overall, this series addresses potential use-after-free errors when dereferencing pointers to struct drm_master. These were identified after one such bug was caught by Syzbot in drm_getunique():
https://syzkaller.appspot.com/bug?id=148d2f1dfac64af52ffd27b661981a540724f803

The series is broken up into five patches:

1. Move a call to drm_is_current_master() out from a section locked by &dev->mode_config.mutex in drm_mode_getconnector(). This patch does not apply to stable.

2. Move a call to drm_is_current_master() out from the RCU read-side critical section in drm_clients_info().

3. Implement a locked version of drm_is_current_master() function that's used within drm_auth.c.

4. Serialize drm_file.master by introducing a new spinlock that's held whenever the value of drm_file.master changes.

5. Identify areas in drm_lease.c where pointers to struct drm_master are dereferenced, and ensure that the master pointers are not freed during use.

v7 -> v8:
- Remove the patch that moves the call to _drm_lease_held out from the section locked by &dev->mode_config.idr_mutex in __drm_mode_object_find. This patch violated an existing lockdep requirement as reported by the intel-gfx CI.
- Added a new patch that moves a call to drm_is_current_master out from the RCU critical section in drm_clients_info. This was reported by the intel-gfx CI.

v6 -> v7:
- Modify code alignment as suggested by the intel-gfx CI.
- Add a new patch to the series that adds a new lock to serialize drm_file.master, in response to the lockdep splat by the intel-gfx CI.
- Update drm_file_get_master to use the new drm_file.master_lock instead of drm_device.master_mutex, in response to the lockdep splat by the intel-gfx CI.

v5 -> v6:
- Add a new patch to the series that moves the call to _drm_lease_held out from the section locked by &dev->mode_config.idr_mutex in __drm_mode_object_find.
- Clarify the kerneldoc for dereferencing drm_file.master, as suggested by Daniel Vetter.
- Refactor error paths with goto labels so that each function only has a single drm_master_put(), as suggested by Emil Velikov.
- Modify comparisons to NULL into "!master", as suggested by the intel-gfx CI.

v4 -> v5:
- Add a new patch to the series that moves the call to drm_is_current_master in drm_mode_getconnector out from the section locked by &dev->mode_config.mutex.
- Additionally, added a missing semicolon to the patch, caught by the intel-gfx CI.

v3 -> v4:
- Move the call to drm_is_current_master in drm_mode_getconnector out from the section locked by &dev->mode_config.mutex. As suggested by Daniel Vetter. This avoids a circular lock lock dependency as reported here https://patchwork.freedesktop.org/patch/440406/
- Inside drm_is_current_master, instead of grabbing &fpriv->master->dev->master_mutex, we grab &fpriv->minor->dev->master_mutex to avoid dereferencing a null ptr if fpriv->master is not set.
- Modify kerneldoc formatting for drm_file.master, as suggested by Daniel Vetter.
- Additionally, add a file_priv->master NULL check inside drm_file_get_master, and handle the NULL result accordingly in drm_lease.c. As suggested by Daniel Vetter.

v2 -> v3:
- Move the definition of drm_is_current_master and the _locked version higher up in drm_auth.c to avoid needing a forward declaration of drm_is_current_master_locked. As suggested by Daniel Vetter.
- Instead of leaking drm_device.master_mutex into drm_lease.c to protect drm_master pointers, add a new drm_file_get_master() function that returns drm_file->master while increasing its reference count, to prevent drm_file->master from being freed. As suggested by Daniel Vetter.

Quoted 9 lines
Quoted 2 lines

v1 -> v2:
- Move the lock and assignment before the DRM_DEBUG_LEASE in drm_mode_get_lease_ioctl, as suggested by Emil Velikov.

Apologies for the delay, I missed your series. Maybe just ping next time around there's silence.

Looks all great, merged to drm-misc-next. Given how complex this was I'm vary of just pushing this to -fixes without some solid testing.

Hi Daniel,

Thanks for merging, more testing definitely sounds good to me.

Quoted 3 lines

One thing I noticed is that drm_is_current_master could just use the spinlock, since it's only doing a read access. Care to type up that patch?

I thought about this too, but I'm not sure if that's the best solution.

drm_is_current_master calls drm_lease_owner which then walks up the tree of master lessors. The spinlock protects the master of the current drm file, but subsequent lessors aren't protected without holding the device's master mutex.

Quoted 5 lines

Also, do you plan to look into that idea we've discussed to flush pending access when we revoke a master or a lease? I think that would be really nice improvement here.
-Daniel

Yup, now that the potential UAFs are addressed (hopefully), I'll take a closer look and propose a patch for this.

Best wishes,
Desmond

Quoted 21 lines
Quoted 20 lines

Desmond Cheong Zhi Xi (5):
drm: avoid circular locks in drm_mode_getconnector
drm: avoid blocking in drm_clients_info's rcu section
drm: add a locked version of drm_is_current_master
drm: serialize drm_file.master with a new spinlock
drm: protect drm_master pointers in drm_lease.c

  drivers/gpu/drm/drm_auth.c      | 93 ++++++++++++++++++++++++---------
  drivers/gpu/drm/drm_connector.c |  5 +-
  drivers/gpu/drm/drm_debugfs.c   |  3 +-
  drivers/gpu/drm/drm_file.c      |  1 +
  drivers/gpu/drm/drm_lease.c     | 81 +++++++++++++++++++++-------
  include/drm/drm_auth.h          |  1 +
  include/drm/drm_file.h          | 18 +++++--
  7 files changed, 152 insertions(+), 50 deletions(-)
Signature · 1 line
2.25.1
#10 lore raw
Quoted 68 lines · Desmond Cheong Zhi Xi
Quoted 49 lines · Daniel Vetter
Quoted 48 lines · Desmond Cheong Zhi Xi

Hi,

In the previous thread on this series we decided to remove a patch that was violating a lockdep requirement in drm_lease. In addition to this change, I took a closer look at the CI logs for the Basic Acceptance Tests and noticed that another regression was introduced. The new patch 2 is a response to this.

Overall, this series addresses potential use-after-free errors when dereferencing pointers to struct drm_master. These were identified after one such bug was caught by Syzbot in drm_getunique():
https://syzkaller.appspot.com/bug?id=148d2f1dfac64af52ffd27b661981a540724f803

The series is broken up into five patches:

1. Move a call to drm_is_current_master() out from a section locked by &dev->mode_config.mutex in drm_mode_getconnector(). This patch does not apply to stable.

2. Move a call to drm_is_current_master() out from the RCU read-side critical section in drm_clients_info().

3. Implement a locked version of drm_is_current_master() function that's used within drm_auth.c.

4. Serialize drm_file.master by introducing a new spinlock that's held whenever the value of drm_file.master changes.

5. Identify areas in drm_lease.c where pointers to struct drm_master are dereferenced, and ensure that the master pointers are not freed during use.

v7 -> v8:
- Remove the patch that moves the call to _drm_lease_held out from the section locked by &dev->mode_config.idr_mutex in __drm_mode_object_find. This patch violated an existing lockdep requirement as reported by the intel-gfx CI.
- Added a new patch that moves a call to drm_is_current_master out from the RCU critical section in drm_clients_info. This was reported by the intel-gfx CI.

v6 -> v7:
- Modify code alignment as suggested by the intel-gfx CI.
- Add a new patch to the series that adds a new lock to serialize drm_file.master, in response to the lockdep splat by the intel-gfx CI.
- Update drm_file_get_master to use the new drm_file.master_lock instead of drm_device.master_mutex, in response to the lockdep splat by the intel-gfx CI.

v5 -> v6:
- Add a new patch to the series that moves the call to _drm_lease_held out from the section locked by &dev->mode_config.idr_mutex in __drm_mode_object_find.
- Clarify the kerneldoc for dereferencing drm_file.master, as suggested by Daniel Vetter.
- Refactor error paths with goto labels so that each function only has a single drm_master_put(), as suggested by Emil Velikov.
- Modify comparisons to NULL into "!master", as suggested by the intel-gfx CI.

v4 -> v5:
- Add a new patch to the series that moves the call to drm_is_current_master in drm_mode_getconnector out from the section locked by &dev->mode_config.mutex.
- Additionally, added a missing semicolon to the patch, caught by the intel-gfx CI.

v3 -> v4:
- Move the call to drm_is_current_master in drm_mode_getconnector out from the section locked by &dev->mode_config.mutex. As suggested by Daniel Vetter. This avoids a circular lock lock dependency as reported here https://patchwork.freedesktop.org/patch/440406/
- Inside drm_is_current_master, instead of grabbing &fpriv->master->dev->master_mutex, we grab &fpriv->minor->dev->master_mutex to avoid dereferencing a null ptr if fpriv->master is not set.
- Modify kerneldoc formatting for drm_file.master, as suggested by Daniel Vetter.
- Additionally, add a file_priv->master NULL check inside drm_file_get_master, and handle the NULL result accordingly in drm_lease.c. As suggested by Daniel Vetter.

v2 -> v3:
- Move the definition of drm_is_current_master and the _locked version higher up in drm_auth.c to avoid needing a forward declaration of drm_is_current_master_locked. As suggested by Daniel Vetter.
- Instead of leaking drm_device.master_mutex into drm_lease.c to protect drm_master pointers, add a new drm_file_get_master() function that returns drm_file->master while increasing its reference count, to prevent drm_file->master from being freed. As suggested by Daniel Vetter.

Quoted 9 lines
Quoted 2 lines

v1 -> v2:
- Move the lock and assignment before the DRM_DEBUG_LEASE in drm_mode_get_lease_ioctl, as suggested by Emil Velikov.

Apologies for the delay, I missed your series. Maybe just ping next time around there's silence.

Looks all great, merged to drm-misc-next. Given how complex this was I'm vary of just pushing this to -fixes without some solid testing.

Hi Daniel,

Thanks for merging, more testing definitely sounds good to me.

Quoted 3 lines

One thing I noticed is that drm_is_current_master could just use the spinlock, since it's only doing a read access. Care to type up that patch?

Quoted 6 lines

I thought about this too, but I'm not sure if that's the best solution.

drm_is_current_master calls drm_lease_owner which then walks up the tree of master lessors. The spinlock protects the master of the current drm file, but subsequent lessors aren't protected without holding the device's master mutex.

But this isn't a fpriv->master pointer, but a master->lessor pointer. Which should never ever be able to change (we'd have tons of uaf bugs around drm_lease_owner otherwise). So I don't think there's anything that dev->master_lock protects here that fpriv->master_lookup_lock doesn't protect already?

Or am I missing something?

The comment in the struct drm_master says it's protected by mode_config.idr_mutex, but that only applies to the idrs and lists I think.

Quoted 8 lines
Quoted 5 lines

Also, do you plan to look into that idea we've discussed to flush pending access when we revoke a master or a lease? I think that would be really nice improvement here.
-Daniel

Yup, now that the potential UAFs are addressed (hopefully), I'll take a closer look and propose a patch for this.

Thanks a lot.
-Daniel

Quoted 26 lines

Best wishes,
Desmond

Quoted 21 lines
Quoted 20 lines

Desmond Cheong Zhi Xi (5):
drm: avoid circular locks in drm_mode_getconnector
drm: avoid blocking in drm_clients_info's rcu section
drm: add a locked version of drm_is_current_master
drm: serialize drm_file.master with a new spinlock
drm: protect drm_master pointers in drm_lease.c

  drivers/gpu/drm/drm_auth.c      | 93 ++++++++++++++++++++++++---------
  drivers/gpu/drm/drm_connector.c |  5 +-
  drivers/gpu/drm/drm_debugfs.c   |  3 +-
  drivers/gpu/drm/drm_file.c      |  1 +
  drivers/gpu/drm/drm_lease.c     | 81 +++++++++++++++++++++-------
  include/drm/drm_auth.h          |  1 +
  include/drm/drm_file.h          | 18 +++++--
  7 files changed, 152 insertions(+), 50 deletions(-)

--
2.25.1

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#11 lore raw
Quoted 83 lines · Daniel Vetter
Quoted 68 lines · Desmond Cheong Zhi Xi
Quoted 49 lines · Daniel Vetter
Quoted 48 lines · Desmond Cheong Zhi Xi

Hi,

In the previous thread on this series we decided to remove a patch that was violating a lockdep requirement in drm_lease. In addition to this change, I took a closer look at the CI logs for the Basic Acceptance Tests and noticed that another regression was introduced. The new patch 2 is a response to this.

Overall, this series addresses potential use-after-free errors when dereferencing pointers to struct drm_master. These were identified after one such bug was caught by Syzbot in drm_getunique():
https://syzkaller.appspot.com/bug?id=148d2f1dfac64af52ffd27b661981a540724f803

The series is broken up into five patches:

1. Move a call to drm_is_current_master() out from a section locked by &dev->mode_config.mutex in drm_mode_getconnector(). This patch does not apply to stable.

2. Move a call to drm_is_current_master() out from the RCU read-side critical section in drm_clients_info().

3. Implement a locked version of drm_is_current_master() function that's used within drm_auth.c.

4. Serialize drm_file.master by introducing a new spinlock that's held whenever the value of drm_file.master changes.

5. Identify areas in drm_lease.c where pointers to struct drm_master are dereferenced, and ensure that the master pointers are not freed during use.

v7 -> v8:
- Remove the patch that moves the call to _drm_lease_held out from the section locked by &dev->mode_config.idr_mutex in __drm_mode_object_find. This patch violated an existing lockdep requirement as reported by the intel-gfx CI.
- Added a new patch that moves a call to drm_is_current_master out from the RCU critical section in drm_clients_info. This was reported by the intel-gfx CI.

v6 -> v7:
- Modify code alignment as suggested by the intel-gfx CI.
- Add a new patch to the series that adds a new lock to serialize drm_file.master, in response to the lockdep splat by the intel-gfx CI.
- Update drm_file_get_master to use the new drm_file.master_lock instead of drm_device.master_mutex, in response to the lockdep splat by the intel-gfx CI.

v5 -> v6:
- Add a new patch to the series that moves the call to _drm_lease_held out from the section locked by &dev->mode_config.idr_mutex in __drm_mode_object_find.
- Clarify the kerneldoc for dereferencing drm_file.master, as suggested by Daniel Vetter.
- Refactor error paths with goto labels so that each function only has a single drm_master_put(), as suggested by Emil Velikov.
- Modify comparisons to NULL into "!master", as suggested by the intel-gfx CI.

v4 -> v5:
- Add a new patch to the series that moves the call to drm_is_current_master in drm_mode_getconnector out from the section locked by &dev->mode_config.mutex.
- Additionally, added a missing semicolon to the patch, caught by the intel-gfx CI.

v3 -> v4:
- Move the call to drm_is_current_master in drm_mode_getconnector out from the section locked by &dev->mode_config.mutex. As suggested by Daniel Vetter. This avoids a circular lock lock dependency as reported here https://patchwork.freedesktop.org/patch/440406/
- Inside drm_is_current_master, instead of grabbing &fpriv->master->dev->master_mutex, we grab &fpriv->minor->dev->master_mutex to avoid dereferencing a null ptr if fpriv->master is not set.
- Modify kerneldoc formatting for drm_file.master, as suggested by Daniel Vetter.
- Additionally, add a file_priv->master NULL check inside drm_file_get_master, and handle the NULL result accordingly in drm_lease.c. As suggested by Daniel Vetter.

v2 -> v3:
- Move the definition of drm_is_current_master and the _locked version higher up in drm_auth.c to avoid needing a forward declaration of drm_is_current_master_locked. As suggested by Daniel Vetter.
- Instead of leaking drm_device.master_mutex into drm_lease.c to protect drm_master pointers, add a new drm_file_get_master() function that returns drm_file->master while increasing its reference count, to prevent drm_file->master from being freed. As suggested by Daniel Vetter.

Quoted 9 lines
Quoted 2 lines

v1 -> v2:
- Move the lock and assignment before the DRM_DEBUG_LEASE in drm_mode_get_lease_ioctl, as suggested by Emil Velikov.

Apologies for the delay, I missed your series. Maybe just ping next time around there's silence.

Looks all great, merged to drm-misc-next. Given how complex this was I'm vary of just pushing this to -fixes without some solid testing.

Hi Daniel,

Thanks for merging, more testing definitely sounds good to me.

Quoted 3 lines

One thing I noticed is that drm_is_current_master could just use the spinlock, since it's only doing a read access. Care to type up that patch?

Quoted 6 lines

I thought about this too, but I'm not sure if that's the best solution.

drm_is_current_master calls drm_lease_owner which then walks up the tree of master lessors. The spinlock protects the master of the current drm file, but subsequent lessors aren't protected without holding the device's master mutex.

But this isn't a fpriv->master pointer, but a master->lessor pointer. Which should never ever be able to change (we'd have tons of uaf bugs around drm_lease_owner otherwise). So I don't think there's anything that dev->master_lock protects here that fpriv->master_lookup_lock doesn't protect already?

Quoted 5 lines

Or am I missing something?

Quoted 1 line

The comment in the struct drm_master says it's protected by

mode_config.idr_mutex, but that only applies to the idrs and lists I think.

Ah you're right, I also completely forgot that lessees hold a reference to their lessor so nothing will be freed as long as the spinlock is held. I'll prepare that patch then, thanks for pointing it out.

Quoted 40 lines
Quoted 8 lines
Quoted 5 lines

Also, do you plan to look into that idea we've discussed to flush pending access when we revoke a master or a lease? I think that would be really nice improvement here.
-Daniel

Yup, now that the potential UAFs are addressed (hopefully), I'll take a closer look and propose a patch for this.

Thanks a lot.
-Daniel

Quoted 26 lines

Best wishes,
Desmond

Quoted 21 lines
Quoted 20 lines

Desmond Cheong Zhi Xi (5):
drm: avoid circular locks in drm_mode_getconnector
drm: avoid blocking in drm_clients_info's rcu section
drm: add a locked version of drm_is_current_master
drm: serialize drm_file.master with a new spinlock
drm: protect drm_master pointers in drm_lease.c

   drivers/gpu/drm/drm_auth.c      | 93 ++++++++++++++++++++++++---------
   drivers/gpu/drm/drm_connector.c |  5 +-
   drivers/gpu/drm/drm_debugfs.c   |  3 +-
   drivers/gpu/drm/drm_file.c      |  1 +
   drivers/gpu/drm/drm_lease.c     | 81 +++++++++++++++++++++-------
   include/drm/drm_auth.h          |  1 +
   include/drm/drm_file.h          | 18 +++++--
   7 files changed, 152 insertions(+), 50 deletions(-)

--
2.25.1

#12 lore raw
Quoted 90 lines · Desmond Cheong Zhi Xi
Quoted 83 lines · Daniel Vetter
Quoted 68 lines · Desmond Cheong Zhi Xi
Quoted 49 lines · Daniel Vetter
Quoted 48 lines · Desmond Cheong Zhi Xi

Hi,

In the previous thread on this series we decided to remove a patch that was violating a lockdep requirement in drm_lease. In addition to this change, I took a closer look at the CI logs for the Basic Acceptance Tests and noticed that another regression was introduced. The new patch 2 is a response to this.

Overall, this series addresses potential use-after-free errors when dereferencing pointers to struct drm_master. These were identified after one such bug was caught by Syzbot in drm_getunique():
https://syzkaller.appspot.com/bug?id=148d2f1dfac64af52ffd27b661981a540724f803

The series is broken up into five patches:

1. Move a call to drm_is_current_master() out from a section locked by &dev->mode_config.mutex in drm_mode_getconnector(). This patch does not apply to stable.

2. Move a call to drm_is_current_master() out from the RCU read-side critical section in drm_clients_info().

3. Implement a locked version of drm_is_current_master() function that's used within drm_auth.c.

4. Serialize drm_file.master by introducing a new spinlock that's held whenever the value of drm_file.master changes.

5. Identify areas in drm_lease.c where pointers to struct drm_master are dereferenced, and ensure that the master pointers are not freed during use.

v7 -> v8:
- Remove the patch that moves the call to _drm_lease_held out from the section locked by &dev->mode_config.idr_mutex in __drm_mode_object_find. This patch violated an existing lockdep requirement as reported by the intel-gfx CI.
- Added a new patch that moves a call to drm_is_current_master out from the RCU critical section in drm_clients_info. This was reported by the intel-gfx CI.

v6 -> v7:
- Modify code alignment as suggested by the intel-gfx CI.
- Add a new patch to the series that adds a new lock to serialize drm_file.master, in response to the lockdep splat by the intel-gfx CI.
- Update drm_file_get_master to use the new drm_file.master_lock instead of drm_device.master_mutex, in response to the lockdep splat by the intel-gfx CI.

v5 -> v6:
- Add a new patch to the series that moves the call to _drm_lease_held out from the section locked by &dev->mode_config.idr_mutex in __drm_mode_object_find.
- Clarify the kerneldoc for dereferencing drm_file.master, as suggested by Daniel Vetter.
- Refactor error paths with goto labels so that each function only has a single drm_master_put(), as suggested by Emil Velikov.
- Modify comparisons to NULL into "!master", as suggested by the intel-gfx CI.

v4 -> v5:
- Add a new patch to the series that moves the call to drm_is_current_master in drm_mode_getconnector out from the section locked by &dev->mode_config.mutex.
- Additionally, added a missing semicolon to the patch, caught by the intel-gfx CI.

v3 -> v4:
- Move the call to drm_is_current_master in drm_mode_getconnector out from the section locked by &dev->mode_config.mutex. As suggested by Daniel Vetter. This avoids a circular lock lock dependency as reported here https://patchwork.freedesktop.org/patch/440406/
- Inside drm_is_current_master, instead of grabbing &fpriv->master->dev->master_mutex, we grab &fpriv->minor->dev->master_mutex to avoid dereferencing a null ptr if fpriv->master is not set.
- Modify kerneldoc formatting for drm_file.master, as suggested by Daniel Vetter.
- Additionally, add a file_priv->master NULL check inside drm_file_get_master, and handle the NULL result accordingly in drm_lease.c. As suggested by Daniel Vetter.

v2 -> v3:
- Move the definition of drm_is_current_master and the _locked version higher up in drm_auth.c to avoid needing a forward declaration of drm_is_current_master_locked. As suggested by Daniel Vetter.
- Instead of leaking drm_device.master_mutex into drm_lease.c to protect drm_master pointers, add a new drm_file_get_master() function that returns drm_file->master while increasing its reference count, to prevent drm_file->master from being freed. As suggested by Daniel Vetter.

Quoted 9 lines
Quoted 2 lines

v1 -> v2:
- Move the lock and assignment before the DRM_DEBUG_LEASE in drm_mode_get_lease_ioctl, as suggested by Emil Velikov.

Apologies for the delay, I missed your series. Maybe just ping next time around there's silence.

Looks all great, merged to drm-misc-next. Given how complex this was I'm vary of just pushing this to -fixes without some solid testing.

Hi Daniel,

Thanks for merging, more testing definitely sounds good to me.

Quoted 3 lines

One thing I noticed is that drm_is_current_master could just use the spinlock, since it's only doing a read access. Care to type up that patch?

Quoted 6 lines

I thought about this too, but I'm not sure if that's the best solution.

drm_is_current_master calls drm_lease_owner which then walks up the tree of master lessors. The spinlock protects the master of the current drm file, but subsequent lessors aren't protected without holding the device's master mutex.

But this isn't a fpriv->master pointer, but a master->lessor pointer. Which should never ever be able to change (we'd have tons of uaf bugs around drm_lease_owner otherwise). So I don't think there's anything that dev->master_lock protects here that fpriv->master_lookup_lock doesn't protect already?

Quoted 5 lines

Or am I missing something?

Quoted 1 line

The comment in the struct drm_master says it's protected by

mode_config.idr_mutex, but that only applies to the idrs and lists I think.

Quoted 3 lines

Ah you're right, I also completely forgot that lessees hold a reference to their lessor so nothing will be freed as long as the spinlock is held. I'll prepare that patch then, thanks for pointing it out.

btw since we now looked at all this in detail, can you perhaps do a patch to update the kerneldoc for all the lease fields in struct drm_master? I think moving them to the inline style and then adding comments for each field how locking/lifetime rules work would be really good. Since right now it's all fresh from for us. -Daniel

Quoted 41 lines
Quoted 40 lines
Quoted 8 lines
Quoted 5 lines

Also, do you plan to look into that idea we've discussed to flush pending access when we revoke a master or a lease? I think that would be really nice improvement here.
-Daniel

Yup, now that the potential UAFs are addressed (hopefully), I'll take a closer look and propose a patch for this.

Thanks a lot.
-Daniel

Quoted 26 lines

Best wishes,
Desmond

Quoted 21 lines
Quoted 20 lines

Desmond Cheong Zhi Xi (5):
drm: avoid circular locks in drm_mode_getconnector
drm: avoid blocking in drm_clients_info's rcu section
drm: add a locked version of drm_is_current_master
drm: serialize drm_file.master with a new spinlock
drm: protect drm_master pointers in drm_lease.c

   drivers/gpu/drm/drm_auth.c      | 93 ++++++++++++++++++++++++---------
   drivers/gpu/drm/drm_connector.c |  5 +-
   drivers/gpu/drm/drm_debugfs.c   |  3 +-
   drivers/gpu/drm/drm_file.c      |  1 +
   drivers/gpu/drm/drm_lease.c     | 81 +++++++++++++++++++++-------
   include/drm/drm_auth.h          |  1 +
   include/drm/drm_file.h          | 18 +++++--
   7 files changed, 152 insertions(+), 50 deletions(-)

--
2.25.1

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#13 lore raw
Quoted 96 lines · Daniel Vetter
Quoted 90 lines · Desmond Cheong Zhi Xi
Quoted 83 lines · Daniel Vetter
Quoted 68 lines · Desmond Cheong Zhi Xi
Quoted 49 lines · Daniel Vetter
Quoted 48 lines · Desmond Cheong Zhi Xi

Hi,

In the previous thread on this series we decided to remove a patch that was violating a lockdep requirement in drm_lease. In addition to this change, I took a closer look at the CI logs for the Basic Acceptance Tests and noticed that another regression was introduced. The new patch 2 is a response to this.

Overall, this series addresses potential use-after-free errors when dereferencing pointers to struct drm_master. These were identified after one such bug was caught by Syzbot in drm_getunique():
https://syzkaller.appspot.com/bug?id=148d2f1dfac64af52ffd27b661981a540724f803

The series is broken up into five patches:

1. Move a call to drm_is_current_master() out from a section locked by &dev->mode_config.mutex in drm_mode_getconnector(). This patch does not apply to stable.

2. Move a call to drm_is_current_master() out from the RCU read-side critical section in drm_clients_info().

3. Implement a locked version of drm_is_current_master() function that's used within drm_auth.c.

4. Serialize drm_file.master by introducing a new spinlock that's held whenever the value of drm_file.master changes.

5. Identify areas in drm_lease.c where pointers to struct drm_master are dereferenced, and ensure that the master pointers are not freed during use.

v7 -> v8:
- Remove the patch that moves the call to _drm_lease_held out from the section locked by &dev->mode_config.idr_mutex in __drm_mode_object_find. This patch violated an existing lockdep requirement as reported by the intel-gfx CI.
- Added a new patch that moves a call to drm_is_current_master out from the RCU critical section in drm_clients_info. This was reported by the intel-gfx CI.

v6 -> v7:
- Modify code alignment as suggested by the intel-gfx CI.
- Add a new patch to the series that adds a new lock to serialize drm_file.master, in response to the lockdep splat by the intel-gfx CI.
- Update drm_file_get_master to use the new drm_file.master_lock instead of drm_device.master_mutex, in response to the lockdep splat by the intel-gfx CI.

v5 -> v6:
- Add a new patch to the series that moves the call to _drm_lease_held out from the section locked by &dev->mode_config.idr_mutex in __drm_mode_object_find.
- Clarify the kerneldoc for dereferencing drm_file.master, as suggested by Daniel Vetter.
- Refactor error paths with goto labels so that each function only has a single drm_master_put(), as suggested by Emil Velikov.
- Modify comparisons to NULL into "!master", as suggested by the intel-gfx CI.

v4 -> v5:
- Add a new patch to the series that moves the call to drm_is_current_master in drm_mode_getconnector out from the section locked by &dev->mode_config.mutex.
- Additionally, added a missing semicolon to the patch, caught by the intel-gfx CI.

v3 -> v4:
- Move the call to drm_is_current_master in drm_mode_getconnector out from the section locked by &dev->mode_config.mutex. As suggested by Daniel Vetter. This avoids a circular lock lock dependency as reported here https://patchwork.freedesktop.org/patch/440406/
- Inside drm_is_current_master, instead of grabbing &fpriv->master->dev->master_mutex, we grab &fpriv->minor->dev->master_mutex to avoid dereferencing a null ptr if fpriv->master is not set.
- Modify kerneldoc formatting for drm_file.master, as suggested by Daniel Vetter.
- Additionally, add a file_priv->master NULL check inside drm_file_get_master, and handle the NULL result accordingly in drm_lease.c. As suggested by Daniel Vetter.

v2 -> v3:
- Move the definition of drm_is_current_master and the _locked version higher up in drm_auth.c to avoid needing a forward declaration of drm_is_current_master_locked. As suggested by Daniel Vetter.
- Instead of leaking drm_device.master_mutex into drm_lease.c to protect drm_master pointers, add a new drm_file_get_master() function that returns drm_file->master while increasing its reference count, to prevent drm_file->master from being freed. As suggested by Daniel Vetter.

Quoted 9 lines
Quoted 2 lines

v1 -> v2:
- Move the lock and assignment before the DRM_DEBUG_LEASE in drm_mode_get_lease_ioctl, as suggested by Emil Velikov.

Apologies for the delay, I missed your series. Maybe just ping next time around there's silence.

Looks all great, merged to drm-misc-next. Given how complex this was I'm vary of just pushing this to -fixes without some solid testing.

Hi Daniel,

Thanks for merging, more testing definitely sounds good to me.

Quoted 3 lines

One thing I noticed is that drm_is_current_master could just use the spinlock, since it's only doing a read access. Care to type up that patch?

Quoted 6 lines

I thought about this too, but I'm not sure if that's the best solution.

drm_is_current_master calls drm_lease_owner which then walks up the tree of master lessors. The spinlock protects the master of the current drm file, but subsequent lessors aren't protected without holding the device's master mutex.

But this isn't a fpriv->master pointer, but a master->lessor pointer. Which should never ever be able to change (we'd have tons of uaf bugs around drm_lease_owner otherwise). So I don't think there's anything that dev->master_lock protects here that fpriv->master_lookup_lock doesn't protect already?

Quoted 5 lines

Or am I missing something?

Quoted 1 line

The comment in the struct drm_master says it's protected by

mode_config.idr_mutex, but that only applies to the idrs and lists I think.

Quoted 3 lines

Ah you're right, I also completely forgot that lessees hold a reference to their lessor so nothing will be freed as long as the spinlock is held. I'll prepare that patch then, thanks for pointing it out.

Quoted 7 lines

btw since we now looked at all this in detail, can you perhaps do a patch to update the kerneldoc for all the lease fields in struct drm_master? I think moving them to the inline style and then adding comments for each field how locking/lifetime rules work would be really good. Since right now it's all fresh from for us. -Daniel

Sure thing. Just sent out the suggested changes in the same series, along with a relevant fix for drm/vmwgfx that I just noticed.

Quoted 43 lines
Quoted 41 lines
Quoted 40 lines
Quoted 8 lines
Quoted 5 lines

Also, do you plan to look into that idea we've discussed to flush pending access when we revoke a master or a lease? I think that would be really nice improvement here.
-Daniel

Yup, now that the potential UAFs are addressed (hopefully), I'll take a closer look and propose a patch for this.

Thanks a lot.
-Daniel

Quoted 26 lines

Best wishes,
Desmond

Quoted 21 lines
Quoted 20 lines

Desmond Cheong Zhi Xi (5):
drm: avoid circular locks in drm_mode_getconnector
drm: avoid blocking in drm_clients_info's rcu section
drm: add a locked version of drm_is_current_master
drm: serialize drm_file.master with a new spinlock
drm: protect drm_master pointers in drm_lease.c

drivers/gpu/drm/drm_auth.c | 93 ++++++++++++++++++++++++---------
drivers/gpu/drm/drm_connector.c | 5 +-
drivers/gpu/drm/drm_debugfs.c | 3 +-
drivers/gpu/drm/drm_file.c | 1 +
drivers/gpu/drm/drm_lease.c | 81 +++++++++++++++++++++-------
include/drm/drm_auth.h | 1 +
include/drm/drm_file.h | 18 +++++--
7 files changed, 152 insertions(+), 50 deletions(-)

--
2.25.1