From: Kris Van Hees Date: Wed, 24 May 2017 03:34:53 +0000 (-0400) Subject: dtrace: ensure limit is enforced even when pcs is NULL X-Git-Tag: v4.1.12-102.0.20170529_2200~57^2~12 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=984f2b7ff4e5bf92c285cdb75075942d73d5d52b;p=users%2Fjedix%2Flinux-maple.git dtrace: ensure limit is enforced even when pcs is NULL The dtrace_user_stacktrace() functions for x86_64 and sparc64 were not handling the specified limit (st->limit correctly if the buffer for PC values (st->pcs) was NULL. This commit ensures that we decrement the limit whenever we encounter a PC, whether it gets stored or not. Orabug: 25949692 Signed-off-by: Kris Van Hees Acked-by: Nick Alcock --- diff --git a/arch/sparc/kernel/dtrace_util.c b/arch/sparc/kernel/dtrace_util.c index 9e6629068225c..47e19175cd7b7 100644 --- a/arch/sparc/kernel/dtrace_util.c +++ b/arch/sparc/kernel/dtrace_util.c @@ -141,10 +141,9 @@ void dtrace_user_stacktrace(stacktrace_state_t *st) flush_user_windows(); st->depth = 1; - if (pcs) { + if (pcs) *pcs++ = (uint64_t)instruction_pointer(regs); - limit--; - } + limit--; if (!limit) goto out; @@ -168,10 +167,9 @@ void dtrace_user_stacktrace(stacktrace_state_t *st) addr = ((struct reg_window32 *)(&t->reg_window[window]))->ins[7]; } - if (pcs) { + if (pcs) *pcs++ = addr; - limit--; - } + limit--; st->depth++; if (!limit) @@ -206,10 +204,9 @@ void dtrace_user_stacktrace(stacktrace_state_t *st) if (ret) break; - if (pcs) { + if (pcs) *pcs++ = addr; - limit--; - } + limit--; st->depth++; pagefault_disable(); diff --git a/arch/x86/kernel/dtrace_util.c b/arch/x86/kernel/dtrace_util.c index edd5fdf05290e..53d3c121aaa62 100644 --- a/arch/x86/kernel/dtrace_util.c +++ b/arch/x86/kernel/dtrace_util.c @@ -373,10 +373,9 @@ void dtrace_user_stacktrace(stacktrace_state_t *st) bos = current->dtrace_psinfo->ustack; st->depth = 1; - if (pcs) { + if (pcs) *pcs++ = (uint64_t)instruction_pointer(regs); - limit--; - } + limit--; if (!limit) goto out; @@ -391,11 +390,12 @@ void dtrace_user_stacktrace(stacktrace_state_t *st) if (ret) break; - if (dtrace_user_addr_is_exec(pc) && pcs) { - *pcs++ = pc; + if (dtrace_user_addr_is_exec(pc)) { + if (pcs) + *pcs++ = pc; limit--; + st->depth++; } - st->depth++; sp++; }