diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2019-04-25 05:45:18 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2019-04-29 06:37:56 -0400 |
commit | 25e39e32b0a3f99b9db320605f20f91d425b6a65 (patch) | |
tree | e9e0ee73fa7044b5d0249381911b64250d779ed7 | |
parent | 9f50c91b1195dfffd183d5d8505e45af86623532 (diff) |
livepatch: Simplify stack trace retrieval
Replace the indirection through struct stack_trace by using the storage
array based interfaces.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
Acked-by: Miroslav Benes <mbenes@suse.cz>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Alexander Potapenko <glider@google.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: linux-mm@kvack.org
Cc: David Rientjes <rientjes@google.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: kasan-dev@googlegroups.com
Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
Cc: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: iommu@lists.linux-foundation.org
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: David Sterba <dsterba@suse.com>
Cc: Chris Mason <clm@fb.com>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: linux-btrfs@vger.kernel.org
Cc: dm-devel@redhat.com
Cc: Mike Snitzer <snitzer@redhat.com>
Cc: Alasdair Kergon <agk@redhat.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: intel-gfx@lists.freedesktop.org
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: dri-devel@lists.freedesktop.org
Cc: David Airlie <airlied@linux.ie>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Tom Zanussi <tom.zanussi@linux.intel.com>
Cc: linux-arch@vger.kernel.org
Link: https://lkml.kernel.org/r/20190425094803.437950229@linutronix.de
-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", |