Skip to content

Commit f9e62f3

Browse files
bebarinoKAGA-KOKO
authored andcommitted
treewide: Make all debug_obj_descriptors const
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
1 parent aedcade commit f9e62f3

8 files changed

Lines changed: 12 additions & 12 deletions

File tree

drivers/gpu/drm/i915/i915_active.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static void *active_debug_hint(void *addr)
8181
return (void *)ref->active ?: (void *)ref->retire ?: (void *)ref;
8282
}
8383

84-
static struct debug_obj_descr active_debug_desc = {
84+
static const struct debug_obj_descr active_debug_desc = {
8585
.name = "i915_active",
8686
.debug_hint = active_debug_hint,
8787
};

drivers/gpu/drm/i915/i915_sw_fence.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static void *i915_sw_fence_debug_hint(void *addr)
3434

3535
#ifdef CONFIG_DRM_I915_SW_FENCE_DEBUG_OBJECTS
3636

37-
static struct debug_obj_descr i915_sw_fence_debug_descr = {
37+
static const struct debug_obj_descr i915_sw_fence_debug_descr = {
3838
.name = "i915_sw_fence",
3939
.debug_hint = i915_sw_fence_debug_hint,
4040
};

kernel/rcu/rcu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ static inline unsigned long rcu_seq_diff(unsigned long new, unsigned long old)
167167
# define STATE_RCU_HEAD_READY 0
168168
# define STATE_RCU_HEAD_QUEUED 1
169169

170-
extern struct debug_obj_descr rcuhead_debug_descr;
170+
extern const struct debug_obj_descr rcuhead_debug_descr;
171171

172172
static inline int debug_rcu_head_queue(struct rcu_head *head)
173173
{

kernel/rcu/update.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ void destroy_rcu_head_on_stack(struct rcu_head *head)
469469
}
470470
EXPORT_SYMBOL_GPL(destroy_rcu_head_on_stack);
471471

472-
struct debug_obj_descr rcuhead_debug_descr = {
472+
const struct debug_obj_descr rcuhead_debug_descr = {
473473
.name = "rcu_head",
474474
.is_static_object = rcuhead_is_static_object,
475475
};

kernel/time/hrtimer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ EXPORT_SYMBOL_GPL(ktime_add_safe);
342342

343343
#ifdef CONFIG_DEBUG_OBJECTS_TIMERS
344344

345-
static struct debug_obj_descr hrtimer_debug_descr;
345+
static const struct debug_obj_descr hrtimer_debug_descr;
346346

347347
static void *hrtimer_debug_hint(void *addr)
348348
{
@@ -401,7 +401,7 @@ static bool hrtimer_fixup_free(void *addr, enum debug_obj_state state)
401401
}
402402
}
403403

404-
static struct debug_obj_descr hrtimer_debug_descr = {
404+
static const struct debug_obj_descr hrtimer_debug_descr = {
405405
.name = "hrtimer",
406406
.debug_hint = hrtimer_debug_hint,
407407
.fixup_init = hrtimer_fixup_init,

kernel/time/timer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ static void internal_add_timer(struct timer_base *base, struct timer_list *timer
611611

612612
#ifdef CONFIG_DEBUG_OBJECTS_TIMERS
613613

614-
static struct debug_obj_descr timer_debug_descr;
614+
static const struct debug_obj_descr timer_debug_descr;
615615

616616
static void *timer_debug_hint(void *addr)
617617
{
@@ -707,7 +707,7 @@ static bool timer_fixup_assert_init(void *addr, enum debug_obj_state state)
707707
}
708708
}
709709

710-
static struct debug_obj_descr timer_debug_descr = {
710+
static const struct debug_obj_descr timer_debug_descr = {
711711
.name = "timer_list",
712712
.debug_hint = timer_debug_hint,
713713
.is_static_object = timer_is_static_object,

kernel/workqueue.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ static void show_pwq(struct pool_workqueue *pwq);
427427

428428
#ifdef CONFIG_DEBUG_OBJECTS_WORK
429429

430-
static struct debug_obj_descr work_debug_descr;
430+
static const struct debug_obj_descr work_debug_descr;
431431

432432
static void *work_debug_hint(void *addr)
433433
{
@@ -477,7 +477,7 @@ static bool work_fixup_free(void *addr, enum debug_obj_state state)
477477
}
478478
}
479479

480-
static struct debug_obj_descr work_debug_descr = {
480+
static const struct debug_obj_descr work_debug_descr = {
481481
.name = "work_struct",
482482
.debug_hint = work_debug_hint,
483483
.is_static_object = work_is_static_object,

lib/percpu_counter.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ static DEFINE_SPINLOCK(percpu_counters_lock);
1717

1818
#ifdef CONFIG_DEBUG_OBJECTS_PERCPU_COUNTER
1919

20-
static struct debug_obj_descr percpu_counter_debug_descr;
20+
static const struct debug_obj_descr percpu_counter_debug_descr;
2121

2222
static bool percpu_counter_fixup_free(void *addr, enum debug_obj_state state)
2323
{
@@ -33,7 +33,7 @@ static bool percpu_counter_fixup_free(void *addr, enum debug_obj_state state)
3333
}
3434
}
3535

36-
static struct debug_obj_descr percpu_counter_debug_descr = {
36+
static const struct debug_obj_descr percpu_counter_debug_descr = {
3737
.name = "percpu_counter",
3838
.fixup_free = percpu_counter_fixup_free,
3939
};

0 commit comments

Comments
 (0)