Commit fde9f39
drm/amd/display: Clear dm_state for fast updates
This patch fixes a race condition that causes a use-after-free during
amdgpu_dm_atomic_commit_tail. This can occur when 2 non-blocking commits
are requested and the second one finishes before the first. Essentially,
this bug occurs when the following sequence of events happens:
1. Non-blocking commit gregkh#1 is requested w/ a new dm_state gregkh#1 and is
deferred to the workqueue.
2. Non-blocking commit gregkh#2 is requested w/ a new dm_state gregkh#2 and is
deferred to the workqueue.
3. Commit gregkh#2 starts before commit gregkh#1, dm_state gregkh#1 is used in the
commit_tail and commit gregkh#2 completes, freeing dm_state gregkh#1.
4. Commit gregkh#1 starts after commit gregkh#2 completes, uses the freed dm_state
1 and dereferences a freelist pointer while setting the context.
Since this bug has only been spotted with fast commits, this patch fixes
the bug by clearing the dm_state instead of using the old dc_state for
fast updates. In addition, since dm_state is only used for its dc_state
and amdgpu_dm_atomic_commit_tail will retain the dc_state if none is found,
removing the dm_state should not have any consequences in fast updates.
This use-after-free bug has existed for a while now, but only caused a
noticeable issue starting from 5.7-rc1 due to 3202fa6 ("slub: relocate
freelist pointer to middle of object") moving the freelist pointer from
dm_state->base (which was unused) to dm_state->context (which is
dereferenced).
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=207383
Fixes: bd200d1 ("drm/amd/display: Don't replace the dc_state for fast updates")
Reported-by: Duncan <[email protected]>
Signed-off-by: Mazin Rezk <[email protected]>
Reviewed-by: Nicholas Kazlauskas <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
Cc: [email protected]1 parent 543e866 commit fde9f39
1 file changed
+27
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8717 | 8717 | | |
8718 | 8718 | | |
8719 | 8719 | | |
| 8720 | + | |
| 8721 | + | |
| 8722 | + | |
| 8723 | + | |
| 8724 | + | |
8720 | 8725 | | |
8721 | | - | |
8722 | 8726 | | |
8723 | | - | |
8724 | | - | |
| 8727 | + | |
| 8728 | + | |
8725 | 8729 | | |
8726 | | - | |
8727 | | - | |
8728 | | - | |
| 8730 | + | |
| 8731 | + | |
8729 | 8732 | | |
8730 | | - | |
| 8733 | + | |
| 8734 | + | |
| 8735 | + | |
| 8736 | + | |
| 8737 | + | |
| 8738 | + | |
| 8739 | + | |
| 8740 | + | |
| 8741 | + | |
| 8742 | + | |
8731 | 8743 | | |
8732 | | - | |
8733 | | - | |
| 8744 | + | |
| 8745 | + | |
| 8746 | + | |
| 8747 | + | |
| 8748 | + | |
| 8749 | + | |
| 8750 | + | |
| 8751 | + | |
8734 | 8752 | | |
8735 | 8753 | | |
8736 | 8754 | | |
| |||
0 commit comments