Patch "drm/i915: Register engines early to avoid type confusion" has been added to the 6.5-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    drm/i915: Register engines early to avoid type confusion

to the 6.5-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     drm-i915-register-engines-early-to-avoid-type-confus.patch
and it can be found in the queue-6.5 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit defda39723058e18aea111f1c149d76e8f1dfba2
Author: Mathias Krause <minipli@xxxxxxxxxxxxxx>
Date:   Thu Sep 28 20:20:18 2023 +0200

    drm/i915: Register engines early to avoid type confusion
    
    [ Upstream commit 6007265ad70a87aa9b4eea79b5e5828da452cfd8 ]
    
    Commit 1ec23ed7126e ("drm/i915: Use uabi engines for the default engine
    map") switched from using for_each_engine() to for_each_uabi_engine() to
    iterate over the user engines. While this seems to be a sensible change,
    it's only safe to do when the engines are actually chained using the
    rb-tree structure which is not the case during early driver
    initialization where it can be either a lock-less list or regular
    double-linked list.
    
    In fact, the modesetting initialization code may end up calling
    default_engines() through the fb helper code while the engines list
    is still llist_node-based:
    
      i915_driver_probe() ->
        intel_display_driver_probe() ->
          intel_fbdev_init() ->
            drm_fb_helper_init() ->
              drm_client_init() ->
                drm_client_open() ->
                  drm_file_alloc() ->
                    i915_driver_open() ->
                      i915_gem_open() ->
                        i915_gem_context_open() ->
                          i915_gem_create_context() ->
                            default_engines()
    
    Using for_each_uabi_engine() in default_engines() is therefore wrong, as
    it would try to interpret the llist as rb-tree, making it find no engine
    at all, as the rb_left and rb_right members will still be NULL, as they
    haven't been initialized yet.
    
    To fix this type confusion register the engines earlier and at the same
    time reduce the amount of code that has to deal with the intermediate
    llist state.
    
    Reported-by: sanity checks in grsecurity
    Suggested-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx>
    Fixes: 1ec23ed7126e ("drm/i915: Use uabi engines for the default engine map")
    Signed-off-by: Mathias Krause <minipli@xxxxxxxxxxxxxx>
    Cc: Jonathan Cavitt <jonathan.cavitt@xxxxxxxxx>
    Cc: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx>
    Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx>
    Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230928182019.10256-2-minipli@xxxxxxxxxxxxxx
    [tursulin: fixed commit tag typo]
    (cherry picked from commit 2b562f032fc2594fb3fac22b7a2eb3c1969a7ba3)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 1f65bb33dd212..a8551ce322de2 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1199,6 +1199,13 @@ int i915_gem_init(struct drm_i915_private *dev_priv)
 			goto err_unlock;
 	}
 
+	/*
+	 * Register engines early to ensure the engine list is in its final
+	 * rb-tree form, lowering the amount of code that has to deal with
+	 * the intermediate llist state.
+	 */
+	intel_engines_driver_register(dev_priv);
+
 	return 0;
 
 	/*
@@ -1246,8 +1253,6 @@ int i915_gem_init(struct drm_i915_private *dev_priv)
 void i915_gem_driver_register(struct drm_i915_private *i915)
 {
 	i915_gem_driver_register__shrinker(i915);
-
-	intel_engines_driver_register(i915);
 }
 
 void i915_gem_driver_unregister(struct drm_i915_private *i915)



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux