]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
dtrace: ensure limit is enforced even when pcs is NULL
authorKris Van Hees <kris.van.hees@oracle.com>
Wed, 24 May 2017 03:34:53 +0000 (23:34 -0400)
committerKris Van Hees <kris.van.hees@oracle.com>
Wed, 24 May 2017 15:23:49 +0000 (11:23 -0400)
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 <kris.van.hees@oracle.com>
Acked-by: Nick Alcock <nick.alcock@oracle.com>
arch/sparc/kernel/dtrace_util.c
arch/x86/kernel/dtrace_util.c

index 9e6629068225cdf8dcbb12211bcfcb360a668d70..47e19175cd7b7e903931cd599eb81fa49634159e 100644 (file)
@@ -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();
index edd5fdf05290eb828ef969501cf8fc4eb4059a00..53d3c121aaa62cd5ba835ad455033bc7e9745072 100644 (file)
@@ -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++;
        }