diff options
Diffstat (limited to 'kernel/livepatch/transition.c')
-rw-r--r-- | kernel/livepatch/transition.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/kernel/livepatch/transition.c b/kernel/livepatch/transition.c index 9c89ae8b337a..c53370d596be 100644 --- a/kernel/livepatch/transition.c +++ b/kernel/livepatch/transition.c | |||
@@ -202,15 +202,15 @@ void klp_update_patch_state(struct task_struct *task) | |||
202 | * Determine whether the given stack trace includes any references to a | 202 | * Determine whether the given stack trace includes any references to a |
203 | * to-be-patched or to-be-unpatched function. | 203 | * to-be-patched or to-be-unpatched function. |
204 | */ | 204 | */ |
205 | static int klp_check_stack_func(struct klp_func *func, | 205 | static int klp_check_stack_func(struct klp_func *func, unsigned long *entries, |
206 | struct stack_trace *trace) | 206 | unsigned int nr_entries) |
207 | { | 207 | { |
208 | unsigned long func_addr, func_size, address; | 208 | unsigned long func_addr, func_size, address; |
209 | struct klp_ops *ops; | 209 | struct klp_ops *ops; |
210 | int i; | 210 | int i; |
211 | 211 | ||
212 | for (i = 0; i < trace->nr_entries; i++) { | 212 | for (i = 0; i < nr_entries; i++) { |
213 | address = trace->entries[i]; | 213 | address = entries[i]; |
214 | 214 | ||
215 | if (klp_target_state == KLP_UNPATCHED) { | 215 | if (klp_target_state == KLP_UNPATCHED) { |
216 | /* | 216 | /* |
@@ -254,29 +254,25 @@ static int klp_check_stack_func(struct klp_func *func, | |||
254 | static int klp_check_stack(struct task_struct *task, char *err_buf) | 254 | static int klp_check_stack(struct task_struct *task, char *err_buf) |
255 | { | 255 | { |
256 | static unsigned long entries[MAX_STACK_ENTRIES]; | 256 | static unsigned long entries[MAX_STACK_ENTRIES]; |
257 | struct stack_trace trace; | ||
258 | struct klp_object *obj; | 257 | struct klp_object *obj; |
259 | struct klp_func *func; | 258 | struct klp_func *func; |
260 | int ret; | 259 | int ret, nr_entries; |
261 | 260 | ||
262 | trace.skip = 0; | 261 | ret = stack_trace_save_tsk_reliable(task, entries, ARRAY_SIZE(entries)); |
263 | trace.nr_entries = 0; | ||
264 | trace.max_entries = MAX_STACK_ENTRIES; | ||
265 | trace.entries = entries; | ||
266 | ret = save_stack_trace_tsk_reliable(task, &trace); | ||
267 | WARN_ON_ONCE(ret == -ENOSYS); | 262 | WARN_ON_ONCE(ret == -ENOSYS); |
268 | if (ret) { | 263 | if (ret < 0) { |
269 | snprintf(err_buf, STACK_ERR_BUF_SIZE, | 264 | snprintf(err_buf, STACK_ERR_BUF_SIZE, |
270 | "%s: %s:%d has an unreliable stack\n", | 265 | "%s: %s:%d has an unreliable stack\n", |
271 | __func__, task->comm, task->pid); | 266 | __func__, task->comm, task->pid); |
272 | return ret; | 267 | return ret; |
273 | } | 268 | } |
269 | nr_entries = ret; | ||
274 | 270 | ||
275 | klp_for_each_object(klp_transition_patch, obj) { | 271 | klp_for_each_object(klp_transition_patch, obj) { |
276 | if (!obj->patched) | 272 | if (!obj->patched) |
277 | continue; | 273 | continue; |
278 | klp_for_each_func(obj, func) { | 274 | klp_for_each_func(obj, func) { |
279 | ret = klp_check_stack_func(func, &trace); | 275 | ret = klp_check_stack_func(func, entries, nr_entries); |
280 | if (ret) { | 276 | if (ret) { |
281 | snprintf(err_buf, STACK_ERR_BUF_SIZE, | 277 | snprintf(err_buf, STACK_ERR_BUF_SIZE, |
282 | "%s: %s:%d is sleeping on function %s\n", | 278 | "%s: %s:%d is sleeping on function %s\n", |