misc: tegra-profiler: verify stack pointer
Igor Nabirushkin [Sun, 29 Jan 2017 20:33:13 +0000 (00:33 +0400)]
Add additional stack pointer verification for DWARF unwinding
since stack always has to grow downwards in memory.
This commit prevents infinite loop when FDE entry is empty.

Bug 1868657

Change-Id: I4e8eda697606f2b9ca9d613b35ffad5a39a14be7
Signed-off-by: Igor Nabirushkin <inabirushkin@nvidia.com>
Reviewed-on: http://git-master/r/1295733
(cherry picked from commit 832bcf45afce219eb4beb8d0ad385f07ef40ac95)
Reviewed-on: http://git-master/r/1302041
(cherry picked from commit c9848e202c00f1ccc5edf14cb7c080c63ec119c9)

drivers/misc/tegra-profiler/dwarf_unwind.c

index c9214c3..9054e52 100644 (file)
@@ -2033,6 +2033,11 @@ unwind_backtrace(struct quadd_callchain *cc,
                cc->curr_pc = sf->pc;
                cc->curr_lr = sf->vregs[regnum_lr(mode)];
 
+               if (cc->curr_sp <= sp) {
+                       cc->urc_dwarf = QUADD_URC_SP_INCORRECT;
+                       break;
+               }
+
                nr_added = quadd_callchain_store(cc, sf->pc, unw_type);
                if (nr_added == 0)
                        break;