@@ -23,7 +23,7 @@ static DEFINE_PER_CPU(unsigned long[MAX_STACK_ENTRIES], klp_stack_entries);
23
23
24
24
struct klp_patch * klp_transition_patch ;
25
25
26
- static int klp_target_state = KLP_UNDEFINED ;
26
+ static int klp_target_state = KLP_TRANSITION_IDLE ;
27
27
28
28
static unsigned int klp_signals_cnt ;
29
29
@@ -96,16 +96,16 @@ static void klp_complete_transition(void)
96
96
97
97
pr_debug ("'%s': completing %s transition\n" ,
98
98
klp_transition_patch -> mod -> name ,
99
- klp_target_state == KLP_PATCHED ? "patching" : "unpatching" );
99
+ klp_target_state == KLP_TRANSITION_PATCHED ? "patching" : "unpatching" );
100
100
101
- if (klp_transition_patch -> replace && klp_target_state == KLP_PATCHED ) {
101
+ if (klp_transition_patch -> replace && klp_target_state == KLP_TRANSITION_PATCHED ) {
102
102
klp_unpatch_replaced_patches (klp_transition_patch );
103
103
klp_discard_nops (klp_transition_patch );
104
104
}
105
105
106
- if (klp_target_state == KLP_UNPATCHED ) {
106
+ if (klp_target_state == KLP_TRANSITION_UNPATCHED ) {
107
107
/*
108
- * All tasks have transitioned to KLP_UNPATCHED so we can now
108
+ * All tasks have transitioned to KLP_TRANSITION_UNPATCHED so we can now
109
109
* remove the new functions from the func_stack.
110
110
*/
111
111
klp_unpatch_objects (klp_transition_patch );
@@ -123,36 +123,36 @@ static void klp_complete_transition(void)
123
123
klp_for_each_func (obj , func )
124
124
func -> transition = false;
125
125
126
- /* Prevent klp_ftrace_handler() from seeing KLP_UNDEFINED state */
127
- if (klp_target_state == KLP_PATCHED )
126
+ /* Prevent klp_ftrace_handler() from seeing KLP_TRANSITION_IDLE state */
127
+ if (klp_target_state == KLP_TRANSITION_PATCHED )
128
128
klp_synchronize_transition ();
129
129
130
130
read_lock (& tasklist_lock );
131
131
for_each_process_thread (g , task ) {
132
132
WARN_ON_ONCE (test_tsk_thread_flag (task , TIF_PATCH_PENDING ));
133
- task -> patch_state = KLP_UNDEFINED ;
133
+ task -> patch_state = KLP_TRANSITION_IDLE ;
134
134
}
135
135
read_unlock (& tasklist_lock );
136
136
137
137
for_each_possible_cpu (cpu ) {
138
138
task = idle_task (cpu );
139
139
WARN_ON_ONCE (test_tsk_thread_flag (task , TIF_PATCH_PENDING ));
140
- task -> patch_state = KLP_UNDEFINED ;
140
+ task -> patch_state = KLP_TRANSITION_IDLE ;
141
141
}
142
142
143
143
klp_for_each_object (klp_transition_patch , obj ) {
144
144
if (!klp_is_object_loaded (obj ))
145
145
continue ;
146
- if (klp_target_state == KLP_PATCHED )
146
+ if (klp_target_state == KLP_TRANSITION_PATCHED )
147
147
klp_post_patch_callback (obj );
148
- else if (klp_target_state == KLP_UNPATCHED )
148
+ else if (klp_target_state == KLP_TRANSITION_UNPATCHED )
149
149
klp_post_unpatch_callback (obj );
150
150
}
151
151
152
152
pr_notice ("'%s': %s complete\n" , klp_transition_patch -> mod -> name ,
153
- klp_target_state == KLP_PATCHED ? "patching" : "unpatching" );
153
+ klp_target_state == KLP_TRANSITION_PATCHED ? "patching" : "unpatching" );
154
154
155
- klp_target_state = KLP_UNDEFINED ;
155
+ klp_target_state = KLP_TRANSITION_IDLE ;
156
156
klp_transition_patch = NULL ;
157
157
}
158
158
@@ -164,13 +164,13 @@ static void klp_complete_transition(void)
164
164
*/
165
165
void klp_cancel_transition (void )
166
166
{
167
- if (WARN_ON_ONCE (klp_target_state != KLP_PATCHED ))
167
+ if (WARN_ON_ONCE (klp_target_state != KLP_TRANSITION_PATCHED ))
168
168
return ;
169
169
170
170
pr_debug ("'%s': canceling patching transition, going to unpatch\n" ,
171
171
klp_transition_patch -> mod -> name );
172
172
173
- klp_target_state = KLP_UNPATCHED ;
173
+ klp_target_state = KLP_TRANSITION_UNPATCHED ;
174
174
klp_complete_transition ();
175
175
}
176
176
@@ -218,7 +218,7 @@ static int klp_check_stack_func(struct klp_func *func, unsigned long *entries,
218
218
struct klp_ops * ops ;
219
219
int i ;
220
220
221
- if (klp_target_state == KLP_UNPATCHED ) {
221
+ if (klp_target_state == KLP_TRANSITION_UNPATCHED ) {
222
222
/*
223
223
* Check for the to-be-unpatched function
224
224
* (the func itself).
@@ -455,7 +455,7 @@ void klp_try_complete_transition(void)
455
455
struct klp_patch * patch ;
456
456
bool complete = true;
457
457
458
- WARN_ON_ONCE (klp_target_state == KLP_UNDEFINED );
458
+ WARN_ON_ONCE (klp_target_state == KLP_TRANSITION_IDLE );
459
459
460
460
/*
461
461
* Try to switch the tasks to the target patch state by walking their
@@ -532,11 +532,11 @@ void klp_start_transition(void)
532
532
struct task_struct * g , * task ;
533
533
unsigned int cpu ;
534
534
535
- WARN_ON_ONCE (klp_target_state == KLP_UNDEFINED );
535
+ WARN_ON_ONCE (klp_target_state == KLP_TRANSITION_IDLE );
536
536
537
537
pr_notice ("'%s': starting %s transition\n" ,
538
538
klp_transition_patch -> mod -> name ,
539
- klp_target_state == KLP_PATCHED ? "patching" : "unpatching" );
539
+ klp_target_state == KLP_TRANSITION_PATCHED ? "patching" : "unpatching" );
540
540
541
541
/*
542
542
* Mark all normal tasks as needing a patch state update. They'll
@@ -578,7 +578,7 @@ void klp_init_transition(struct klp_patch *patch, int state)
578
578
struct klp_func * func ;
579
579
int initial_state = !state ;
580
580
581
- WARN_ON_ONCE (klp_target_state != KLP_UNDEFINED );
581
+ WARN_ON_ONCE (klp_target_state != KLP_TRANSITION_IDLE );
582
582
583
583
klp_transition_patch = patch ;
584
584
@@ -589,15 +589,15 @@ void klp_init_transition(struct klp_patch *patch, int state)
589
589
klp_target_state = state ;
590
590
591
591
pr_debug ("'%s': initializing %s transition\n" , patch -> mod -> name ,
592
- klp_target_state == KLP_PATCHED ? "patching" : "unpatching" );
592
+ klp_target_state == KLP_TRANSITION_PATCHED ? "patching" : "unpatching" );
593
593
594
594
/*
595
595
* Initialize all tasks to the initial patch state to prepare them for
596
596
* switching to the target state.
597
597
*/
598
598
read_lock (& tasklist_lock );
599
599
for_each_process_thread (g , task ) {
600
- WARN_ON_ONCE (task -> patch_state != KLP_UNDEFINED );
600
+ WARN_ON_ONCE (task -> patch_state != KLP_TRANSITION_IDLE );
601
601
task -> patch_state = initial_state ;
602
602
}
603
603
read_unlock (& tasklist_lock );
@@ -607,19 +607,19 @@ void klp_init_transition(struct klp_patch *patch, int state)
607
607
*/
608
608
for_each_possible_cpu (cpu ) {
609
609
task = idle_task (cpu );
610
- WARN_ON_ONCE (task -> patch_state != KLP_UNDEFINED );
610
+ WARN_ON_ONCE (task -> patch_state != KLP_TRANSITION_IDLE );
611
611
task -> patch_state = initial_state ;
612
612
}
613
613
614
614
/*
615
615
* Enforce the order of the task->patch_state initializations and the
616
616
* func->transition updates to ensure that klp_ftrace_handler() doesn't
617
- * see a func in transition with a task->patch_state of KLP_UNDEFINED .
617
+ * see a func in transition with a task->patch_state of KLP_TRANSITION_IDLE .
618
618
*
619
619
* Also enforce the order of the klp_target_state write and future
620
620
* TIF_PATCH_PENDING writes to ensure klp_update_patch_state() and
621
621
* __klp_sched_try_switch() don't set a task->patch_state to
622
- * KLP_UNDEFINED .
622
+ * KLP_TRANSITION_IDLE .
623
623
*/
624
624
smp_wmb ();
625
625
@@ -652,7 +652,7 @@ void klp_reverse_transition(void)
652
652
653
653
pr_debug ("'%s': reversing transition from %s\n" ,
654
654
klp_transition_patch -> mod -> name ,
655
- klp_target_state == KLP_PATCHED ? "patching to unpatching" :
655
+ klp_target_state == KLP_TRANSITION_PATCHED ? "patching to unpatching" :
656
656
"unpatching to patching" );
657
657
658
658
/*
@@ -741,7 +741,7 @@ void klp_force_transition(void)
741
741
klp_update_patch_state (idle_task (cpu ));
742
742
743
743
/* Set forced flag for patches being removed. */
744
- if (klp_target_state == KLP_UNPATCHED )
744
+ if (klp_target_state == KLP_TRANSITION_UNPATCHED )
745
745
klp_transition_patch -> forced = true;
746
746
else if (klp_transition_patch -> replace ) {
747
747
klp_for_each_patch (patch ) {
0 commit comments