drm/i915: Avoid post-put frontbuffer object access [FreeBSD] - #495
Draft
JustAnotherHumanBeing wants to merge 1 commit into
Draft
drm/i915: Avoid post-put frontbuffer object access [FreeBSD]#495JustAnotherHumanBeing wants to merge 1 commit into
JustAnotherHumanBeing wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
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 infrontbuffer_release(). The old code then dereferencedobjagain to findi915->display.fb_tracking.lock.A captured panic showed
drm_gem_object_free()followed by an unlock through a poisoned0xdeadc0de...pointer inintel_frontbuffer_put(), reached fromDRM_IOCTL_MODE_CLOSEFB.Caching
i915whileobjis 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
i915kms.kofrom official master withmake -C i915 -j12 DEBUG_FLAGS=-g SYSDIR=/usr/src/sysand-Werrordrm_gem_object_free()