Skip to content

drm/i915: Avoid post-put frontbuffer object access [FreeBSD] - #495

Draft
JustAnotherHumanBeing wants to merge 1 commit into
freebsd:masterfrom
JustAnotherHumanBeing:agent/fix-i915-frontbuffer-uaf
Draft

drm/i915: Avoid post-put frontbuffer object access [FreeBSD]#495
JustAnotherHumanBeing wants to merge 1 commit into
freebsd:masterfrom
JustAnotherHumanBeing:agent/fix-i915-frontbuffer-uaf

Conversation

@JustAnotherHumanBeing

Copy link
Copy Markdown

Summary

  • cache the i915 device pointer before clearing the object's frontbuffer
  • avoid deriving the warning target and fb-tracking lock from a GEM object after its final reference may have been dropped

Root cause

i915_gem_object_set_frontbuffer(obj, NULL) can release the final GEM object reference. On FreeBSD, object reclamation may run before the following statements in frontbuffer_release(). The old code then dereferenced obj again to find i915->display.fb_tracking.lock.

A captured panic showed drm_gem_object_free() followed by an unlock through a poisoned 0xdeadc0de... pointer in intel_frontbuffer_put(), reached from DRM_IOCTL_MODE_CLOSEFB.

Caching i915 while obj is still referenced preserves the existing lock and reference ordering while removing the post-put dereference.

PR #469's Linux 6.13 conversion also avoids this sequence as a side effect. This PR is a minimal fix for the current 6.12-based master and does not depend on the full version update.

Testing

  • built i915kms.ko from official master with make -C i915 -j12 DEBUG_FLAGS=-g SYSDIR=/usr/src/sys and -Werror
  • verified the generated code retains the cached device pointer across drm_gem_object_free()
  • booted the corrected module and ran Plasma/KWin through the startup path that previously panicked, with no recurrence

i915_gem_object_set_frontbuffer(obj, NULL) can drop the final GEM object reference. On FreeBSD, the object may be reclaimed before frontbuffer_release() derives the device and fb_tracking lock from obj for the warning and unlock operations.

Cache the i915 pointer while the object is still referenced and use it after the put. This preserves the existing lock and reference ordering while removing the post-put object dereference.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant