treewide: Make all debug_obj_descriptors const
authorStephen Boyd <swboyd@chromium.org>
Sat, 15 Aug 2020 00:40:27 +0000 (17:40 -0700)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 24 Sep 2020 19:56:25 +0000 (21:56 +0200)
This should make it harder for the kernel to corrupt the debug object
descriptor, used to call functions to fixup state and track debug objects,
by moving the structure to read-only memory.

Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20200815004027.2046113-3-swboyd@chromium.org
drivers/gpu/drm/i915/i915_active.c
drivers/gpu/drm/i915/i915_sw_fence.c
kernel/rcu/rcu.h
kernel/rcu/update.c
kernel/time/hrtimer.c
kernel/time/timer.c
kernel/workqueue.c
lib/percpu_counter.c

index d960d0be5bd2fb62cae1261f35b51c8174cc76ef..839bd53df6e9cd810bed2e4e22f7dc6c898503d4 100644 (file)
@@ -81,7 +81,7 @@ static void *active_debug_hint(void *addr)
        return (void *)ref->active ?: (void *)ref->retire ?: (void *)ref;
 }
 
-static struct debug_obj_descr active_debug_desc = {
+static const struct debug_obj_descr active_debug_desc = {
        .name = "i915_active",
        .debug_hint = active_debug_hint,
 };
index 4cd2038cbe35990c0a2e1a4d790dded6ec8d69b3..038d4c6884c5b708dc102d1b09fa663a17cee701 100644 (file)
@@ -34,7 +34,7 @@ static void *i915_sw_fence_debug_hint(void *addr)
 
 #ifdef CONFIG_DRM_I915_SW_FENCE_DEBUG_OBJECTS
 
-static struct debug_obj_descr i915_sw_fence_debug_descr = {
+static const struct debug_obj_descr i915_sw_fence_debug_descr = {
        .name = "i915_sw_fence",
        .debug_hint = i915_sw_fence_debug_hint,
 };
index cf66a3ccd757326a20414f6c0cd59c4a8fb9a4d0..e01cba5e4b5290c5f59790cad95b1dbab4c3a060 100644 (file)
@@ -167,7 +167,7 @@ static inline unsigned long rcu_seq_diff(unsigned long new, unsigned long old)
 # define STATE_RCU_HEAD_READY  0
 # define STATE_RCU_HEAD_QUEUED 1
 
-extern struct debug_obj_descr rcuhead_debug_descr;
+extern const struct debug_obj_descr rcuhead_debug_descr;
 
 static inline int debug_rcu_head_queue(struct rcu_head *head)
 {
index 2de49b5d8dd292018429ebf3af265ef0a3a1d00c..3e0f4bcb558fd7be7c967177b217aa2a3f147c00 100644 (file)
@@ -469,7 +469,7 @@ void destroy_rcu_head_on_stack(struct rcu_head *head)
 }
 EXPORT_SYMBOL_GPL(destroy_rcu_head_on_stack);
 
-struct debug_obj_descr rcuhead_debug_descr = {
+const struct debug_obj_descr rcuhead_debug_descr = {
        .name = "rcu_head",
        .is_static_object = rcuhead_is_static_object,
 };
index 95b6a708b0406b717c130b511d964ebcddc09a2e..3624b9b5835de548df2eafd78f986447e798e0fb 100644 (file)
@@ -342,7 +342,7 @@ EXPORT_SYMBOL_GPL(ktime_add_safe);
 
 #ifdef CONFIG_DEBUG_OBJECTS_TIMERS
 
-static struct debug_obj_descr hrtimer_debug_descr;
+static const struct debug_obj_descr hrtimer_debug_descr;
 
 static void *hrtimer_debug_hint(void *addr)
 {
@@ -401,7 +401,7 @@ static bool hrtimer_fixup_free(void *addr, enum debug_obj_state state)
        }
 }
 
-static struct debug_obj_descr hrtimer_debug_descr = {
+static const struct debug_obj_descr hrtimer_debug_descr = {
        .name           = "hrtimer",
        .debug_hint     = hrtimer_debug_hint,
        .fixup_init     = hrtimer_fixup_init,
index a50364df10543912c0bfc9f6f40d4c0470de5cc5..8b17cf28e54b108a9dbbdf5814eba9633a06561b 100644 (file)
@@ -611,7 +611,7 @@ static void internal_add_timer(struct timer_base *base, struct timer_list *timer
 
 #ifdef CONFIG_DEBUG_OBJECTS_TIMERS
 
-static struct debug_obj_descr timer_debug_descr;
+static const struct debug_obj_descr timer_debug_descr;
 
 static void *timer_debug_hint(void *addr)
 {
@@ -707,7 +707,7 @@ static bool timer_fixup_assert_init(void *addr, enum debug_obj_state state)
        }
 }
 
-static struct debug_obj_descr timer_debug_descr = {
+static const struct debug_obj_descr timer_debug_descr = {
        .name                   = "timer_list",
        .debug_hint             = timer_debug_hint,
        .is_static_object       = timer_is_static_object,
index c41c3c17b86a3ea1703e12d3412cf417eacd4555..ac088ce6059bc2dadc148d76deb934eaa3ccf785 100644 (file)
@@ -427,7 +427,7 @@ static void show_pwq(struct pool_workqueue *pwq);
 
 #ifdef CONFIG_DEBUG_OBJECTS_WORK
 
-static struct debug_obj_descr work_debug_descr;
+static const struct debug_obj_descr work_debug_descr;
 
 static void *work_debug_hint(void *addr)
 {
@@ -477,7 +477,7 @@ static bool work_fixup_free(void *addr, enum debug_obj_state state)
        }
 }
 
-static struct debug_obj_descr work_debug_descr = {
+static const struct debug_obj_descr work_debug_descr = {
        .name           = "work_struct",
        .debug_hint     = work_debug_hint,
        .is_static_object = work_is_static_object,
index a2345de90e937bad64e00bf62a224f9f3e6732b4..f61689a96e85e74bca32cb39665d0e3553def495 100644 (file)
@@ -17,7 +17,7 @@ static DEFINE_SPINLOCK(percpu_counters_lock);
 
 #ifdef CONFIG_DEBUG_OBJECTS_PERCPU_COUNTER
 
-static struct debug_obj_descr percpu_counter_debug_descr;
+static const struct debug_obj_descr percpu_counter_debug_descr;
 
 static bool percpu_counter_fixup_free(void *addr, enum debug_obj_state state)
 {
@@ -33,7 +33,7 @@ static bool percpu_counter_fixup_free(void *addr, enum debug_obj_state state)
        }
 }
 
-static struct debug_obj_descr percpu_counter_debug_descr = {
+static const struct debug_obj_descr percpu_counter_debug_descr = {
        .name           = "percpu_counter",
        .fixup_free     = percpu_counter_fixup_free,
 };