From: Maninder Singh <maninder1.s@samsung.com>
To: akpm@linux-foundation.org, dvyukov@google.com,
chris@chris-wilson.co.uk, kasan-dev@googlegroups.com,
mark.rutland@arm.com
Cc: linux-kernel@vger.kernel.org, pankaj.m@samsung.com,
a.sahrawat@samsung.com, Maninder Singh <maninder1.s@samsung.com>,
Vaneet Narang <v.narang@samsung.com>
Subject: [PATCH v2] stackdepot: ignore junk last entry in case of switch from user mode.
Date: Wed, 11 Oct 2017 18:13:22 +0530 [thread overview]
Message-ID: <1507725802-44574-1-git-send-email-maninder1.s@samsung.com> (raw)
In-Reply-To: <CGME20171011124443epcas5p23a0d74a4628baa3a1b424cb363fc5c81@epcas5p2.samsung.com>
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
next parent reply other threads:[~2017-10-11 12:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20171011124443epcas5p23a0d74a4628baa3a1b424cb363fc5c81@epcas5p2.samsung.com>
2017-10-11 12:43 ` Maninder Singh [this message]
[not found] ` <CGME20171011124443epcas5p23a0d74a4628baa3a1b424cb363fc5c81@epcms5p3>
2017-10-12 11:10 ` Vaneet Narang
2017-10-12 13:59 ` Dmitry Vyukov
2017-10-13 15:19 ` Andrey Ryabinin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1507725802-44574-1-git-send-email-maninder1.s@samsung.com \
--to=maninder1.s@samsung.com \
--cc=a.sahrawat@samsung.com \
--cc=akpm@linux-foundation.org \
--cc=chris@chris-wilson.co.uk \
--cc=dvyukov@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=pankaj.m@samsung.com \
--cc=v.narang@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®