lkml.org 
[lkml]   [2017]   [Oct]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2] stackdepot: ignore junk last entry in case of switch from user mode.
Date
Issue observed on ARM.

Whenever there is switch from user mode, we end up with invalid last entry
with some user space address as below:-

save_stack+0x40/0xec
__set_page_owner+0x2c/0x64
....
....
__handle_domain_irq+0x9c/0x130
gic_handle_irq+0x40/0x80
__irq_usr+0x4c/0x60
0xb6507818

So in this case last entry is not valid, which leads to allocated one more
new frame for stackdepot although having all above frames exactly same.

(It increases depot_index drastically)

So its better to ignore that last frame in case of switch.
save_stack+0x40/0xec
__set_page_owner+0x2c/0x64
....
....
__handle_domain_irq+0x9c/0x130
gic_handle_irq+0x40/0x80
__irq_usr+0x4c/0x60

Signed-off-by: Vaneet Narang <v.narang@samsung.com>
Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
---
v1 -> v2: use generic API to check whether address belongs to user space or not.

lib/stackdepot.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/lib/stackdepot.c b/lib/stackdepot.c
index f87d138..a045748 100644
--- a/lib/stackdepot.c
+++ b/lib/stackdepot.c
@@ -214,6 +214,13 @@ depot_stack_handle_t depot_save_stack(struct stack_trace *trace,
if (unlikely(trace->nr_entries == 0))
goto fast_exit;

+ /*
+ * Ignore last entry if it belongs to user space
+ * in case of switch from user mode.
+ */
+ if (!kernel_text_address(trace->entries[trace->nr_entries - 1]))
+ trace->nr_entries--;
+
hash = hash_stack(trace->entries, trace->nr_entries);
bucket = &stack_table[hash & STACK_HASH_MASK];

--
1.9.1
\
 
 \ /
  Last update: 2017-10-11 14:44    [W:0.108 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site