ARM: 6654/1: perf/oprofile: fix off-by-one in stack check
authorRabin Vincent <rabin.vincent@stericsson.com>
Wed, 9 Feb 2011 10:35:12 +0000 (11:35 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Thu, 10 Feb 2011 15:29:03 +0000 (15:29 +0000)
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>
arch/arm/kernel/perf_event.c
arch/arm/oprofile/common.c

index 5efa2647a2fb3bcdf26c58cec440adbc88724e74..d150ad1ccb5d8e3212e6461288f2c0a7ed451c85 100644 (file)
@@ -700,7 +700,7 @@ user_backtrace(struct frame_tail __user *tail,
         * Frame pointers should strictly progress back up the stack
         * (towards higher addresses).
         */
-       if (tail >= buftail.fp)
+       if (tail + 1 >= buftail.fp)
                return NULL;
 
        return buftail.fp - 1;
index 8aa974491dfcd555a6962461c0d2aa5f3287b653..6adda2b5fa31728a934c7400bcd17d5724d265ca 100644 (file)
@@ -85,7 +85,7 @@ static struct frame_tail* user_backtrace(struct frame_tail *tail)
 
        /* frame pointers should strictly progress back up the stack
         * (towards higher addresses) */
-       if (tail >= buftail[0].fp)
+       if (tail + 1 >= buftail[0].fp)
                return NULL;
 
        return buftail[0].fp-1;