signal/arm64: Better isolate the COMPAT_TASK portion of ptrace_hbptriggered
authorEric W. Biederman <ebiederm@xmission.com>
Mon, 22 Jan 2018 20:50:53 +0000 (14:50 -0600)
committerEric W. Biederman <ebiederm@xmission.com>
Tue, 23 Jan 2018 01:06:48 +0000 (19:06 -0600)
Instead of jumpping while !is_compat_task placee all of the code
inside of an if (is_compat_task) block.  This allows the int i
variable to be properly limited to the compat block no matter how the
rest of ptrace_hbptriggered changes.

In a following change a non-variable declaration will preceed
was made independent to ensure the code is easy to review.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
arch/arm64/kernel/ptrace.c

index 7c44658b316d32585516f4f991740c68bff3a970..0a1cf830e4b36341411b69049e6f9ba570ebc378 100644 (file)
@@ -188,26 +188,23 @@ static void ptrace_hbptriggered(struct perf_event *bp,
        };
 
 #ifdef CONFIG_COMPAT
-       int i;
-
-       if (!is_compat_task())
-               goto send_sig;
+       if (is_compat_task()) {
+               int i;
 
-       for (i = 0; i < ARM_MAX_BRP; ++i) {
-               if (current->thread.debug.hbp_break[i] == bp) {
-                       info.si_errno = (i << 1) + 1;
-                       break;
+               for (i = 0; i < ARM_MAX_BRP; ++i) {
+                       if (current->thread.debug.hbp_break[i] == bp) {
+                               info.si_errno = (i << 1) + 1;
+                               break;
+                       }
                }
-       }
 
-       for (i = 0; i < ARM_MAX_WRP; ++i) {
-               if (current->thread.debug.hbp_watch[i] == bp) {
-                       info.si_errno = -((i << 1) + 1);
-                       break;
+               for (i = 0; i < ARM_MAX_WRP; ++i) {
+                       if (current->thread.debug.hbp_watch[i] == bp) {
+                               info.si_errno = -((i << 1) + 1);
+                               break;
+                       }
                }
        }
-
-send_sig:
 #endif
        force_sig_info(SIGTRAP, &info, current);
 }