Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: 6654/1: perf/oprofile: fix off-by-one in stack check

Since tail is the previous fp - 1, we need to compare the new fp with tail + 1
to ensure that we don't end up passing in the same tail again, in order to
avoid a potential infinite loop in the perf interrupt handler (which has been
observed to occur). A similar fix seems to be needed in the OProfile code.

Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by

Rabin Vincent and committed by
Russell King
cb06199b 4a9cb360

+2 -2
+1 -1
arch/arm/kernel/perf_event.c
··· 700 700 * Frame pointers should strictly progress back up the stack 701 701 * (towards higher addresses). 702 702 */ 703 - if (tail >= buftail.fp) 703 + if (tail + 1 >= buftail.fp) 704 704 return NULL; 705 705 706 706 return buftail.fp - 1;
+1 -1
arch/arm/oprofile/common.c
··· 85 85 86 86 /* frame pointers should strictly progress back up the stack 87 87 * (towards higher addresses) */ 88 - if (tail >= buftail[0].fp) 88 + if (tail + 1 >= buftail[0].fp) 89 89 return NULL; 90 90 91 91 return buftail[0].fp-1;